summaryrefslogtreecommitdiffstats
path: root/sway/tree/view.c
diff options
context:
space:
mode:
authorLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2018-10-18 21:20:00 +1000
committerLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2018-10-20 13:11:43 +1000
commitc006717910e5f30ca65645f701541dfa176c1392 (patch)
treec64452b7f2fe6ab481ad90c424cb14bcb0328eda /sway/tree/view.c
parentMerge pull request #2872 from RyanDwyer/cursor-rebase (diff)
downloadsway-c006717910e5f30ca65645f701541dfa176c1392.tar.gz
sway-c006717910e5f30ca65645f701541dfa176c1392.tar.zst
sway-c006717910e5f30ca65645f701541dfa176c1392.zip
Minor refactor of input manager
The input manager is a singleton object. Passing the sway_input_manager argument to each of its functions is unnecessary, while removing the argument makes it obvious to the caller that it's a singleton. This patch removes the argument and makes the input manager use server.input instead. On a similar note: * sway_input_manager.server is removed in favour of using the server global. * seat.input is removed because it can get it from server.input. Due to a circular dependency, creating seat0 is now done directly in server_init rather than in input_manager_create. This is because creating seats must be done after server.input is set. Lastly, it now stores the default seat name using a constant and removes a second reference to seat0 (in input_manager_get_default_seat).
Diffstat (limited to 'sway/tree/view.c')
-rw-r--r--sway/tree/view.c16
1 files changed, 8 insertions, 8 deletions
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
445static struct sway_workspace *select_workspace(struct sway_view *view) { 445static 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
519static bool should_focus(struct sway_view *view) { 519static 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 }