diff options
author | Ryan Dwyer <ryandwyer1@gmail.com> | 2018-10-18 21:20:00 +1000 |
---|---|---|
committer | Ryan Dwyer <ryandwyer1@gmail.com> | 2018-10-20 13:11:43 +1000 |
commit | c006717910e5f30ca65645f701541dfa176c1392 (patch) | |
tree | c64452b7f2fe6ab481ad90c424cb14bcb0328eda /include/sway | |
parent | Merge pull request #2872 from RyanDwyer/cursor-rebase (diff) | |
download | sway-c006717910e5f30ca65645f701541dfa176c1392.tar.gz sway-c006717910e5f30ca65645f701541dfa176c1392.tar.zst sway-c006717910e5f30ca65645f701541dfa176c1392.zip |
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).
Diffstat (limited to 'include/sway')
-rw-r--r-- | include/sway/input/input-manager.h | 29 | ||||
-rw-r--r-- | include/sway/input/seat.h | 4 |
2 files changed, 9 insertions, 24 deletions
diff --git a/include/sway/input/input-manager.h b/include/sway/input/input-manager.h index b7073006..219aa9ba 100644 --- a/include/sway/input/input-manager.h +++ b/include/sway/input/input-manager.h | |||
@@ -7,12 +7,6 @@ | |||
7 | #include "sway/config.h" | 7 | #include "sway/config.h" |
8 | #include "list.h" | 8 | #include "list.h" |
9 | 9 | ||
10 | /** | ||
11 | * The global singleton input manager | ||
12 | * TODO: make me not a global | ||
13 | */ | ||
14 | extern struct sway_input_manager *input_manager; | ||
15 | |||
16 | struct sway_input_device { | 10 | struct sway_input_device { |
17 | char *identifier; | 11 | char *identifier; |
18 | struct wlr_input_device *wlr_device; | 12 | struct wlr_input_device *wlr_device; |
@@ -21,7 +15,6 @@ struct sway_input_device { | |||
21 | }; | 15 | }; |
22 | 16 | ||
23 | struct sway_input_manager { | 17 | struct sway_input_manager { |
24 | struct sway_server *server; | ||
25 | struct wl_list devices; | 18 | struct wl_list devices; |
26 | struct wl_list seats; | 19 | struct wl_list seats; |
27 | 20 | ||
@@ -36,30 +29,24 @@ struct sway_input_manager { | |||
36 | 29 | ||
37 | struct sway_input_manager *input_manager_create(struct sway_server *server); | 30 | struct sway_input_manager *input_manager_create(struct sway_server *server); |
38 | 31 | ||
39 | bool input_manager_has_focus(struct sway_input_manager *input, | 32 | bool input_manager_has_focus(struct sway_node *node); |
40 | struct sway_node *node); | ||
41 | 33 | ||
42 | void input_manager_set_focus(struct sway_input_manager *input, | 34 | void input_manager_set_focus(struct sway_node *node); |
43 | struct sway_node *node); | ||
44 | 35 | ||
45 | void input_manager_configure_xcursor(struct sway_input_manager *input); | 36 | void input_manager_configure_xcursor(void); |
46 | 37 | ||
47 | void input_manager_apply_input_config(struct sway_input_manager *input, | 38 | void input_manager_apply_input_config(struct input_config *input_config); |
48 | struct input_config *input_config); | ||
49 | 39 | ||
50 | void input_manager_apply_seat_config(struct sway_input_manager *input, | 40 | void input_manager_apply_seat_config(struct seat_config *seat_config); |
51 | struct seat_config *seat_config); | ||
52 | 41 | ||
53 | struct sway_seat *input_manager_get_default_seat( | 42 | struct sway_seat *input_manager_get_default_seat(void); |
54 | struct sway_input_manager *input); | ||
55 | 43 | ||
56 | struct sway_seat *input_manager_get_seat(struct sway_input_manager *input, | 44 | struct sway_seat *input_manager_get_seat(const char *seat_name); |
57 | const char *seat_name); | ||
58 | 45 | ||
59 | /** | 46 | /** |
60 | * Gets the last seat the user interacted with | 47 | * Gets the last seat the user interacted with |
61 | */ | 48 | */ |
62 | struct sway_seat *input_manager_current_seat(struct sway_input_manager *input); | 49 | struct sway_seat *input_manager_current_seat(void); |
63 | 50 | ||
64 | struct input_config *input_device_get_config(struct sway_input_device *device); | 51 | struct input_config *input_device_get_config(struct sway_input_device *device); |
65 | 52 | ||
diff --git a/include/sway/input/seat.h b/include/sway/input/seat.h index e9f553f3..ef65810c 100644 --- a/include/sway/input/seat.h +++ b/include/sway/input/seat.h | |||
@@ -47,7 +47,6 @@ enum sway_seat_operation { | |||
47 | struct sway_seat { | 47 | struct sway_seat { |
48 | struct wlr_seat *wlr_seat; | 48 | struct wlr_seat *wlr_seat; |
49 | struct sway_cursor *cursor; | 49 | struct sway_cursor *cursor; |
50 | struct sway_input_manager *input; | ||
51 | 50 | ||
52 | bool has_focus; | 51 | bool has_focus; |
53 | struct wl_list focus_stack; // list of containers in focus order | 52 | struct wl_list focus_stack; // list of containers in focus order |
@@ -89,8 +88,7 @@ struct sway_seat { | |||
89 | struct wl_list link; // input_manager::seats | 88 | struct wl_list link; // input_manager::seats |
90 | }; | 89 | }; |
91 | 90 | ||
92 | struct sway_seat *seat_create(struct sway_input_manager *input, | 91 | struct sway_seat *seat_create(const char *seat_name); |
93 | const char *seat_name); | ||
94 | 92 | ||
95 | void seat_destroy(struct sway_seat *seat); | 93 | void seat_destroy(struct sway_seat *seat); |
96 | 94 | ||