diff options
-rw-r--r-- | include/sway/input/input-manager.h | 29 | ||||
-rw-r--r-- | include/sway/input/seat.h | 4 | ||||
-rw-r--r-- | sway/commands.c | 4 | ||||
-rw-r--r-- | sway/commands/border.c | 2 | ||||
-rw-r--r-- | sway/commands/input.c | 2 | ||||
-rw-r--r-- | sway/commands/move.c | 2 | ||||
-rw-r--r-- | sway/commands/scratchpad.c | 2 | ||||
-rw-r--r-- | sway/commands/swap.c | 2 | ||||
-rw-r--r-- | sway/config.c | 3 | ||||
-rw-r--r-- | sway/criteria.c | 2 | ||||
-rw-r--r-- | sway/debug-tree.c | 2 | ||||
-rw-r--r-- | sway/desktop/layer_shell.c | 8 | ||||
-rw-r--r-- | sway/desktop/output.c | 2 | ||||
-rw-r--r-- | sway/desktop/render.c | 4 | ||||
-rw-r--r-- | sway/desktop/transaction.c | 4 | ||||
-rw-r--r-- | sway/desktop/xwayland.c | 11 | ||||
-rw-r--r-- | sway/input/cursor.c | 20 | ||||
-rw-r--r-- | sway/input/input-manager.c | 83 | ||||
-rw-r--r-- | sway/input/keyboard.c | 2 | ||||
-rw-r--r-- | sway/input/seat.c | 11 | ||||
-rw-r--r-- | sway/ipc-json.c | 2 | ||||
-rw-r--r-- | sway/ipc-server.c | 6 | ||||
-rw-r--r-- | sway/server.c | 4 | ||||
-rw-r--r-- | sway/tree/container.c | 16 | ||||
-rw-r--r-- | sway/tree/output.c | 4 | ||||
-rw-r--r-- | sway/tree/root.c | 8 | ||||
-rw-r--r-- | sway/tree/view.c | 16 | ||||
-rw-r--r-- | sway/tree/workspace.c | 10 |
28 files changed, 116 insertions, 149 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 | ||
diff --git a/sway/commands.c b/sway/commands.c index 8db1df01..d1275a1e 100644 --- a/sway/commands.c +++ b/sway/commands.c | |||
@@ -68,7 +68,7 @@ void apply_seat_config(struct seat_config *seat_config) { | |||
68 | list_add(config->seat_configs, seat_config); | 68 | list_add(config->seat_configs, seat_config); |
69 | } | 69 | } |
70 | 70 | ||
71 | input_manager_apply_seat_config(input_manager, seat_config); | 71 | input_manager_apply_seat_config(seat_config); |
72 | } | 72 | } |
73 | 73 | ||
74 | /* Keep alphabetized */ | 74 | /* Keep alphabetized */ |
@@ -240,7 +240,7 @@ struct cmd_results *execute_command(char *_exec, struct sway_seat *seat, | |||
240 | 240 | ||
241 | if (seat == NULL) { | 241 | if (seat == NULL) { |
242 | // passing a NULL seat means we just pick the default seat | 242 | // passing a NULL seat means we just pick the default seat |
243 | seat = input_manager_get_default_seat(input_manager); | 243 | seat = input_manager_get_default_seat(); |
244 | if (!sway_assert(seat, "could not find a seat to run the command on")) { | 244 | if (!sway_assert(seat, "could not find a seat to run the command on")) { |
245 | return NULL; | 245 | return NULL; |
246 | } | 246 | } |
diff --git a/sway/commands/border.c b/sway/commands/border.c index a50f7a1c..5b65148d 100644 --- a/sway/commands/border.c +++ b/sway/commands/border.c | |||
@@ -94,7 +94,7 @@ struct cmd_results *cmd_border(int argc, char **argv) { | |||
94 | 94 | ||
95 | arrange_container(view->container); | 95 | arrange_container(view->container); |
96 | 96 | ||
97 | struct sway_seat *seat = input_manager_current_seat(input_manager); | 97 | struct sway_seat *seat = input_manager_current_seat(); |
98 | if (seat->cursor) { | 98 | if (seat->cursor) { |
99 | cursor_rebase(seat->cursor); | 99 | cursor_rebase(seat->cursor); |
100 | } | 100 | } |
diff --git a/sway/commands/input.c b/sway/commands/input.c index 2889d47d..c50926a8 100644 --- a/sway/commands/input.c +++ b/sway/commands/input.c | |||
@@ -71,7 +71,7 @@ struct cmd_results *cmd_input(int argc, char **argv) { | |||
71 | struct input_config *ic = | 71 | struct input_config *ic = |
72 | store_input_config(config->handler_context.input_config); | 72 | store_input_config(config->handler_context.input_config); |
73 | 73 | ||
74 | input_manager_apply_input_config(input_manager, ic); | 74 | input_manager_apply_input_config(ic); |
75 | } else { | 75 | } else { |
76 | free_input_config(config->handler_context.input_config); | 76 | free_input_config(config->handler_context.input_config); |
77 | } | 77 | } |
diff --git a/sway/commands/move.c b/sway/commands/move.c index cb7f6009..941b284a 100644 --- a/sway/commands/move.c +++ b/sway/commands/move.c | |||
@@ -103,7 +103,7 @@ static void workspace_focus_fullscreen(struct sway_workspace *workspace) { | |||
103 | } | 103 | } |
104 | struct sway_seat *seat; | 104 | struct sway_seat *seat; |
105 | struct sway_workspace *focus_ws; | 105 | struct sway_workspace *focus_ws; |
106 | wl_list_for_each(seat, &input_manager->seats, link) { | 106 | wl_list_for_each(seat, &server.input->seats, link) { |
107 | focus_ws = seat_get_focused_workspace(seat); | 107 | focus_ws = seat_get_focused_workspace(seat); |
108 | if (focus_ws == workspace) { | 108 | if (focus_ws == workspace) { |
109 | struct sway_node *new_focus = | 109 | struct sway_node *new_focus = |
diff --git a/sway/commands/scratchpad.c b/sway/commands/scratchpad.c index d8bae615..26f0e490 100644 --- a/sway/commands/scratchpad.c +++ b/sway/commands/scratchpad.c | |||
@@ -8,7 +8,7 @@ | |||
8 | #include "sway/tree/workspace.h" | 8 | #include "sway/tree/workspace.h" |
9 | 9 | ||
10 | static void scratchpad_toggle_auto(void) { | 10 | static void scratchpad_toggle_auto(void) { |
11 | struct sway_seat *seat = input_manager_current_seat(input_manager); | 11 | struct sway_seat *seat = input_manager_current_seat(); |
12 | struct sway_container *focus = seat_get_focused_container(seat); | 12 | struct sway_container *focus = seat_get_focused_container(seat); |
13 | struct sway_workspace *ws = seat_get_focused_workspace(seat); | 13 | struct sway_workspace *ws = seat_get_focused_workspace(seat); |
14 | 14 | ||
diff --git a/sway/commands/swap.c b/sway/commands/swap.c index 8a6dfdbd..6062724d 100644 --- a/sway/commands/swap.c +++ b/sway/commands/swap.c | |||
@@ -108,7 +108,7 @@ static void container_swap(struct sway_container *con1, | |||
108 | container_set_fullscreen(con2, false); | 108 | container_set_fullscreen(con2, false); |
109 | } | 109 | } |
110 | 110 | ||
111 | struct sway_seat *seat = input_manager_get_default_seat(input_manager); | 111 | struct sway_seat *seat = input_manager_get_default_seat(); |
112 | struct sway_container *focus = seat_get_focused_container(seat); | 112 | struct sway_container *focus = seat_get_focused_container(seat); |
113 | struct sway_workspace *vis1 = | 113 | struct sway_workspace *vis1 = |
114 | output_get_active_workspace(con1->workspace->output); | 114 | output_get_active_workspace(con1->workspace->output); |
diff --git a/sway/config.c b/sway/config.c index 89b89464..f683e7ab 100644 --- a/sway/config.c +++ b/sway/config.c | |||
@@ -151,8 +151,7 @@ static void destroy_removed_seats(struct sway_config *old_config, | |||
151 | /* Also destroy seats that aren't present in new config */ | 151 | /* Also destroy seats that aren't present in new config */ |
152 | if (new_config && list_seq_find(new_config->seat_configs, | 152 | if (new_config && list_seq_find(new_config->seat_configs, |
153 | seat_name_cmp, seat_config->name) < 0) { | 153 | seat_name_cmp, seat_config->name) < 0) { |
154 | seat = input_manager_get_seat(input_manager, | 154 | seat = input_manager_get_seat(seat_config->name); |
155 | seat_config->name); | ||
156 | seat_destroy(seat); | 155 | seat_destroy(seat); |
157 | } | 156 | } |
158 | } | 157 | } |
diff --git a/sway/criteria.c b/sway/criteria.c index 575e8bcf..e00d638c 100644 --- a/sway/criteria.c +++ b/sway/criteria.c | |||
@@ -356,7 +356,7 @@ static enum criteria_token token_from_name(char *name) { | |||
356 | * criteria is only executed once per view. | 356 | * criteria is only executed once per view. |
357 | */ | 357 | */ |
358 | static char *get_focused_prop(enum criteria_token token) { | 358 | static char *get_focused_prop(enum criteria_token token) { |
359 | struct sway_seat *seat = input_manager_current_seat(input_manager); | 359 | struct sway_seat *seat = input_manager_current_seat(); |
360 | struct sway_container *focus = seat_get_focused_container(seat); | 360 | struct sway_container *focus = seat_get_focused_container(seat); |
361 | 361 | ||
362 | if (!focus || !focus->view) { | 362 | if (!focus || !focus->view) { |
diff --git a/sway/debug-tree.c b/sway/debug-tree.c index 16b479f9..b3266241 100644 --- a/sway/debug-tree.c +++ b/sway/debug-tree.c | |||
@@ -140,7 +140,7 @@ void update_debug_tree(void) { | |||
140 | cairo_t *cairo = cairo_create(surface); | 140 | cairo_t *cairo = cairo_create(surface); |
141 | PangoContext *pango = pango_cairo_create_context(cairo); | 141 | PangoContext *pango = pango_cairo_create_context(cairo); |
142 | 142 | ||
143 | struct sway_seat *seat = input_manager_current_seat(input_manager); | 143 | struct sway_seat *seat = input_manager_current_seat(); |
144 | struct sway_node *focus = seat_get_focus(seat); | 144 | struct sway_node *focus = seat_get_focus(seat); |
145 | 145 | ||
146 | cairo_set_source_u32(cairo, 0x000000FF); | 146 | cairo_set_source_u32(cairo, 0x000000FF); |
diff --git a/sway/desktop/layer_shell.c b/sway/desktop/layer_shell.c index 269864d4..cabb07f5 100644 --- a/sway/desktop/layer_shell.c +++ b/sway/desktop/layer_shell.c | |||
@@ -211,7 +211,7 @@ void arrange_layers(struct sway_output *output) { | |||
211 | } | 211 | } |
212 | 212 | ||
213 | struct sway_seat *seat; | 213 | struct sway_seat *seat; |
214 | wl_list_for_each(seat, &input_manager->seats, link) { | 214 | wl_list_for_each(seat, &server.input->seats, link) { |
215 | seat_set_focus_layer(seat, topmost ? topmost->layer_surface : NULL); | 215 | seat_set_focus_layer(seat, topmost ? topmost->layer_surface : NULL); |
216 | } | 216 | } |
217 | } | 217 | } |
@@ -241,7 +241,7 @@ static void handle_output_destroy(struct wl_listener *listener, void *data) { | |||
241 | wl_container_of(listener, sway_layer, output_destroy); | 241 | wl_container_of(listener, sway_layer, output_destroy); |
242 | // Determine if this layer is being used by an exclusive client. If it is, | 242 | // Determine if this layer is being used by an exclusive client. If it is, |
243 | // try and find another layer owned by this client to pass focus to. | 243 | // try and find another layer owned by this client to pass focus to. |
244 | struct sway_seat *seat = input_manager_get_default_seat(input_manager); | 244 | struct sway_seat *seat = input_manager_get_default_seat(); |
245 | struct wl_client *client = | 245 | struct wl_client *client = |
246 | wl_resource_get_client(sway_layer->layer_surface->resource); | 246 | wl_resource_get_client(sway_layer->layer_surface->resource); |
247 | bool set_focus = seat->exclusive_client == client; | 247 | bool set_focus = seat->exclusive_client == client; |
@@ -299,7 +299,7 @@ static void unmap(struct sway_layer_surface *sway_layer) { | |||
299 | output_damage_surface(output, sway_layer->geo.x, sway_layer->geo.y, | 299 | output_damage_surface(output, sway_layer->geo.x, sway_layer->geo.y, |
300 | sway_layer->layer_surface->surface, true); | 300 | sway_layer->layer_surface->surface, true); |
301 | 301 | ||
302 | struct sway_seat *seat = input_manager_current_seat(input_manager); | 302 | struct sway_seat *seat = input_manager_current_seat(); |
303 | if (seat->focused_layer == sway_layer->layer_surface) { | 303 | if (seat->focused_layer == sway_layer->layer_surface) { |
304 | seat_set_focus_layer(seat, NULL); | 304 | seat_set_focus_layer(seat, NULL); |
305 | } | 305 | } |
@@ -370,7 +370,7 @@ void handle_layer_shell_surface(struct wl_listener *listener, void *data) { | |||
370 | if (!layer_surface->output) { | 370 | if (!layer_surface->output) { |
371 | // Assign last active output | 371 | // Assign last active output |
372 | struct sway_output *output = NULL; | 372 | struct sway_output *output = NULL; |
373 | struct sway_seat *seat = input_manager_get_default_seat(input_manager); | 373 | struct sway_seat *seat = input_manager_get_default_seat(); |
374 | if (seat) { | 374 | if (seat) { |
375 | struct sway_workspace *ws = seat_get_focused_workspace(seat); | 375 | struct sway_workspace *ws = seat_get_focused_workspace(seat); |
376 | 376 | ||
diff --git a/sway/desktop/output.c b/sway/desktop/output.c index fc52dd28..018a7285 100644 --- a/sway/desktop/output.c +++ b/sway/desktop/output.c | |||
@@ -235,7 +235,7 @@ static void scale_box(struct wlr_box *box, float scale) { | |||
235 | } | 235 | } |
236 | 236 | ||
237 | struct sway_workspace *output_get_active_workspace(struct sway_output *output) { | 237 | struct sway_workspace *output_get_active_workspace(struct sway_output *output) { |
238 | struct sway_seat *seat = input_manager_current_seat(input_manager); | 238 | struct sway_seat *seat = input_manager_current_seat(); |
239 | struct sway_node *focus = seat_get_active_tiling_child(seat, &output->node); | 239 | struct sway_node *focus = seat_get_active_tiling_child(seat, &output->node); |
240 | if (!focus) { | 240 | if (!focus) { |
241 | return output->workspaces->items[0]; | 241 | return output->workspaces->items[0]; |
diff --git a/sway/desktop/render.c b/sway/desktop/render.c index 9b26c560..1a72f752 100644 --- a/sway/desktop/render.c +++ b/sway/desktop/render.c | |||
@@ -885,7 +885,7 @@ static void render_floating(struct sway_output *soutput, | |||
885 | static void render_dropzones(struct sway_output *output, | 885 | static void render_dropzones(struct sway_output *output, |
886 | pixman_region32_t *damage) { | 886 | pixman_region32_t *damage) { |
887 | struct sway_seat *seat; | 887 | struct sway_seat *seat; |
888 | wl_list_for_each(seat, &input_manager->seats, link) { | 888 | wl_list_for_each(seat, &server.input->seats, link) { |
889 | if (seat->operation == OP_MOVE_TILING && seat->op_target_node | 889 | if (seat->operation == OP_MOVE_TILING && seat->op_target_node |
890 | && node_get_output(seat->op_target_node) == output) { | 890 | && node_get_output(seat->op_target_node) == output) { |
891 | float color[4]; | 891 | float color[4]; |
@@ -995,7 +995,7 @@ void output_render(struct sway_output *output, struct timespec *when, | |||
995 | 995 | ||
996 | render_dropzones(output, damage); | 996 | render_dropzones(output, damage); |
997 | 997 | ||
998 | struct sway_seat *seat = input_manager_current_seat(input_manager); | 998 | struct sway_seat *seat = input_manager_current_seat(); |
999 | struct sway_container *focus = seat_get_focused_container(seat); | 999 | struct sway_container *focus = seat_get_focused_container(seat); |
1000 | if (focus && focus->view) { | 1000 | if (focus && focus->view) { |
1001 | render_view_popups(focus->view, output, damage, focus->alpha); | 1001 | render_view_popups(focus->view, output, damage, focus->alpha); |
diff --git a/sway/desktop/transaction.c b/sway/desktop/transaction.c index e717ee35..5dec279d 100644 --- a/sway/desktop/transaction.c +++ b/sway/desktop/transaction.c | |||
@@ -110,7 +110,7 @@ static void copy_workspace_state(struct sway_workspace *ws, | |||
110 | list_cat(state->floating, ws->floating); | 110 | list_cat(state->floating, ws->floating); |
111 | list_cat(state->tiling, ws->tiling); | 111 | list_cat(state->tiling, ws->tiling); |
112 | 112 | ||
113 | struct sway_seat *seat = input_manager_current_seat(input_manager); | 113 | struct sway_seat *seat = input_manager_current_seat(); |
114 | state->focused = seat_get_focus(seat) == &ws->node; | 114 | state->focused = seat_get_focus(seat) == &ws->node; |
115 | 115 | ||
116 | // Set focused_inactive_child to the direct tiling child | 116 | // Set focused_inactive_child to the direct tiling child |
@@ -153,7 +153,7 @@ static void copy_container_state(struct sway_container *container, | |||
153 | list_cat(state->children, container->children); | 153 | list_cat(state->children, container->children); |
154 | } | 154 | } |
155 | 155 | ||
156 | struct sway_seat *seat = input_manager_current_seat(input_manager); | 156 | struct sway_seat *seat = input_manager_current_seat(); |
157 | state->focused = seat_get_focus(seat) == &container->node; | 157 | state->focused = seat_get_focus(seat) == &container->node; |
158 | 158 | ||
159 | if (!container->view) { | 159 | if (!container->view) { |
diff --git a/sway/desktop/xwayland.c b/sway/desktop/xwayland.c index 066556b8..58cb4d07 100644 --- a/sway/desktop/xwayland.c +++ b/sway/desktop/xwayland.c | |||
@@ -70,9 +70,8 @@ static void unmanaged_handle_map(struct wl_listener *listener, void *data) { | |||
70 | desktop_damage_surface(xsurface->surface, surface->lx, surface->ly, true); | 70 | desktop_damage_surface(xsurface->surface, surface->lx, surface->ly, true); |
71 | 71 | ||
72 | if (wlr_xwayland_or_surface_wants_focus(xsurface)) { | 72 | if (wlr_xwayland_or_surface_wants_focus(xsurface)) { |
73 | struct sway_seat *seat = input_manager_current_seat(input_manager); | 73 | struct sway_seat *seat = input_manager_current_seat(); |
74 | struct wlr_xwayland *xwayland = | 74 | struct wlr_xwayland *xwayland = server.xwayland.wlr_xwayland; |
75 | seat->input->server->xwayland.wlr_xwayland; | ||
76 | wlr_xwayland_set_seat(xwayland, seat->wlr_seat); | 75 | wlr_xwayland_set_seat(xwayland, seat->wlr_seat); |
77 | seat_set_focus_surface(seat, xsurface->surface, false); | 76 | seat_set_focus_surface(seat, xsurface->surface, false); |
78 | } | 77 | } |
@@ -86,7 +85,7 @@ static void unmanaged_handle_unmap(struct wl_listener *listener, void *data) { | |||
86 | wl_list_remove(&surface->link); | 85 | wl_list_remove(&surface->link); |
87 | wl_list_remove(&surface->commit.link); | 86 | wl_list_remove(&surface->commit.link); |
88 | 87 | ||
89 | struct sway_seat *seat = input_manager_current_seat(input_manager); | 88 | struct sway_seat *seat = input_manager_current_seat(); |
90 | if (seat->wlr_seat->keyboard_state.focused_surface == | 89 | if (seat->wlr_seat->keyboard_state.focused_surface == |
91 | xsurface->surface) { | 90 | xsurface->surface) { |
92 | // Restore focus | 91 | // Restore focus |
@@ -457,7 +456,7 @@ static void handle_request_move(struct wl_listener *listener, void *data) { | |||
457 | if (!container_is_floating(view->container)) { | 456 | if (!container_is_floating(view->container)) { |
458 | return; | 457 | return; |
459 | } | 458 | } |
460 | struct sway_seat *seat = input_manager_current_seat(input_manager); | 459 | struct sway_seat *seat = input_manager_current_seat(); |
461 | seat_begin_move_floating(seat, view->container, seat->last_button); | 460 | seat_begin_move_floating(seat, view->container, seat->last_button); |
462 | } | 461 | } |
463 | 462 | ||
@@ -473,7 +472,7 @@ static void handle_request_resize(struct wl_listener *listener, void *data) { | |||
473 | return; | 472 | return; |
474 | } | 473 | } |
475 | struct wlr_xwayland_resize_event *e = data; | 474 | struct wlr_xwayland_resize_event *e = data; |
476 | struct sway_seat *seat = input_manager_current_seat(input_manager); | 475 | struct sway_seat *seat = input_manager_current_seat(); |
477 | seat_begin_resize_floating(seat, view->container, | 476 | seat_begin_resize_floating(seat, view->container, |
478 | seat->last_button, e->edges); | 477 | seat->last_button, e->edges); |
479 | } | 478 | } |
diff --git a/sway/input/cursor.c b/sway/input/cursor.c index 756f2f8c..a07bc53b 100644 --- a/sway/input/cursor.c +++ b/sway/input/cursor.c | |||
@@ -680,7 +680,7 @@ void cursor_send_pointer_motion(struct sway_cursor *cursor, | |||
680 | 680 | ||
681 | static void handle_cursor_motion(struct wl_listener *listener, void *data) { | 681 | static void handle_cursor_motion(struct wl_listener *listener, void *data) { |
682 | struct sway_cursor *cursor = wl_container_of(listener, cursor, motion); | 682 | struct sway_cursor *cursor = wl_container_of(listener, cursor, motion); |
683 | wlr_idle_notify_activity(cursor->seat->input->server->idle, cursor->seat->wlr_seat); | 683 | wlr_idle_notify_activity(server.idle, cursor->seat->wlr_seat); |
684 | struct wlr_event_pointer_motion *event = data; | 684 | struct wlr_event_pointer_motion *event = data; |
685 | wlr_cursor_move(cursor->cursor, event->device, | 685 | wlr_cursor_move(cursor->cursor, event->device, |
686 | event->delta_x, event->delta_y); | 686 | event->delta_x, event->delta_y); |
@@ -692,7 +692,7 @@ static void handle_cursor_motion_absolute( | |||
692 | struct wl_listener *listener, void *data) { | 692 | struct wl_listener *listener, void *data) { |
693 | struct sway_cursor *cursor = | 693 | struct sway_cursor *cursor = |
694 | wl_container_of(listener, cursor, motion_absolute); | 694 | wl_container_of(listener, cursor, motion_absolute); |
695 | wlr_idle_notify_activity(cursor->seat->input->server->idle, cursor->seat->wlr_seat); | 695 | wlr_idle_notify_activity(server.idle, cursor->seat->wlr_seat); |
696 | struct wlr_event_pointer_motion_absolute *event = data; | 696 | struct wlr_event_pointer_motion_absolute *event = data; |
697 | wlr_cursor_warp_absolute(cursor->cursor, event->device, event->x, event->y); | 697 | wlr_cursor_warp_absolute(cursor->cursor, event->device, event->x, event->y); |
698 | cursor_send_pointer_motion(cursor, event->time_msec); | 698 | cursor_send_pointer_motion(cursor, event->time_msec); |
@@ -970,7 +970,7 @@ void dispatch_cursor_button(struct sway_cursor *cursor, | |||
970 | 970 | ||
971 | static void handle_cursor_button(struct wl_listener *listener, void *data) { | 971 | static void handle_cursor_button(struct wl_listener *listener, void *data) { |
972 | struct sway_cursor *cursor = wl_container_of(listener, cursor, button); | 972 | struct sway_cursor *cursor = wl_container_of(listener, cursor, button); |
973 | wlr_idle_notify_activity(cursor->seat->input->server->idle, cursor->seat->wlr_seat); | 973 | wlr_idle_notify_activity(server.idle, cursor->seat->wlr_seat); |
974 | struct wlr_event_pointer_button *event = data; | 974 | struct wlr_event_pointer_button *event = data; |
975 | dispatch_cursor_button(cursor, event->device, | 975 | dispatch_cursor_button(cursor, event->device, |
976 | event->time_msec, event->button, event->state); | 976 | event->time_msec, event->button, event->state); |
@@ -1019,7 +1019,7 @@ static void dispatch_cursor_axis(struct sway_cursor *cursor, | |||
1019 | 1019 | ||
1020 | static void handle_cursor_axis(struct wl_listener *listener, void *data) { | 1020 | static void handle_cursor_axis(struct wl_listener *listener, void *data) { |
1021 | struct sway_cursor *cursor = wl_container_of(listener, cursor, axis); | 1021 | struct sway_cursor *cursor = wl_container_of(listener, cursor, axis); |
1022 | wlr_idle_notify_activity(cursor->seat->input->server->idle, cursor->seat->wlr_seat); | 1022 | wlr_idle_notify_activity(server.idle, cursor->seat->wlr_seat); |
1023 | struct wlr_event_pointer_axis *event = data; | 1023 | struct wlr_event_pointer_axis *event = data; |
1024 | dispatch_cursor_axis(cursor, event); | 1024 | dispatch_cursor_axis(cursor, event); |
1025 | transaction_commit_dirty(); | 1025 | transaction_commit_dirty(); |
@@ -1027,7 +1027,7 @@ static void handle_cursor_axis(struct wl_listener *listener, void *data) { | |||
1027 | 1027 | ||
1028 | static void handle_touch_down(struct wl_listener *listener, void *data) { | 1028 | static void handle_touch_down(struct wl_listener *listener, void *data) { |
1029 | struct sway_cursor *cursor = wl_container_of(listener, cursor, touch_down); | 1029 | struct sway_cursor *cursor = wl_container_of(listener, cursor, touch_down); |
1030 | wlr_idle_notify_activity(cursor->seat->input->server->idle, cursor->seat->wlr_seat); | 1030 | wlr_idle_notify_activity(server.idle, cursor->seat->wlr_seat); |
1031 | struct wlr_event_touch_down *event = data; | 1031 | struct wlr_event_touch_down *event = data; |
1032 | 1032 | ||
1033 | struct sway_seat *seat = cursor->seat; | 1033 | struct sway_seat *seat = cursor->seat; |
@@ -1058,7 +1058,7 @@ static void handle_touch_down(struct wl_listener *listener, void *data) { | |||
1058 | 1058 | ||
1059 | static void handle_touch_up(struct wl_listener *listener, void *data) { | 1059 | static void handle_touch_up(struct wl_listener *listener, void *data) { |
1060 | struct sway_cursor *cursor = wl_container_of(listener, cursor, touch_up); | 1060 | struct sway_cursor *cursor = wl_container_of(listener, cursor, touch_up); |
1061 | wlr_idle_notify_activity(cursor->seat->input->server->idle, cursor->seat->wlr_seat); | 1061 | wlr_idle_notify_activity(server.idle, cursor->seat->wlr_seat); |
1062 | struct wlr_event_touch_up *event = data; | 1062 | struct wlr_event_touch_up *event = data; |
1063 | struct wlr_seat *seat = cursor->seat->wlr_seat; | 1063 | struct wlr_seat *seat = cursor->seat->wlr_seat; |
1064 | // TODO: fall back to cursor simulation if client has not bound to touch | 1064 | // TODO: fall back to cursor simulation if client has not bound to touch |
@@ -1068,7 +1068,7 @@ static void handle_touch_up(struct wl_listener *listener, void *data) { | |||
1068 | static void handle_touch_motion(struct wl_listener *listener, void *data) { | 1068 | static void handle_touch_motion(struct wl_listener *listener, void *data) { |
1069 | struct sway_cursor *cursor = | 1069 | struct sway_cursor *cursor = |
1070 | wl_container_of(listener, cursor, touch_motion); | 1070 | wl_container_of(listener, cursor, touch_motion); |
1071 | wlr_idle_notify_activity(cursor->seat->input->server->idle, cursor->seat->wlr_seat); | 1071 | wlr_idle_notify_activity(server.idle, cursor->seat->wlr_seat); |
1072 | struct wlr_event_touch_motion *event = data; | 1072 | struct wlr_event_touch_motion *event = data; |
1073 | 1073 | ||
1074 | struct sway_seat *seat = cursor->seat; | 1074 | struct sway_seat *seat = cursor->seat; |
@@ -1132,7 +1132,7 @@ static void apply_mapping_from_region(struct wlr_input_device *device, | |||
1132 | 1132 | ||
1133 | static void handle_tool_axis(struct wl_listener *listener, void *data) { | 1133 | static void handle_tool_axis(struct wl_listener *listener, void *data) { |
1134 | struct sway_cursor *cursor = wl_container_of(listener, cursor, tool_axis); | 1134 | struct sway_cursor *cursor = wl_container_of(listener, cursor, tool_axis); |
1135 | wlr_idle_notify_activity(cursor->seat->input->server->idle, cursor->seat->wlr_seat); | 1135 | wlr_idle_notify_activity(server.idle, cursor->seat->wlr_seat); |
1136 | struct wlr_event_tablet_tool_axis *event = data; | 1136 | struct wlr_event_tablet_tool_axis *event = data; |
1137 | struct sway_input_device *input_device = event->device->data; | 1137 | struct sway_input_device *input_device = event->device->data; |
1138 | 1138 | ||
@@ -1156,7 +1156,7 @@ static void handle_tool_axis(struct wl_listener *listener, void *data) { | |||
1156 | 1156 | ||
1157 | static void handle_tool_tip(struct wl_listener *listener, void *data) { | 1157 | static void handle_tool_tip(struct wl_listener *listener, void *data) { |
1158 | struct sway_cursor *cursor = wl_container_of(listener, cursor, tool_tip); | 1158 | struct sway_cursor *cursor = wl_container_of(listener, cursor, tool_tip); |
1159 | wlr_idle_notify_activity(cursor->seat->input->server->idle, cursor->seat->wlr_seat); | 1159 | wlr_idle_notify_activity(server.idle, cursor->seat->wlr_seat); |
1160 | struct wlr_event_tablet_tool_tip *event = data; | 1160 | struct wlr_event_tablet_tool_tip *event = data; |
1161 | dispatch_cursor_button(cursor, event->device, event->time_msec, | 1161 | dispatch_cursor_button(cursor, event->device, event->time_msec, |
1162 | BTN_LEFT, event->state == WLR_TABLET_TOOL_TIP_DOWN ? | 1162 | BTN_LEFT, event->state == WLR_TABLET_TOOL_TIP_DOWN ? |
@@ -1166,7 +1166,7 @@ static void handle_tool_tip(struct wl_listener *listener, void *data) { | |||
1166 | 1166 | ||
1167 | static void handle_tool_button(struct wl_listener *listener, void *data) { | 1167 | static void handle_tool_button(struct wl_listener *listener, void *data) { |
1168 | struct sway_cursor *cursor = wl_container_of(listener, cursor, tool_button); | 1168 | struct sway_cursor *cursor = wl_container_of(listener, cursor, tool_button); |
1169 | wlr_idle_notify_activity(cursor->seat->input->server->idle, cursor->seat->wlr_seat); | 1169 | wlr_idle_notify_activity(server.idle, cursor->seat->wlr_seat); |
1170 | struct wlr_event_tablet_tool_button *event = data; | 1170 | struct wlr_event_tablet_tool_button *event = data; |
1171 | // TODO: the user may want to configure which tool buttons are mapped to | 1171 | // TODO: the user may want to configure which tool buttons are mapped to |
1172 | // which simulated pointer buttons | 1172 | // which simulated pointer buttons |
diff --git a/sway/input/input-manager.c b/sway/input/input-manager.c index 671f9a47..5be4143f 100644 --- a/sway/input/input-manager.c +++ b/sway/input/input-manager.c | |||
@@ -17,32 +17,28 @@ | |||
17 | #include "list.h" | 17 | #include "list.h" |
18 | #include "log.h" | 18 | #include "log.h" |
19 | 19 | ||
20 | static const char *default_seat = "seat0"; | 20 | #define DEFAULT_SEAT "seat0" |
21 | |||
22 | // TODO make me not global | ||
23 | struct sway_input_manager *input_manager; | ||
24 | 21 | ||
25 | struct input_config *current_input_config = NULL; | 22 | struct input_config *current_input_config = NULL; |
26 | struct seat_config *current_seat_config = NULL; | 23 | struct seat_config *current_seat_config = NULL; |
27 | 24 | ||
28 | struct sway_seat *input_manager_current_seat(struct sway_input_manager *input) { | 25 | struct sway_seat *input_manager_current_seat(void) { |
29 | struct sway_seat *seat = config->handler_context.seat; | 26 | struct sway_seat *seat = config->handler_context.seat; |
30 | if (!seat) { | 27 | if (!seat) { |
31 | seat = input_manager_get_default_seat(input_manager); | 28 | seat = input_manager_get_default_seat(); |
32 | } | 29 | } |
33 | return seat; | 30 | return seat; |
34 | } | 31 | } |
35 | 32 | ||
36 | struct sway_seat *input_manager_get_seat( | 33 | struct sway_seat *input_manager_get_seat(const char *seat_name) { |
37 | struct sway_input_manager *input, const char *seat_name) { | ||
38 | struct sway_seat *seat = NULL; | 34 | struct sway_seat *seat = NULL; |
39 | wl_list_for_each(seat, &input->seats, link) { | 35 | wl_list_for_each(seat, &server.input->seats, link) { |
40 | if (strcmp(seat->wlr_seat->name, seat_name) == 0) { | 36 | if (strcmp(seat->wlr_seat->name, seat_name) == 0) { |
41 | return seat; | 37 | return seat; |
42 | } | 38 | } |
43 | } | 39 | } |
44 | 40 | ||
45 | return seat_create(input, seat_name); | 41 | return seat_create(seat_name); |
46 | } | 42 | } |
47 | 43 | ||
48 | char *input_device_get_identifier(struct wlr_input_device *device) { | 44 | char *input_device_get_identifier(struct wlr_input_device *device) { |
@@ -72,9 +68,9 @@ char *input_device_get_identifier(struct wlr_input_device *device) { | |||
72 | } | 68 | } |
73 | 69 | ||
74 | static struct sway_input_device *input_sway_device_from_wlr( | 70 | static struct sway_input_device *input_sway_device_from_wlr( |
75 | struct sway_input_manager *input, struct wlr_input_device *device) { | 71 | struct wlr_input_device *device) { |
76 | struct sway_input_device *input_device = NULL; | 72 | struct sway_input_device *input_device = NULL; |
77 | wl_list_for_each(input_device, &input->devices, link) { | 73 | wl_list_for_each(input_device, &server.input->devices, link) { |
78 | if (input_device->wlr_device == device) { | 74 | if (input_device->wlr_device == device) { |
79 | return input_device; | 75 | return input_device; |
80 | } | 76 | } |
@@ -82,9 +78,9 @@ static struct sway_input_device *input_sway_device_from_wlr( | |||
82 | return NULL; | 78 | return NULL; |
83 | } | 79 | } |
84 | 80 | ||
85 | static bool input_has_seat_configuration(struct sway_input_manager *input) { | 81 | static bool input_has_seat_configuration(void) { |
86 | struct sway_seat *seat = NULL; | 82 | struct sway_seat *seat = NULL; |
87 | wl_list_for_each(seat, &input->seats, link) { | 83 | wl_list_for_each(seat, &server.input->seats, link) { |
88 | struct seat_config *seat_config = seat_get_config(seat); | 84 | struct seat_config *seat_config = seat_get_config(seat); |
89 | if (seat_config) { | 85 | if (seat_config) { |
90 | return true; | 86 | return true; |
@@ -244,8 +240,7 @@ static void input_manager_libinput_config_pointer( | |||
244 | static void handle_device_destroy(struct wl_listener *listener, void *data) { | 240 | static void handle_device_destroy(struct wl_listener *listener, void *data) { |
245 | struct wlr_input_device *device = data; | 241 | struct wlr_input_device *device = data; |
246 | 242 | ||
247 | struct sway_input_device *input_device = | 243 | struct sway_input_device *input_device = input_sway_device_from_wlr(device); |
248 | input_sway_device_from_wlr(input_manager, device); | ||
249 | 244 | ||
250 | if (!sway_assert(input_device, "could not find sway device")) { | 245 | if (!sway_assert(input_device, "could not find sway device")) { |
251 | return; | 246 | return; |
@@ -255,7 +250,7 @@ static void handle_device_destroy(struct wl_listener *listener, void *data) { | |||
255 | input_device->identifier); | 250 | input_device->identifier); |
256 | 251 | ||
257 | struct sway_seat *seat = NULL; | 252 | struct sway_seat *seat = NULL; |
258 | wl_list_for_each(seat, &input_manager->seats, link) { | 253 | wl_list_for_each(seat, &server.input->seats, link) { |
259 | seat_remove_device(seat, input_device); | 254 | seat_remove_device(seat, input_device); |
260 | } | 255 | } |
261 | 256 | ||
@@ -297,9 +292,9 @@ static void handle_new_input(struct wl_listener *listener, void *data) { | |||
297 | input_device->device_destroy.notify = handle_device_destroy; | 292 | input_device->device_destroy.notify = handle_device_destroy; |
298 | 293 | ||
299 | struct sway_seat *seat = NULL; | 294 | struct sway_seat *seat = NULL; |
300 | if (!input_has_seat_configuration(input)) { | 295 | if (!input_has_seat_configuration()) { |
301 | wlr_log(WLR_DEBUG, "no seat configuration, using default seat"); | 296 | wlr_log(WLR_DEBUG, "no seat configuration, using default seat"); |
302 | seat = input_manager_get_seat(input, default_seat); | 297 | seat = input_manager_get_seat(DEFAULT_SEAT); |
303 | seat_add_device(seat, input_device); | 298 | seat_add_device(seat, input_device); |
304 | return; | 299 | return; |
305 | } | 300 | } |
@@ -364,7 +359,7 @@ void handle_virtual_keyboard(struct wl_listener *listener, void *data) { | |||
364 | struct wlr_virtual_keyboard_v1 *keyboard = data; | 359 | struct wlr_virtual_keyboard_v1 *keyboard = data; |
365 | struct wlr_input_device *device = &keyboard->input_device; | 360 | struct wlr_input_device *device = &keyboard->input_device; |
366 | 361 | ||
367 | struct sway_seat *seat = input_manager_get_default_seat(input_manager); | 362 | struct sway_seat *seat = input_manager_get_default_seat(); |
368 | 363 | ||
369 | // TODO: The user might want this on a different seat | 364 | // TODO: The user might want this on a different seat |
370 | struct sway_input_device *input_device = | 365 | struct sway_input_device *input_device = |
@@ -387,21 +382,16 @@ void handle_virtual_keyboard(struct wl_listener *listener, void *data) { | |||
387 | seat_add_device(seat, input_device); | 382 | seat_add_device(seat, input_device); |
388 | } | 383 | } |
389 | 384 | ||
390 | struct sway_input_manager *input_manager_create( | 385 | struct sway_input_manager *input_manager_create(struct sway_server *server) { |
391 | struct sway_server *server) { | ||
392 | struct sway_input_manager *input = | 386 | struct sway_input_manager *input = |
393 | calloc(1, sizeof(struct sway_input_manager)); | 387 | calloc(1, sizeof(struct sway_input_manager)); |
394 | if (!input) { | 388 | if (!input) { |
395 | return NULL; | 389 | return NULL; |
396 | } | 390 | } |
397 | input->server = server; | ||
398 | 391 | ||
399 | wl_list_init(&input->devices); | 392 | wl_list_init(&input->devices); |
400 | wl_list_init(&input->seats); | 393 | wl_list_init(&input->seats); |
401 | 394 | ||
402 | // create the default seat | ||
403 | input_manager_get_seat(input, default_seat); | ||
404 | |||
405 | input->new_input.notify = handle_new_input; | 395 | input->new_input.notify = handle_new_input; |
406 | wl_signal_add(&server->backend->events.new_input, &input->new_input); | 396 | wl_signal_add(&server->backend->events.new_input, &input->new_input); |
407 | 397 | ||
@@ -422,10 +412,9 @@ struct sway_input_manager *input_manager_create( | |||
422 | return input; | 412 | return input; |
423 | } | 413 | } |
424 | 414 | ||
425 | bool input_manager_has_focus(struct sway_input_manager *input, | 415 | bool input_manager_has_focus(struct sway_node *node) { |
426 | struct sway_node *node) { | ||
427 | struct sway_seat *seat = NULL; | 416 | struct sway_seat *seat = NULL; |
428 | wl_list_for_each(seat, &input->seats, link) { | 417 | wl_list_for_each(seat, &server.input->seats, link) { |
429 | if (seat_get_focus(seat) == node) { | 418 | if (seat_get_focus(seat) == node) { |
430 | return true; | 419 | return true; |
431 | } | 420 | } |
@@ -434,19 +423,17 @@ bool input_manager_has_focus(struct sway_input_manager *input, | |||
434 | return false; | 423 | return false; |
435 | } | 424 | } |
436 | 425 | ||
437 | void input_manager_set_focus(struct sway_input_manager *input, | 426 | void input_manager_set_focus(struct sway_node *node) { |
438 | struct sway_node *node) { | ||
439 | struct sway_seat *seat; | 427 | struct sway_seat *seat; |
440 | wl_list_for_each(seat, &input->seats, link) { | 428 | wl_list_for_each(seat, &server.input->seats, link) { |
441 | seat_set_focus(seat, node); | 429 | seat_set_focus(seat, node); |
442 | } | 430 | } |
443 | } | 431 | } |
444 | 432 | ||
445 | void input_manager_apply_input_config(struct sway_input_manager *input, | 433 | void input_manager_apply_input_config(struct input_config *input_config) { |
446 | struct input_config *input_config) { | ||
447 | struct sway_input_device *input_device = NULL; | 434 | struct sway_input_device *input_device = NULL; |
448 | bool wildcard = strcmp(input_config->identifier, "*") == 0; | 435 | bool wildcard = strcmp(input_config->identifier, "*") == 0; |
449 | wl_list_for_each(input_device, &input->devices, link) { | 436 | wl_list_for_each(input_device, &server.input->devices, link) { |
450 | if (strcmp(input_device->identifier, input_config->identifier) == 0 | 437 | if (strcmp(input_device->identifier, input_config->identifier) == 0 |
451 | || wildcard) { | 438 | || wildcard) { |
452 | if (input_device->wlr_device->type == WLR_INPUT_DEVICE_POINTER || | 439 | if (input_device->wlr_device->type == WLR_INPUT_DEVICE_POINTER || |
@@ -459,18 +446,17 @@ void input_manager_apply_input_config(struct sway_input_manager *input, | |||
459 | } | 446 | } |
460 | 447 | ||
461 | struct sway_seat *seat = NULL; | 448 | struct sway_seat *seat = NULL; |
462 | wl_list_for_each(seat, &input->seats, link) { | 449 | wl_list_for_each(seat, &server.input->seats, link) { |
463 | seat_configure_device(seat, input_device); | 450 | seat_configure_device(seat, input_device); |
464 | } | 451 | } |
465 | } | 452 | } |
466 | } | 453 | } |
467 | } | 454 | } |
468 | 455 | ||
469 | void input_manager_apply_seat_config(struct sway_input_manager *input, | 456 | void input_manager_apply_seat_config(struct seat_config *seat_config) { |
470 | struct seat_config *seat_config) { | ||
471 | wlr_log(WLR_DEBUG, "applying new seat config for seat %s", | 457 | wlr_log(WLR_DEBUG, "applying new seat config for seat %s", |
472 | seat_config->name); | 458 | seat_config->name); |
473 | struct sway_seat *seat = input_manager_get_seat(input, seat_config->name); | 459 | struct sway_seat *seat = input_manager_get_seat(seat_config->name); |
474 | if (!seat) { | 460 | if (!seat) { |
475 | return; | 461 | return; |
476 | } | 462 | } |
@@ -480,10 +466,10 @@ void input_manager_apply_seat_config(struct sway_input_manager *input, | |||
480 | // for every device, try to add it to a seat and if no seat has it | 466 | // for every device, try to add it to a seat and if no seat has it |
481 | // attached, add it to the fallback seats. | 467 | // attached, add it to the fallback seats. |
482 | struct sway_input_device *input_device = NULL; | 468 | struct sway_input_device *input_device = NULL; |
483 | wl_list_for_each(input_device, &input->devices, link) { | 469 | wl_list_for_each(input_device, &server.input->devices, link) { |
484 | list_t *seat_list = create_list(); | 470 | list_t *seat_list = create_list(); |
485 | struct sway_seat *seat = NULL; | 471 | struct sway_seat *seat = NULL; |
486 | wl_list_for_each(seat, &input->seats, link) { | 472 | wl_list_for_each(seat, &server.input->seats, link) { |
487 | struct seat_config *seat_config = seat_get_config(seat); | 473 | struct seat_config *seat_config = seat_get_config(seat); |
488 | if (!seat_config) { | 474 | if (!seat_config) { |
489 | continue; | 475 | continue; |
@@ -496,7 +482,7 @@ void input_manager_apply_seat_config(struct sway_input_manager *input, | |||
496 | } | 482 | } |
497 | 483 | ||
498 | if (seat_list->length) { | 484 | if (seat_list->length) { |
499 | wl_list_for_each(seat, &input->seats, link) { | 485 | wl_list_for_each(seat, &server.input->seats, link) { |
500 | bool attached = false; | 486 | bool attached = false; |
501 | for (int i = 0; i < seat_list->length; ++i) { | 487 | for (int i = 0; i < seat_list->length; ++i) { |
502 | if (seat == seat_list->items[i]) { | 488 | if (seat == seat_list->items[i]) { |
@@ -511,7 +497,7 @@ void input_manager_apply_seat_config(struct sway_input_manager *input, | |||
511 | } | 497 | } |
512 | } | 498 | } |
513 | } else { | 499 | } else { |
514 | wl_list_for_each(seat, &input->seats, link) { | 500 | wl_list_for_each(seat, &server.input->seats, link) { |
515 | struct seat_config *seat_config = seat_get_config(seat); | 501 | struct seat_config *seat_config = seat_get_config(seat); |
516 | if (seat_config && seat_config->fallback == 1) { | 502 | if (seat_config && seat_config->fallback == 1) { |
517 | seat_add_device(seat, input_device); | 503 | seat_add_device(seat, input_device); |
@@ -524,18 +510,17 @@ void input_manager_apply_seat_config(struct sway_input_manager *input, | |||
524 | } | 510 | } |
525 | } | 511 | } |
526 | 512 | ||
527 | void input_manager_configure_xcursor(struct sway_input_manager *input) { | 513 | void input_manager_configure_xcursor(void) { |
528 | struct sway_seat *seat = NULL; | 514 | struct sway_seat *seat = NULL; |
529 | wl_list_for_each(seat, &input->seats, link) { | 515 | wl_list_for_each(seat, &server.input->seats, link) { |
530 | seat_configure_xcursor(seat); | 516 | seat_configure_xcursor(seat); |
531 | } | 517 | } |
532 | } | 518 | } |
533 | 519 | ||
534 | struct sway_seat *input_manager_get_default_seat( | 520 | struct sway_seat *input_manager_get_default_seat(void) { |
535 | struct sway_input_manager *input) { | ||
536 | struct sway_seat *seat = NULL; | 521 | struct sway_seat *seat = NULL; |
537 | wl_list_for_each(seat, &input->seats, link) { | 522 | wl_list_for_each(seat, &server.input->seats, link) { |
538 | if (strcmp(seat->wlr_seat->name, "seat0") == 0) { | 523 | if (strcmp(seat->wlr_seat->name, DEFAULT_SEAT) == 0) { |
539 | return seat; | 524 | return seat; |
540 | } | 525 | } |
541 | } | 526 | } |
diff --git a/sway/input/keyboard.c b/sway/input/keyboard.c index 4427dabe..5c1e7ae6 100644 --- a/sway/input/keyboard.c +++ b/sway/input/keyboard.c | |||
@@ -211,7 +211,7 @@ static void handle_keyboard_key(struct wl_listener *listener, void *data) { | |||
211 | struct wlr_input_device *wlr_device = | 211 | struct wlr_input_device *wlr_device = |
212 | keyboard->seat_device->input_device->wlr_device; | 212 | keyboard->seat_device->input_device->wlr_device; |
213 | char *device_identifier = input_device_get_identifier(wlr_device); | 213 | char *device_identifier = input_device_get_identifier(wlr_device); |
214 | wlr_idle_notify_activity(seat->input->server->idle, wlr_seat); | 214 | wlr_idle_notify_activity(server.idle, wlr_seat); |
215 | struct wlr_event_keyboard_key *event = data; | 215 | struct wlr_event_keyboard_key *event = data; |
216 | bool input_inhibited = seat->exclusive_client != NULL; | 216 | bool input_inhibited = seat->exclusive_client != NULL; |
217 | 217 | ||
diff --git a/sway/input/seat.c b/sway/input/seat.c index d7733855..330b7bbe 100644 --- a/sway/input/seat.c +++ b/sway/input/seat.c | |||
@@ -95,8 +95,7 @@ static void seat_send_focus(struct sway_node *node, struct sway_seat *seat) { | |||
95 | if (view && seat_is_input_allowed(seat, view->surface)) { | 95 | if (view && seat_is_input_allowed(seat, view->surface)) { |
96 | #ifdef HAVE_XWAYLAND | 96 | #ifdef HAVE_XWAYLAND |
97 | if (view->type == SWAY_VIEW_XWAYLAND) { | 97 | if (view->type == SWAY_VIEW_XWAYLAND) { |
98 | struct wlr_xwayland *xwayland = | 98 | struct wlr_xwayland *xwayland = server.xwayland.wlr_xwayland; |
99 | seat->input->server->xwayland.wlr_xwayland; | ||
100 | wlr_xwayland_set_seat(xwayland, seat->wlr_seat); | 99 | wlr_xwayland_set_seat(xwayland, seat->wlr_seat); |
101 | } | 100 | } |
102 | #endif | 101 | #endif |
@@ -328,14 +327,13 @@ static void collect_focus_container_iter(struct sway_container *container, | |||
328 | collect_focus_iter(&container->node, data); | 327 | collect_focus_iter(&container->node, data); |
329 | } | 328 | } |
330 | 329 | ||
331 | struct sway_seat *seat_create(struct sway_input_manager *input, | 330 | struct sway_seat *seat_create(const char *seat_name) { |
332 | const char *seat_name) { | ||
333 | struct sway_seat *seat = calloc(1, sizeof(struct sway_seat)); | 331 | struct sway_seat *seat = calloc(1, sizeof(struct sway_seat)); |
334 | if (!seat) { | 332 | if (!seat) { |
335 | return NULL; | 333 | return NULL; |
336 | } | 334 | } |
337 | 335 | ||
338 | seat->wlr_seat = wlr_seat_create(input->server->wl_display, seat_name); | 336 | seat->wlr_seat = wlr_seat_create(server.wl_display, seat_name); |
339 | if (!sway_assert(seat->wlr_seat, "could not allocate seat")) { | 337 | if (!sway_assert(seat->wlr_seat, "could not allocate seat")) { |
340 | free(seat); | 338 | free(seat); |
341 | return NULL; | 339 | return NULL; |
@@ -361,10 +359,9 @@ struct sway_seat *seat_create(struct sway_input_manager *input, | |||
361 | wl_signal_add(&seat->wlr_seat->events.new_drag_icon, &seat->new_drag_icon); | 359 | wl_signal_add(&seat->wlr_seat->events.new_drag_icon, &seat->new_drag_icon); |
362 | seat->new_drag_icon.notify = handle_new_drag_icon; | 360 | seat->new_drag_icon.notify = handle_new_drag_icon; |
363 | 361 | ||
364 | seat->input = input; | ||
365 | wl_list_init(&seat->devices); | 362 | wl_list_init(&seat->devices); |
366 | 363 | ||
367 | wl_list_insert(&input->seats, &seat->link); | 364 | wl_list_insert(&server.input->seats, &seat->link); |
368 | 365 | ||
369 | return seat; | 366 | return seat; |
370 | } | 367 | } |
diff --git a/sway/ipc-json.c b/sway/ipc-json.c index 54d611f2..a29647ed 100644 --- a/sway/ipc-json.c +++ b/sway/ipc-json.c | |||
@@ -340,7 +340,7 @@ static void focus_inactive_children_iterator(struct sway_node *node, | |||
340 | } | 340 | } |
341 | 341 | ||
342 | json_object *ipc_json_describe_node(struct sway_node *node) { | 342 | json_object *ipc_json_describe_node(struct sway_node *node) { |
343 | struct sway_seat *seat = input_manager_get_default_seat(input_manager); | 343 | struct sway_seat *seat = input_manager_get_default_seat(); |
344 | bool focused = seat_get_focus(seat) == node; | 344 | bool focused = seat_get_focus(seat) == node; |
345 | 345 | ||
346 | json_object *object = json_object_new_object(); | 346 | json_object *object = json_object_new_object(); |
diff --git a/sway/ipc-server.c b/sway/ipc-server.c index 63c95503..619d2aef 100644 --- a/sway/ipc-server.c +++ b/sway/ipc-server.c | |||
@@ -547,7 +547,7 @@ static void ipc_get_workspaces_callback(struct sway_workspace *workspace, | |||
547 | json_object *workspace_json = ipc_json_describe_node(&workspace->node); | 547 | json_object *workspace_json = ipc_json_describe_node(&workspace->node); |
548 | // override the default focused indicator because | 548 | // override the default focused indicator because |
549 | // it's set differently for the get_workspaces reply | 549 | // it's set differently for the get_workspaces reply |
550 | struct sway_seat *seat = input_manager_get_default_seat(input_manager); | 550 | struct sway_seat *seat = input_manager_get_default_seat(); |
551 | struct sway_workspace *focused_ws = seat_get_focused_workspace(seat); | 551 | struct sway_workspace *focused_ws = seat_get_focused_workspace(seat); |
552 | bool focused = workspace == focused_ws; | 552 | bool focused = workspace == focused_ws; |
553 | json_object_object_del(workspace_json, "focused"); | 553 | json_object_object_del(workspace_json, "focused"); |
@@ -702,7 +702,7 @@ void ipc_client_handle_command(struct ipc_client *client) { | |||
702 | { | 702 | { |
703 | json_object *inputs = json_object_new_array(); | 703 | json_object *inputs = json_object_new_array(); |
704 | struct sway_input_device *device = NULL; | 704 | struct sway_input_device *device = NULL; |
705 | wl_list_for_each(device, &input_manager->devices, link) { | 705 | wl_list_for_each(device, &server.input->devices, link) { |
706 | json_object_array_add(inputs, ipc_json_describe_input(device)); | 706 | json_object_array_add(inputs, ipc_json_describe_input(device)); |
707 | } | 707 | } |
708 | const char *json_string = json_object_to_json_string(inputs); | 708 | const char *json_string = json_object_to_json_string(inputs); |
@@ -716,7 +716,7 @@ void ipc_client_handle_command(struct ipc_client *client) { | |||
716 | { | 716 | { |
717 | json_object *seats = json_object_new_array(); | 717 | json_object *seats = json_object_new_array(); |
718 | struct sway_seat *seat = NULL; | 718 | struct sway_seat *seat = NULL; |
719 | wl_list_for_each(seat, &input_manager->seats, link) { | 719 | wl_list_for_each(seat, &server.input->seats, link) { |
720 | json_object_array_add(seats, ipc_json_describe_seat(seat)); | 720 | json_object_array_add(seats, ipc_json_describe_seat(seat)); |
721 | } | 721 | } |
722 | const char *json_string = json_object_to_json_string(seats); | 722 | const char *json_string = json_object_to_json_string(seats); |
diff --git a/sway/server.c b/sway/server.c index 1fd7b7fa..23d42028 100644 --- a/sway/server.c +++ b/sway/server.c | |||
@@ -153,7 +153,9 @@ bool server_init(struct sway_server *server) { | |||
153 | server->dirty_nodes = create_list(); | 153 | server->dirty_nodes = create_list(); |
154 | server->transactions = create_list(); | 154 | server->transactions = create_list(); |
155 | 155 | ||
156 | input_manager = input_manager_create(server); | 156 | server->input = input_manager_create(server); |
157 | input_manager_get_default_seat(); // create seat0 | ||
158 | |||
157 | return true; | 159 | return true; |
158 | } | 160 | } |
159 | 161 | ||
diff --git a/sway/tree/container.c b/sway/tree/container.c index edab7a17..b41e8dd4 100644 --- a/sway/tree/container.c +++ b/sway/tree/container.c | |||
@@ -200,7 +200,7 @@ static struct sway_container *container_at_tabbed(struct sway_node *parent, | |||
200 | if (ly < box.y || ly > box.y + box.height) { | 200 | if (ly < box.y || ly > box.y + box.height) { |
201 | return NULL; | 201 | return NULL; |
202 | } | 202 | } |
203 | struct sway_seat *seat = input_manager_current_seat(input_manager); | 203 | struct sway_seat *seat = input_manager_current_seat(); |
204 | list_t *children = node_get_children(parent); | 204 | list_t *children = node_get_children(parent); |
205 | if (!children->length) { | 205 | if (!children->length) { |
206 | return NULL; | 206 | return NULL; |
@@ -234,7 +234,7 @@ static struct sway_container *container_at_stacked(struct sway_node *parent, | |||
234 | if (ly < box.y || ly > box.y + box.height) { | 234 | if (ly < box.y || ly > box.y + box.height) { |
235 | return NULL; | 235 | return NULL; |
236 | } | 236 | } |
237 | struct sway_seat *seat = input_manager_current_seat(input_manager); | 237 | struct sway_seat *seat = input_manager_current_seat(); |
238 | list_t *children = node_get_children(parent); | 238 | list_t *children = node_get_children(parent); |
239 | 239 | ||
240 | // Title bars | 240 | // Title bars |
@@ -358,7 +358,7 @@ struct sway_container *container_at(struct sway_workspace *workspace, | |||
358 | struct wlr_surface **surface, double *sx, double *sy) { | 358 | struct wlr_surface **surface, double *sx, double *sy) { |
359 | struct sway_container *c; | 359 | struct sway_container *c; |
360 | 360 | ||
361 | struct sway_seat *seat = input_manager_current_seat(input_manager); | 361 | struct sway_seat *seat = input_manager_current_seat(); |
362 | struct sway_container *focus = seat_get_focused_container(seat); | 362 | struct sway_container *focus = seat_get_focused_container(seat); |
363 | bool is_floating = focus && container_is_floating_or_child(focus); | 363 | bool is_floating = focus && container_is_floating_or_child(focus); |
364 | // Focused view's popups | 364 | // Focused view's popups |
@@ -651,7 +651,7 @@ void container_set_floating(struct sway_container *container, bool enable) { | |||
651 | return; | 651 | return; |
652 | } | 652 | } |
653 | 653 | ||
654 | struct sway_seat *seat = input_manager_current_seat(input_manager); | 654 | struct sway_seat *seat = input_manager_current_seat(); |
655 | struct sway_workspace *workspace = container->workspace; | 655 | struct sway_workspace *workspace = container->workspace; |
656 | 656 | ||
657 | if (enable) { | 657 | if (enable) { |
@@ -843,7 +843,7 @@ bool container_has_urgent_child(struct sway_container *container) { | |||
843 | 843 | ||
844 | void container_end_mouse_operation(struct sway_container *container) { | 844 | void container_end_mouse_operation(struct sway_container *container) { |
845 | struct sway_seat *seat; | 845 | struct sway_seat *seat; |
846 | wl_list_for_each(seat, &input_manager->seats, link) { | 846 | wl_list_for_each(seat, &server.input->seats, link) { |
847 | if (seat->op_container == container) { | 847 | if (seat->op_container == container) { |
848 | seat->op_target_node = NULL; // ensure tiling move doesn't apply | 848 | seat->op_target_node = NULL; // ensure tiling move doesn't apply |
849 | seat_end_mouse_operation(seat); | 849 | seat_end_mouse_operation(seat); |
@@ -890,7 +890,7 @@ void container_set_fullscreen(struct sway_container *container, bool enable) { | |||
890 | 890 | ||
891 | struct sway_seat *seat; | 891 | struct sway_seat *seat; |
892 | struct sway_workspace *focus_ws; | 892 | struct sway_workspace *focus_ws; |
893 | wl_list_for_each(seat, &input_manager->seats, link) { | 893 | wl_list_for_each(seat, &server.input->seats, link) { |
894 | focus_ws = seat_get_focused_workspace(seat); | 894 | focus_ws = seat_get_focused_workspace(seat); |
895 | if (focus_ws) { | 895 | if (focus_ws) { |
896 | if (focus_ws == workspace) { | 896 | if (focus_ws == workspace) { |
@@ -1033,7 +1033,7 @@ void container_add_gaps(struct sway_container *c) { | |||
1033 | struct sway_view *view = c->view; | 1033 | struct sway_view *view = c->view; |
1034 | if (!view) { | 1034 | if (!view) { |
1035 | struct sway_seat *seat = | 1035 | struct sway_seat *seat = |
1036 | input_manager_get_default_seat(input_manager); | 1036 | input_manager_get_default_seat(); |
1037 | struct sway_container *focus = | 1037 | struct sway_container *focus = |
1038 | seat_get_focus_inactive_view(seat, &c->node); | 1038 | seat_get_focus_inactive_view(seat, &c->node); |
1039 | view = focus ? focus->view : NULL; | 1039 | view = focus ? focus->view : NULL; |
@@ -1187,7 +1187,7 @@ void container_replace(struct sway_container *container, | |||
1187 | 1187 | ||
1188 | struct sway_container *container_split(struct sway_container *child, | 1188 | struct sway_container *container_split(struct sway_container *child, |
1189 | enum sway_container_layout layout) { | 1189 | enum sway_container_layout layout) { |
1190 | struct sway_seat *seat = input_manager_get_default_seat(input_manager); | 1190 | struct sway_seat *seat = input_manager_get_default_seat(); |
1191 | bool set_focus = (seat_get_focus(seat) == &child->node); | 1191 | bool set_focus = (seat_get_focus(seat) == &child->node); |
1192 | 1192 | ||
1193 | struct sway_container *cont = container_create(NULL); | 1193 | struct sway_container *cont = container_create(NULL); |
diff --git a/sway/tree/output.c b/sway/tree/output.c index c3176325..524a64ab 100644 --- a/sway/tree/output.c +++ b/sway/tree/output.c | |||
@@ -83,7 +83,7 @@ void output_enable(struct sway_output *output, struct output_config *oc) { | |||
83 | struct sway_workspace *ws = workspace_create(output, ws_name); | 83 | struct sway_workspace *ws = workspace_create(output, ws_name); |
84 | // Set each seat's focus if not already set | 84 | // Set each seat's focus if not already set |
85 | struct sway_seat *seat = NULL; | 85 | struct sway_seat *seat = NULL; |
86 | wl_list_for_each(seat, &input_manager->seats, link) { | 86 | wl_list_for_each(seat, &server.input->seats, link) { |
87 | if (!seat->has_focus) { | 87 | if (!seat->has_focus) { |
88 | seat_set_focus_workspace(seat, ws); | 88 | seat_set_focus_workspace(seat, ws); |
89 | } | 89 | } |
@@ -97,7 +97,7 @@ void output_enable(struct sway_output *output, struct output_config *oc) { | |||
97 | } | 97 | } |
98 | wl_signal_init(&output->events.destroy); | 98 | wl_signal_init(&output->events.destroy); |
99 | 99 | ||
100 | input_manager_configure_xcursor(input_manager); | 100 | input_manager_configure_xcursor(); |
101 | 101 | ||
102 | wl_signal_add(&wlr_output->events.mode, &output->mode); | 102 | wl_signal_add(&wlr_output->events.mode, &output->mode); |
103 | wl_signal_add(&wlr_output->events.transform, &output->transform); | 103 | wl_signal_add(&wlr_output->events.transform, &output->transform); |
diff --git a/sway/tree/root.c b/sway/tree/root.c index 6748e9c9..e5eb8f2a 100644 --- a/sway/tree/root.c +++ b/sway/tree/root.c | |||
@@ -67,7 +67,7 @@ void root_scratchpad_add_container(struct sway_container *con) { | |||
67 | container_set_floating(con, true); | 67 | container_set_floating(con, true); |
68 | container_detach(con); | 68 | container_detach(con); |
69 | 69 | ||
70 | struct sway_seat *seat = input_manager_current_seat(input_manager); | 70 | struct sway_seat *seat = input_manager_current_seat(); |
71 | if (parent) { | 71 | if (parent) { |
72 | arrange_container(parent); | 72 | arrange_container(parent); |
73 | seat_set_focus(seat, seat_get_focus_inactive(seat, &parent->node)); | 73 | seat_set_focus(seat, seat_get_focus_inactive(seat, &parent->node)); |
@@ -89,7 +89,7 @@ void root_scratchpad_remove_container(struct sway_container *con) { | |||
89 | } | 89 | } |
90 | 90 | ||
91 | void root_scratchpad_show(struct sway_container *con) { | 91 | void root_scratchpad_show(struct sway_container *con) { |
92 | struct sway_seat *seat = input_manager_current_seat(input_manager); | 92 | struct sway_seat *seat = input_manager_current_seat(); |
93 | struct sway_workspace *ws = seat_get_focused_workspace(seat); | 93 | struct sway_workspace *ws = seat_get_focused_workspace(seat); |
94 | 94 | ||
95 | // If the current con or any of its parents are in fullscreen mode, we | 95 | // If the current con or any of its parents are in fullscreen mode, we |
@@ -127,7 +127,7 @@ void root_scratchpad_show(struct sway_container *con) { | |||
127 | } | 127 | } |
128 | 128 | ||
129 | void root_scratchpad_hide(struct sway_container *con) { | 129 | void root_scratchpad_hide(struct sway_container *con) { |
130 | struct sway_seat *seat = input_manager_current_seat(input_manager); | 130 | struct sway_seat *seat = input_manager_current_seat(); |
131 | struct sway_node *focus = seat_get_focus(seat); | 131 | struct sway_node *focus = seat_get_focus(seat); |
132 | struct sway_workspace *ws = con->workspace; | 132 | struct sway_workspace *ws = con->workspace; |
133 | 133 | ||
@@ -210,7 +210,7 @@ void root_record_workspace_pid(pid_t pid) { | |||
210 | wl_list_init(&pid_workspaces); | 210 | wl_list_init(&pid_workspaces); |
211 | } | 211 | } |
212 | 212 | ||
213 | struct sway_seat *seat = input_manager_current_seat(input_manager); | 213 | struct sway_seat *seat = input_manager_current_seat(); |
214 | struct sway_workspace *ws = seat_get_focused_workspace(seat); | 214 | struct sway_workspace *ws = seat_get_focused_workspace(seat); |
215 | if (!ws) { | 215 | if (!ws) { |
216 | wlr_log(WLR_DEBUG, "Bailing out, no workspace"); | 216 | wlr_log(WLR_DEBUG, "Bailing out, no workspace"); |
diff --git a/sway/tree/view.c b/sway/tree/view.c index 43a9d510..85afbb87 100644 --- a/sway/tree/view.c +++ b/sway/tree/view.c | |||
@@ -305,7 +305,7 @@ void view_request_activate(struct sway_view *view) { | |||
305 | if (!ws) { // hidden scratchpad container | 305 | if (!ws) { // hidden scratchpad container |
306 | return; | 306 | return; |
307 | } | 307 | } |
308 | struct sway_seat *seat = input_manager_current_seat(input_manager); | 308 | struct sway_seat *seat = input_manager_current_seat(); |
309 | 309 | ||
310 | switch (config->focus_on_window_activation) { | 310 | switch (config->focus_on_window_activation) { |
311 | case FOWA_SMART: | 311 | case FOWA_SMART: |
@@ -443,7 +443,7 @@ void view_execute_criteria(struct sway_view *view) { | |||
443 | } | 443 | } |
444 | 444 | ||
445 | static struct sway_workspace *select_workspace(struct sway_view *view) { | 445 | static struct sway_workspace *select_workspace(struct sway_view *view) { |
446 | struct sway_seat *seat = input_manager_current_seat(input_manager); | 446 | struct sway_seat *seat = input_manager_current_seat(); |
447 | 447 | ||
448 | // Check if there's any `assign` criteria for the view | 448 | // Check if there's any `assign` criteria for the view |
449 | list_t *criterias = criteria_for_view(view, | 449 | list_t *criterias = criteria_for_view(view, |
@@ -517,7 +517,7 @@ static struct sway_workspace *select_workspace(struct sway_view *view) { | |||
517 | } | 517 | } |
518 | 518 | ||
519 | static bool should_focus(struct sway_view *view) { | 519 | static bool should_focus(struct sway_view *view) { |
520 | struct sway_seat *seat = input_manager_current_seat(input_manager); | 520 | struct sway_seat *seat = input_manager_current_seat(); |
521 | struct sway_container *prev_con = seat_get_focused_container(seat); | 521 | struct sway_container *prev_con = seat_get_focused_container(seat); |
522 | struct sway_workspace *prev_ws = seat_get_focused_workspace(seat); | 522 | struct sway_workspace *prev_ws = seat_get_focused_workspace(seat); |
523 | struct sway_workspace *map_ws = view->container->workspace; | 523 | struct sway_workspace *map_ws = view->container->workspace; |
@@ -551,7 +551,7 @@ void view_map(struct sway_view *view, struct wlr_surface *wlr_surface, | |||
551 | } | 551 | } |
552 | view->surface = wlr_surface; | 552 | view->surface = wlr_surface; |
553 | 553 | ||
554 | struct sway_seat *seat = input_manager_current_seat(input_manager); | 554 | struct sway_seat *seat = input_manager_current_seat(); |
555 | struct sway_workspace *ws = select_workspace(view); | 555 | struct sway_workspace *ws = select_workspace(view); |
556 | struct sway_node *node = seat_get_focus_inactive(seat, &ws->node); | 556 | struct sway_node *node = seat_get_focus_inactive(seat, &ws->node); |
557 | struct sway_container *target_sibling = node->type == N_CONTAINER ? | 557 | struct sway_container *target_sibling = node->type == N_CONTAINER ? |
@@ -616,7 +616,7 @@ void view_map(struct sway_view *view, struct wlr_surface *wlr_surface, | |||
616 | } | 616 | } |
617 | 617 | ||
618 | if (should_focus(view)) { | 618 | if (should_focus(view)) { |
619 | input_manager_set_focus(input_manager, &view->container->node); | 619 | input_manager_set_focus(&view->container->node); |
620 | } | 620 | } |
621 | } | 621 | } |
622 | 622 | ||
@@ -645,7 +645,7 @@ void view_unmap(struct sway_view *view) { | |||
645 | } | 645 | } |
646 | 646 | ||
647 | struct sway_seat *seat; | 647 | struct sway_seat *seat; |
648 | wl_list_for_each(seat, &input_manager->seats, link) { | 648 | wl_list_for_each(seat, &server.input->seats, link) { |
649 | if (config->mouse_warping == WARP_CONTAINER) { | 649 | if (config->mouse_warping == WARP_CONTAINER) { |
650 | struct sway_node *node = seat_get_focus(seat); | 650 | struct sway_node *node = seat_get_focus(seat); |
651 | if (node && node->type == N_CONTAINER) { | 651 | if (node && node->type == N_CONTAINER) { |
@@ -1106,7 +1106,7 @@ bool view_is_visible(struct sway_view *view) { | |||
1106 | return false; | 1106 | return false; |
1107 | } | 1107 | } |
1108 | // Check view isn't in a tabbed or stacked container on an inactive tab | 1108 | // Check view isn't in a tabbed or stacked container on an inactive tab |
1109 | struct sway_seat *seat = input_manager_current_seat(input_manager); | 1109 | struct sway_seat *seat = input_manager_current_seat(); |
1110 | struct sway_container *con = view->container; | 1110 | struct sway_container *con = view->container; |
1111 | while (con) { | 1111 | while (con) { |
1112 | enum sway_container_layout layout = container_parent_layout(con); | 1112 | enum sway_container_layout layout = container_parent_layout(con); |
@@ -1138,7 +1138,7 @@ void view_set_urgent(struct sway_view *view, bool enable) { | |||
1138 | return; | 1138 | return; |
1139 | } | 1139 | } |
1140 | if (enable) { | 1140 | if (enable) { |
1141 | struct sway_seat *seat = input_manager_current_seat(input_manager); | 1141 | struct sway_seat *seat = input_manager_current_seat(); |
1142 | if (seat_get_focused_container(seat) == view->container) { | 1142 | if (seat_get_focused_container(seat) == view->container) { |
1143 | return; | 1143 | return; |
1144 | } | 1144 | } |
diff --git a/sway/tree/workspace.c b/sway/tree/workspace.c index 2a00824d..e840219f 100644 --- a/sway/tree/workspace.c +++ b/sway/tree/workspace.c | |||
@@ -40,7 +40,7 @@ struct sway_output *workspace_get_initial_output(const char *name) { | |||
40 | } | 40 | } |
41 | } | 41 | } |
42 | // Otherwise put it on the focused output | 42 | // Otherwise put it on the focused output |
43 | struct sway_seat *seat = input_manager_current_seat(input_manager); | 43 | struct sway_seat *seat = input_manager_current_seat(); |
44 | struct sway_workspace *focus = seat_get_focused_workspace(seat); | 44 | struct sway_workspace *focus = seat_get_focused_workspace(seat); |
45 | return focus->output; | 45 | return focus->output; |
46 | } | 46 | } |
@@ -287,7 +287,7 @@ static bool _workspace_by_name(struct sway_workspace *ws, void *data) { | |||
287 | } | 287 | } |
288 | 288 | ||
289 | struct sway_workspace *workspace_by_name(const char *name) { | 289 | struct sway_workspace *workspace_by_name(const char *name) { |
290 | struct sway_seat *seat = input_manager_current_seat(input_manager); | 290 | struct sway_seat *seat = input_manager_current_seat(); |
291 | struct sway_workspace *current = seat_get_focused_workspace(seat); | 291 | struct sway_workspace *current = seat_get_focused_workspace(seat); |
292 | 292 | ||
293 | if (strcmp(name, "prev") == 0) { | 293 | if (strcmp(name, "prev") == 0) { |
@@ -316,7 +316,7 @@ struct sway_workspace *workspace_by_name(const char *name) { | |||
316 | */ | 316 | */ |
317 | static struct sway_workspace *workspace_output_prev_next_impl( | 317 | static struct sway_workspace *workspace_output_prev_next_impl( |
318 | struct sway_output *output, int dir) { | 318 | struct sway_output *output, int dir) { |
319 | struct sway_seat *seat = input_manager_current_seat(input_manager); | 319 | struct sway_seat *seat = input_manager_current_seat(); |
320 | struct sway_workspace *workspace = seat_get_focused_workspace(seat); | 320 | struct sway_workspace *workspace = seat_get_focused_workspace(seat); |
321 | 321 | ||
322 | int index = list_find(output->workspaces, workspace); | 322 | int index = list_find(output->workspaces, workspace); |
@@ -368,7 +368,7 @@ struct sway_workspace *workspace_prev(struct sway_workspace *current) { | |||
368 | 368 | ||
369 | bool workspace_switch(struct sway_workspace *workspace, | 369 | bool workspace_switch(struct sway_workspace *workspace, |
370 | bool no_auto_back_and_forth) { | 370 | bool no_auto_back_and_forth) { |
371 | struct sway_seat *seat = input_manager_current_seat(input_manager); | 371 | struct sway_seat *seat = input_manager_current_seat(); |
372 | struct sway_workspace *active_ws = seat_get_focused_workspace(seat); | 372 | struct sway_workspace *active_ws = seat_get_focused_workspace(seat); |
373 | 373 | ||
374 | if (!no_auto_back_and_forth && config->auto_back_and_forth | 374 | if (!no_auto_back_and_forth && config->auto_back_and_forth |
@@ -619,7 +619,7 @@ void workspace_add_gaps(struct sway_workspace *ws) { | |||
619 | return; | 619 | return; |
620 | } | 620 | } |
621 | if (config->smart_gaps) { | 621 | if (config->smart_gaps) { |
622 | struct sway_seat *seat = input_manager_get_default_seat(input_manager); | 622 | struct sway_seat *seat = input_manager_get_default_seat(); |
623 | struct sway_container *focus = | 623 | struct sway_container *focus = |
624 | seat_get_focus_inactive_tiling(seat, ws); | 624 | seat_get_focus_inactive_tiling(seat, ws); |
625 | if (focus && !focus->view) { | 625 | if (focus && !focus->view) { |