summaryrefslogtreecommitdiffstats
path: root/include/sway/input
diff options
context:
space:
mode:
authorLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2018-10-18 21:20:00 +1000
committerLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2018-10-20 13:11:43 +1000
commitc006717910e5f30ca65645f701541dfa176c1392 (patch)
treec64452b7f2fe6ab481ad90c424cb14bcb0328eda /include/sway/input
parentMerge pull request #2872 from RyanDwyer/cursor-rebase (diff)
downloadsway-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/input')
-rw-r--r--include/sway/input/input-manager.h29
-rw-r--r--include/sway/input/seat.h4
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 */
14extern struct sway_input_manager *input_manager;
15
16struct sway_input_device { 10struct 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
23struct sway_input_manager { 17struct 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
37struct sway_input_manager *input_manager_create(struct sway_server *server); 30struct sway_input_manager *input_manager_create(struct sway_server *server);
38 31
39bool input_manager_has_focus(struct sway_input_manager *input, 32bool input_manager_has_focus(struct sway_node *node);
40 struct sway_node *node);
41 33
42void input_manager_set_focus(struct sway_input_manager *input, 34void input_manager_set_focus(struct sway_node *node);
43 struct sway_node *node);
44 35
45void input_manager_configure_xcursor(struct sway_input_manager *input); 36void input_manager_configure_xcursor(void);
46 37
47void input_manager_apply_input_config(struct sway_input_manager *input, 38void input_manager_apply_input_config(struct input_config *input_config);
48 struct input_config *input_config);
49 39
50void input_manager_apply_seat_config(struct sway_input_manager *input, 40void input_manager_apply_seat_config(struct seat_config *seat_config);
51 struct seat_config *seat_config);
52 41
53struct sway_seat *input_manager_get_default_seat( 42struct sway_seat *input_manager_get_default_seat(void);
54 struct sway_input_manager *input);
55 43
56struct sway_seat *input_manager_get_seat(struct sway_input_manager *input, 44struct 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 */
62struct sway_seat *input_manager_current_seat(struct sway_input_manager *input); 49struct sway_seat *input_manager_current_seat(void);
63 50
64struct input_config *input_device_get_config(struct sway_input_device *device); 51struct 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 {
47struct sway_seat { 47struct 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
92struct sway_seat *seat_create(struct sway_input_manager *input, 91struct sway_seat *seat_create(const char *seat_name);
93 const char *seat_name);
94 92
95void seat_destroy(struct sway_seat *seat); 93void seat_destroy(struct sway_seat *seat);
96 94