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/tree | |
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/tree')
-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 |
5 files changed, 27 insertions, 27 deletions
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) { |