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 /sway/desktop | |
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 'sway/desktop')
-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 |
5 files changed, 14 insertions, 15 deletions
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 | } |