Minor refactor of input manager

The input manager is a singleton object. Passing the sway_input_manager
argument to each of its functions is unnecessary, while removing the
argument makes it obvious to the caller that it's a singleton. This
patch removes the argument and makes the input manager use server.input
instead.

On a similar note:

* sway_input_manager.server is removed in favour of using the server
global.
* seat.input is removed because it can get it from server.input.

Due to a circular dependency, creating seat0 is now done directly in
server_init rather than in input_manager_create. This is because
creating seats must be done after server.input is set.

Lastly, it now stores the default seat name using a constant and removes
a second reference to seat0 (in input_manager_get_default_seat).
This commit is contained in:
Ryan Dwyer 2018-10-18 21:20:00 +10:00
parent 5b8257b88f
commit c006717910
28 changed files with 116 additions and 149 deletions

View file

@ -7,12 +7,6 @@
#include "sway/config.h"
#include "list.h"
/**
* The global singleton input manager
* TODO: make me not a global
*/
extern struct sway_input_manager *input_manager;
struct sway_input_device {
char *identifier;
struct wlr_input_device *wlr_device;
@ -21,7 +15,6 @@ struct sway_input_device {
};
struct sway_input_manager {
struct sway_server *server;
struct wl_list devices;
struct wl_list seats;
@ -36,30 +29,24 @@ struct sway_input_manager {
struct sway_input_manager *input_manager_create(struct sway_server *server);
bool input_manager_has_focus(struct sway_input_manager *input,
struct sway_node *node);
bool input_manager_has_focus(struct sway_node *node);
void input_manager_set_focus(struct sway_input_manager *input,
struct sway_node *node);
void input_manager_set_focus(struct sway_node *node);
void input_manager_configure_xcursor(struct sway_input_manager *input);
void input_manager_configure_xcursor(void);
void input_manager_apply_input_config(struct sway_input_manager *input,
struct input_config *input_config);
void input_manager_apply_input_config(struct input_config *input_config);
void input_manager_apply_seat_config(struct sway_input_manager *input,
struct seat_config *seat_config);
void input_manager_apply_seat_config(struct seat_config *seat_config);
struct sway_seat *input_manager_get_default_seat(
struct sway_input_manager *input);
struct sway_seat *input_manager_get_default_seat(void);
struct sway_seat *input_manager_get_seat(struct sway_input_manager *input,
const char *seat_name);
struct sway_seat *input_manager_get_seat(const char *seat_name);
/**
* Gets the last seat the user interacted with
*/
struct sway_seat *input_manager_current_seat(struct sway_input_manager *input);
struct sway_seat *input_manager_current_seat(void);
struct input_config *input_device_get_config(struct sway_input_device *device);

View file

@ -47,7 +47,6 @@ enum sway_seat_operation {
struct sway_seat {
struct wlr_seat *wlr_seat;
struct sway_cursor *cursor;
struct sway_input_manager *input;
bool has_focus;
struct wl_list focus_stack; // list of containers in focus order
@ -89,8 +88,7 @@ struct sway_seat {
struct wl_list link; // input_manager::seats
};
struct sway_seat *seat_create(struct sway_input_manager *input,
const char *seat_name);
struct sway_seat *seat_create(const char *seat_name);
void seat_destroy(struct sway_seat *seat);