aboutsummaryrefslogtreecommitdiffstats
path: root/sway/input/seat.c
diff options
context:
space:
mode:
authorLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2018-10-15 21:06:24 +1000
committerLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2018-10-15 21:06:24 +1000
commit26278b694c5eeff38512cfe8156567718db73c65 (patch)
tree7c7a5226543817d6c723a9b698458934ee905735 /sway/input/seat.c
parentMerge pull request #2831 from swaywm/move-output-docs (diff)
downloadsway-26278b694c5eeff38512cfe8156567718db73c65.tar.gz
sway-26278b694c5eeff38512cfe8156567718db73c65.tar.zst
sway-26278b694c5eeff38512cfe8156567718db73c65.zip
Introduce seat_set_raw_focus and remove notify argument from seat_set_focus_warp
This introduces seat_set_raw_focus: a function that manipulates the focus stack without doing any other behaviour whatsoever. There are a few places where this is useful, such as where we set focus_inactive followed by another call to set the real focus again. With this change, the notify argument to seat_set_focus_warp is also removed as these cases now use the raw function instead. A bonus of this is we are no longer emitting window::focus IPC events when setting focus_inactive, nor are we sending focus/unfocus events to the surface. This also fixes the following: * When running `move workspace to output <name>` and moving the last workspace from the source output, the workspace::focus IPC event is no longer emitted for the newly created workspace. * When splitting the currently focused container, unfocus/focus events will not be sent to the surface when giving focus_inactive to the newly created parent, and window::focus events will not be emitted.
Diffstat (limited to 'sway/input/seat.c')
-rw-r--r--sway/input/seat.c40
1 files changed, 18 insertions, 22 deletions
diff --git a/sway/input/seat.c b/sway/input/seat.c
index 03ed638e..6dbd1900 100644
--- a/sway/input/seat.c
+++ b/sway/input/seat.c
@@ -184,8 +184,8 @@ static void handle_seat_node_destroy(struct wl_listener *listener, void *data) {
184 seat_set_focus(seat, next_focus); 184 seat_set_focus(seat, next_focus);
185 } else { 185 } else {
186 // Setting focus_inactive 186 // Setting focus_inactive
187 seat_set_focus_warp(seat, next_focus, false, false); 187 seat_set_raw_focus(seat, next_focus);
188 seat_set_focus_warp(seat, focus, false, false); 188 seat_set_raw_focus(seat, focus);
189 } 189 }
190} 190}
191 191
@@ -623,8 +623,16 @@ static void container_raise_floating(struct sway_container *con) {
623 } 623 }
624} 624}
625 625
626void seat_set_raw_focus(struct sway_seat *seat, struct sway_node *node) {
627 struct sway_seat_node *seat_node = seat_node_from_node(seat, node);
628 wl_list_remove(&seat_node->link);
629 wl_list_insert(&seat->focus_stack, &seat_node->link);
630 node_set_dirty(node);
631 node_set_dirty(node_get_parent(node));
632}
633
626void seat_set_focus_warp(struct sway_seat *seat, struct sway_node *node, 634void seat_set_focus_warp(struct sway_seat *seat, struct sway_node *node,
627 bool warp, bool notify) { 635 bool warp) {
628 if (seat->focused_layer) { 636 if (seat->focused_layer) {
629 return; 637 return;
630 } 638 }
@@ -688,32 +696,20 @@ void seat_set_focus_warp(struct sway_seat *seat, struct sway_node *node,
688 if (container) { 696 if (container) {
689 struct sway_container *parent = container->parent; 697 struct sway_container *parent = container->parent;
690 while (parent) { 698 while (parent) {
691 struct sway_seat_node *seat_node = 699 seat_set_raw_focus(seat, &parent->node);
692 seat_node_from_node(seat, &parent->node);
693 wl_list_remove(&seat_node->link);
694 wl_list_insert(&seat->focus_stack, &seat_node->link);
695 node_set_dirty(&parent->node);
696 parent = parent->parent; 700 parent = parent->parent;
697 } 701 }
698 } 702 }
699 if (new_workspace) { 703 if (new_workspace) {
700 struct sway_seat_node *seat_node = 704 seat_set_raw_focus(seat, &new_workspace->node);
701 seat_node_from_node(seat, &new_workspace->node);
702 wl_list_remove(&seat_node->link);
703 wl_list_insert(&seat->focus_stack, &seat_node->link);
704 node_set_dirty(&new_workspace->node);
705 } 705 }
706 if (container) { 706 if (container) {
707 struct sway_seat_node *seat_node = 707 seat_set_raw_focus(seat, &container->node);
708 seat_node_from_node(seat, &container->node);
709 wl_list_remove(&seat_node->link);
710 wl_list_insert(&seat->focus_stack, &seat_node->link);
711 node_set_dirty(&container->node);
712 seat_send_focus(&container->node, seat); 708 seat_send_focus(&container->node, seat);
713 } 709 }
714 710
715 // emit ipc events 711 // emit ipc events
716 if (notify && new_workspace && last_workspace != new_workspace) { 712 if (new_workspace && last_workspace != new_workspace) {
717 ipc_event_workspace(last_workspace, new_workspace, "focus"); 713 ipc_event_workspace(last_workspace, new_workspace, "focus");
718 } 714 }
719 if (container && container->view) { 715 if (container && container->view) {
@@ -807,17 +803,17 @@ void seat_set_focus_warp(struct sway_seat *seat, struct sway_node *node,
807} 803}
808 804
809void seat_set_focus(struct sway_seat *seat, struct sway_node *node) { 805void seat_set_focus(struct sway_seat *seat, struct sway_node *node) {
810 seat_set_focus_warp(seat, node, true, true); 806 seat_set_focus_warp(seat, node, true);
811} 807}
812 808
813void seat_set_focus_container(struct sway_seat *seat, 809void seat_set_focus_container(struct sway_seat *seat,
814 struct sway_container *con) { 810 struct sway_container *con) {
815 seat_set_focus_warp(seat, con ? &con->node : NULL, true, true); 811 seat_set_focus_warp(seat, con ? &con->node : NULL, true);
816} 812}
817 813
818void seat_set_focus_workspace(struct sway_seat *seat, 814void seat_set_focus_workspace(struct sway_seat *seat,
819 struct sway_workspace *ws) { 815 struct sway_workspace *ws) {
820 seat_set_focus_warp(seat, ws ? &ws->node : NULL, true, true); 816 seat_set_focus_warp(seat, ws ? &ws->node : NULL, true);
821} 817}
822 818
823void seat_set_focus_surface(struct sway_seat *seat, 819void seat_set_focus_surface(struct sway_seat *seat,