diff options
author | emersion <contact@emersion.fr> | 2018-09-06 12:56:21 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-09-06 12:56:21 +0200 |
commit | 8e2a2e5ca457c73a62857bd9860c8e34d07ab78e (patch) | |
tree | ff0b87cfe7158e00501e9dc8a571e3b8cce2dbe0 | |
parent | Merge pull request #2590 from RyanDwyer/fix-output-active-workspace (diff) | |
parent | Introduce seat_set_focus_container and seat_set_focus_workspace (diff) | |
download | sway-8e2a2e5ca457c73a62857bd9860c8e34d07ab78e.tar.gz sway-8e2a2e5ca457c73a62857bd9860c8e34d07ab78e.tar.zst sway-8e2a2e5ca457c73a62857bd9860c8e34d07ab78e.zip |
Merge pull request #2589 from RyanDwyer/seat-set-focus-type
Introduce seat_set_focus_container and seat_set_focus_workspace
-rw-r--r-- | include/sway/input/seat.h | 6 | ||||
-rw-r--r-- | sway/commands/floating.c | 2 | ||||
-rw-r--r-- | sway/commands/focus.c | 6 | ||||
-rw-r--r-- | sway/commands/fullscreen.c | 2 | ||||
-rw-r--r-- | sway/commands/move.c | 7 | ||||
-rw-r--r-- | sway/commands/swap.c | 10 | ||||
-rw-r--r-- | sway/input/cursor.c | 8 | ||||
-rw-r--r-- | sway/input/seat.c | 10 | ||||
-rw-r--r-- | sway/tree/container.c | 6 | ||||
-rw-r--r-- | sway/tree/output.c | 2 | ||||
-rw-r--r-- | sway/tree/view.c | 6 | ||||
-rw-r--r-- | sway/tree/workspace.c | 2 |
12 files changed, 42 insertions, 25 deletions
diff --git a/include/sway/input/seat.h b/include/sway/input/seat.h index 8a7e5450..b07d200d 100644 --- a/include/sway/input/seat.h +++ b/include/sway/input/seat.h | |||
@@ -102,6 +102,12 @@ void seat_configure_xcursor(struct sway_seat *seat); | |||
102 | 102 | ||
103 | void seat_set_focus(struct sway_seat *seat, struct sway_node *node); | 103 | void seat_set_focus(struct sway_seat *seat, struct sway_node *node); |
104 | 104 | ||
105 | void seat_set_focus_container(struct sway_seat *seat, | ||
106 | struct sway_container *con); | ||
107 | |||
108 | void seat_set_focus_workspace(struct sway_seat *seat, | ||
109 | struct sway_workspace *ws); | ||
110 | |||
105 | void seat_set_focus_warp(struct sway_seat *seat, | 111 | void seat_set_focus_warp(struct sway_seat *seat, |
106 | struct sway_node *node, bool warp, bool notify); | 112 | struct sway_node *node, bool warp, bool notify); |
107 | 113 | ||
diff --git a/sway/commands/floating.c b/sway/commands/floating.c index d8729094..97662a18 100644 --- a/sway/commands/floating.c +++ b/sway/commands/floating.c | |||
@@ -25,7 +25,7 @@ struct cmd_results *cmd_floating(int argc, char **argv) { | |||
25 | // Wrap the workspace's children in a container so we can float it | 25 | // Wrap the workspace's children in a container so we can float it |
26 | container = workspace_wrap_children(workspace); | 26 | container = workspace_wrap_children(workspace); |
27 | workspace->layout = L_HORIZ; | 27 | workspace->layout = L_HORIZ; |
28 | seat_set_focus(config->handler_context.seat, &container->node); | 28 | seat_set_focus_container(config->handler_context.seat, container); |
29 | } | 29 | } |
30 | 30 | ||
31 | // If the container is in a floating split container, | 31 | // If the container is in a floating split container, |
diff --git a/sway/commands/focus.c b/sway/commands/focus.c index 58721b7e..668a0c7b 100644 --- a/sway/commands/focus.c +++ b/sway/commands/focus.c | |||
@@ -179,7 +179,7 @@ static struct cmd_results *focus_mode(struct sway_workspace *ws, | |||
179 | new_focus = seat_get_focus_inactive_tiling(seat, ws); | 179 | new_focus = seat_get_focus_inactive_tiling(seat, ws); |
180 | } | 180 | } |
181 | if (new_focus) { | 181 | if (new_focus) { |
182 | seat_set_focus(seat, &new_focus->node); | 182 | seat_set_focus_container(seat, new_focus); |
183 | } else { | 183 | } else { |
184 | return cmd_results_new(CMD_FAILURE, "focus", | 184 | return cmd_results_new(CMD_FAILURE, "focus", |
185 | "Failed to find a %s container in workspace", | 185 | "Failed to find a %s container in workspace", |
@@ -230,8 +230,8 @@ struct cmd_results *cmd_focus(int argc, char **argv) { | |||
230 | "Command 'focus' cannot be used above the workspace level"); | 230 | "Command 'focus' cannot be used above the workspace level"); |
231 | } | 231 | } |
232 | 232 | ||
233 | if (argc == 0) { | 233 | if (argc == 0 && container) { |
234 | seat_set_focus(seat, node); | 234 | seat_set_focus_container(seat, container); |
235 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); | 235 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); |
236 | } | 236 | } |
237 | 237 | ||
diff --git a/sway/commands/fullscreen.c b/sway/commands/fullscreen.c index 3bbe00c5..22d747b9 100644 --- a/sway/commands/fullscreen.c +++ b/sway/commands/fullscreen.c | |||
@@ -23,7 +23,7 @@ struct cmd_results *cmd_fullscreen(int argc, char **argv) { | |||
23 | // Wrap the workspace's children in a container so we can fullscreen it | 23 | // Wrap the workspace's children in a container so we can fullscreen it |
24 | container = workspace_wrap_children(workspace); | 24 | container = workspace_wrap_children(workspace); |
25 | workspace->layout = L_HORIZ; | 25 | workspace->layout = L_HORIZ; |
26 | seat_set_focus(config->handler_context.seat, &container->node); | 26 | seat_set_focus_container(config->handler_context.seat, container); |
27 | } | 27 | } |
28 | bool enable = !container->is_fullscreen; | 28 | bool enable = !container->is_fullscreen; |
29 | 29 | ||
diff --git a/sway/commands/move.c b/sway/commands/move.c index 59f1cf78..2e9c00f8 100644 --- a/sway/commands/move.c +++ b/sway/commands/move.c | |||
@@ -624,7 +624,7 @@ static void workspace_move_to_output(struct sway_workspace *workspace, | |||
624 | char *ws_name = workspace_next_name(old_output->wlr_output->name); | 624 | char *ws_name = workspace_next_name(old_output->wlr_output->name); |
625 | struct sway_workspace *ws = workspace_create(old_output, ws_name); | 625 | struct sway_workspace *ws = workspace_create(old_output, ws_name); |
626 | free(ws_name); | 626 | free(ws_name); |
627 | seat_set_focus(seat, &ws->node); | 627 | seat_set_focus_workspace(seat, ws); |
628 | } | 628 | } |
629 | 629 | ||
630 | workspace_consider_destroy(new_output_old_ws); | 630 | workspace_consider_destroy(new_output_old_ws); |
@@ -734,8 +734,9 @@ static struct cmd_results *cmd_move_in_direction( | |||
734 | ipc_event_window(container, "move"); | 734 | ipc_event_window(container, "move"); |
735 | } | 735 | } |
736 | 736 | ||
737 | seat_set_focus(config->handler_context.seat, &new_ws->node); | 737 | // Hack to re-focus container |
738 | seat_set_focus(config->handler_context.seat, &container->node); | 738 | seat_set_focus_workspace(config->handler_context.seat, new_ws); |
739 | seat_set_focus_container(config->handler_context.seat, container); | ||
739 | 740 | ||
740 | if (old_ws != new_ws) { | 741 | if (old_ws != new_ws) { |
741 | ipc_event_workspace(old_ws, new_ws, "focus"); | 742 | ipc_event_workspace(old_ws, new_ws, "focus"); |
diff --git a/sway/commands/swap.c b/sway/commands/swap.c index a0ffbda8..e7f9cbea 100644 --- a/sway/commands/swap.c +++ b/sway/commands/swap.c | |||
@@ -52,20 +52,20 @@ static void swap_focus(struct sway_container *con1, | |||
52 | if (workspace_is_visible(ws2)) { | 52 | if (workspace_is_visible(ws2)) { |
53 | seat_set_focus_warp(seat, &con2->node, false, true); | 53 | seat_set_focus_warp(seat, &con2->node, false, true); |
54 | } | 54 | } |
55 | seat_set_focus(seat, ws1 != ws2 ? &con2->node : &con1->node); | 55 | seat_set_focus_container(seat, ws1 != ws2 ? con2 : con1); |
56 | } else if (focus == con2 && (layout1 == L_TABBED | 56 | } else if (focus == con2 && (layout1 == L_TABBED |
57 | || layout1 == L_STACKED)) { | 57 | || layout1 == L_STACKED)) { |
58 | if (workspace_is_visible(ws1)) { | 58 | if (workspace_is_visible(ws1)) { |
59 | seat_set_focus_warp(seat, &con1->node, false, true); | 59 | seat_set_focus_warp(seat, &con1->node, false, true); |
60 | } | 60 | } |
61 | seat_set_focus(seat, ws1 != ws2 ? &con1->node : &con2->node); | 61 | seat_set_focus_container(seat, ws1 != ws2 ? con1 : con2); |
62 | } else if (ws1 != ws2) { | 62 | } else if (ws1 != ws2) { |
63 | seat_set_focus(seat, focus == con1 ? &con2->node : &con1->node); | 63 | seat_set_focus_container(seat, focus == con1 ? con2 : con1); |
64 | } else { | 64 | } else { |
65 | seat_set_focus(seat, &focus->node); | 65 | seat_set_focus_container(seat, focus); |
66 | } | 66 | } |
67 | } else { | 67 | } else { |
68 | seat_set_focus(seat, &focus->node); | 68 | seat_set_focus_container(seat, focus); |
69 | } | 69 | } |
70 | } | 70 | } |
71 | 71 | ||
diff --git a/sway/input/cursor.c b/sway/input/cursor.c index 19dc3165..be3fc9c7 100644 --- a/sway/input/cursor.c +++ b/sway/input/cursor.c | |||
@@ -675,7 +675,7 @@ void dispatch_cursor_button(struct sway_cursor *cursor, | |||
675 | // Handle tiling resize via border | 675 | // Handle tiling resize via border |
676 | if (resize_edge && button == BTN_LEFT && state == WLR_BUTTON_PRESSED && | 676 | if (resize_edge && button == BTN_LEFT && state == WLR_BUTTON_PRESSED && |
677 | !is_floating) { | 677 | !is_floating) { |
678 | seat_set_focus(seat, &cont->node); | 678 | seat_set_focus_container(seat, cont); |
679 | seat_begin_resize_tiling(seat, cont, button, edge); | 679 | seat_begin_resize_tiling(seat, cont, button, edge); |
680 | return; | 680 | return; |
681 | } | 681 | } |
@@ -704,7 +704,7 @@ void dispatch_cursor_button(struct sway_cursor *cursor, | |||
704 | image = "sw-resize"; | 704 | image = "sw-resize"; |
705 | } | 705 | } |
706 | cursor_set_image(seat->cursor, image, NULL); | 706 | cursor_set_image(seat->cursor, image, NULL); |
707 | seat_set_focus(seat, &cont->node); | 707 | seat_set_focus_container(seat, cont); |
708 | seat_begin_resize_tiling(seat, cont, button, edge); | 708 | seat_begin_resize_tiling(seat, cont, button, edge); |
709 | return; | 709 | return; |
710 | } | 710 | } |
@@ -753,7 +753,7 @@ void dispatch_cursor_button(struct sway_cursor *cursor, | |||
753 | 753 | ||
754 | // Handle mousedown on a container surface | 754 | // Handle mousedown on a container surface |
755 | if (surface && cont && state == WLR_BUTTON_PRESSED) { | 755 | if (surface && cont && state == WLR_BUTTON_PRESSED) { |
756 | seat_set_focus(seat, &cont->node); | 756 | seat_set_focus_container(seat, cont); |
757 | seat_pointer_notify_button(seat, time_msec, button, state); | 757 | seat_pointer_notify_button(seat, time_msec, button, state); |
758 | seat_begin_down(seat, cont, button, sx, sy); | 758 | seat_begin_down(seat, cont, button, sx, sy); |
759 | return; | 759 | return; |
@@ -761,7 +761,7 @@ void dispatch_cursor_button(struct sway_cursor *cursor, | |||
761 | 761 | ||
762 | // Handle clicking a container surface | 762 | // Handle clicking a container surface |
763 | if (cont) { | 763 | if (cont) { |
764 | seat_set_focus(seat, &cont->node); | 764 | seat_set_focus_container(seat, cont); |
765 | seat_pointer_notify_button(seat, time_msec, button, state); | 765 | seat_pointer_notify_button(seat, time_msec, button, state); |
766 | return; | 766 | return; |
767 | } | 767 | } |
diff --git a/sway/input/seat.c b/sway/input/seat.c index b1808793..7c81e9d1 100644 --- a/sway/input/seat.c +++ b/sway/input/seat.c | |||
@@ -734,6 +734,16 @@ void seat_set_focus(struct sway_seat *seat, struct sway_node *node) { | |||
734 | seat_set_focus_warp(seat, node, true, true); | 734 | seat_set_focus_warp(seat, node, true, true); |
735 | } | 735 | } |
736 | 736 | ||
737 | void seat_set_focus_container(struct sway_seat *seat, | ||
738 | struct sway_container *con) { | ||
739 | seat_set_focus_warp(seat, con ? &con->node : NULL, true, true); | ||
740 | } | ||
741 | |||
742 | void seat_set_focus_workspace(struct sway_seat *seat, | ||
743 | struct sway_workspace *ws) { | ||
744 | seat_set_focus_warp(seat, ws ? &ws->node : NULL, true, true); | ||
745 | } | ||
746 | |||
737 | void seat_set_focus_surface(struct sway_seat *seat, | 747 | void seat_set_focus_surface(struct sway_seat *seat, |
738 | struct wlr_surface *surface, bool unfocus) { | 748 | struct wlr_surface *surface, bool unfocus) { |
739 | if (seat->focused_layer != NULL) { | 749 | if (seat->focused_layer != NULL) { |
diff --git a/sway/tree/container.c b/sway/tree/container.c index c91b0361..50f284f4 100644 --- a/sway/tree/container.c +++ b/sway/tree/container.c | |||
@@ -871,7 +871,7 @@ void container_set_fullscreen(struct sway_container *container, bool enable) { | |||
871 | focus_ws = seat_get_focused_workspace(seat); | 871 | focus_ws = seat_get_focused_workspace(seat); |
872 | if (focus_ws) { | 872 | if (focus_ws) { |
873 | if (focus_ws == workspace) { | 873 | if (focus_ws == workspace) { |
874 | seat_set_focus(seat, &container->node); | 874 | seat_set_focus_container(seat, container); |
875 | } | 875 | } |
876 | } | 876 | } |
877 | } | 877 | } |
@@ -1159,8 +1159,8 @@ struct sway_container *container_split(struct sway_container *child, | |||
1159 | container_add_child(cont, child); | 1159 | container_add_child(cont, child); |
1160 | 1160 | ||
1161 | if (set_focus) { | 1161 | if (set_focus) { |
1162 | seat_set_focus(seat, &cont->node); | 1162 | seat_set_focus_container(seat, cont); |
1163 | seat_set_focus(seat, &child->node); | 1163 | seat_set_focus_container(seat, child); |
1164 | } | 1164 | } |
1165 | 1165 | ||
1166 | return cont; | 1166 | return cont; |
diff --git a/sway/tree/output.c b/sway/tree/output.c index 201e767f..1976ad51 100644 --- a/sway/tree/output.c +++ b/sway/tree/output.c | |||
@@ -85,7 +85,7 @@ void output_enable(struct sway_output *output, struct output_config *oc) { | |||
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, &input_manager->seats, link) { |
87 | if (!seat->has_focus) { | 87 | if (!seat->has_focus) { |
88 | seat_set_focus(seat, &ws->node); | 88 | seat_set_focus_workspace(seat, ws); |
89 | } | 89 | } |
90 | } | 90 | } |
91 | free(ws_name); | 91 | free(ws_name); |
diff --git a/sway/tree/view.c b/sway/tree/view.c index f9dcb11a..312c62d1 100644 --- a/sway/tree/view.c +++ b/sway/tree/view.c | |||
@@ -294,7 +294,7 @@ void view_request_activate(struct sway_view *view) { | |||
294 | switch (config->focus_on_window_activation) { | 294 | switch (config->focus_on_window_activation) { |
295 | case FOWA_SMART: | 295 | case FOWA_SMART: |
296 | if (workspace_is_visible(ws)) { | 296 | if (workspace_is_visible(ws)) { |
297 | seat_set_focus(seat, &view->container->node); | 297 | seat_set_focus_container(seat, view->container); |
298 | } else { | 298 | } else { |
299 | view_set_urgent(view, true); | 299 | view_set_urgent(view, true); |
300 | } | 300 | } |
@@ -303,7 +303,7 @@ void view_request_activate(struct sway_view *view) { | |||
303 | view_set_urgent(view, true); | 303 | view_set_urgent(view, true); |
304 | break; | 304 | break; |
305 | case FOWA_FOCUS: | 305 | case FOWA_FOCUS: |
306 | seat_set_focus(seat, &view->container->node); | 306 | seat_set_focus_container(seat, view->container); |
307 | break; | 307 | break; |
308 | case FOWA_NONE: | 308 | case FOWA_NONE: |
309 | break; | 309 | break; |
@@ -404,7 +404,7 @@ void view_execute_criteria(struct sway_view *view) { | |||
404 | } | 404 | } |
405 | wlr_log(WLR_DEBUG, "for_window '%s' matches view %p, cmd: '%s'", | 405 | wlr_log(WLR_DEBUG, "for_window '%s' matches view %p, cmd: '%s'", |
406 | criteria->raw, view, criteria->cmdlist); | 406 | criteria->raw, view, criteria->cmdlist); |
407 | seat_set_focus(seat, &view->container->node); | 407 | seat_set_focus_container(seat, view->container); |
408 | list_add(view->executed_criteria, criteria); | 408 | list_add(view->executed_criteria, criteria); |
409 | struct cmd_results *res = execute_command(criteria->cmdlist, NULL); | 409 | struct cmd_results *res = execute_command(criteria->cmdlist, NULL); |
410 | if (res->status != CMD_SUCCESS) { | 410 | if (res->status != CMD_SUCCESS) { |
diff --git a/sway/tree/workspace.c b/sway/tree/workspace.c index bb1ded22..378bfc5d 100644 --- a/sway/tree/workspace.c +++ b/sway/tree/workspace.c | |||
@@ -399,7 +399,7 @@ bool workspace_switch(struct sway_workspace *workspace, | |||
399 | workspace_add_floating(workspace, floater); | 399 | workspace_add_floating(workspace, floater); |
400 | if (&floater->node == focus) { | 400 | if (&floater->node == focus) { |
401 | seat_set_focus(seat, NULL); | 401 | seat_set_focus(seat, NULL); |
402 | seat_set_focus(seat, &floater->node); | 402 | seat_set_focus_container(seat, floater); |
403 | } | 403 | } |
404 | --i; | 404 | --i; |
405 | } | 405 | } |