diff options
author | Ian Fan <ianfan0@gmail.com> | 2018-07-18 21:55:14 +0100 |
---|---|---|
committer | Ian Fan <ianfan0@gmail.com> | 2018-08-01 16:57:15 +0100 |
commit | 03eaf444a4a432e5712d40f93d849b51d2028b63 (patch) | |
tree | ab593f6a5157668ed8515c0af211b7b8c1d37b1c | |
parent | ipc: fix workspace::focus event behaviour (diff) | |
download | sway-03eaf444a4a432e5712d40f93d849b51d2028b63.tar.gz sway-03eaf444a4a432e5712d40f93d849b51d2028b63.tar.zst sway-03eaf444a4a432e5712d40f93d849b51d2028b63.zip |
ipc: prevent emitting a workspace::focus event when moving a container to a different workspace or output
When a container is moved from, say, workspace 1 to workspace 2, workspace 2 is focused in order to arrange the windows before focus is moved back to workspace 1, which caused a workspace:focus event from workspace 2 to workspace 1 to be emitted. This commit inhibits that event.
-rw-r--r-- | include/sway/input/seat.h | 2 | ||||
-rw-r--r-- | sway/commands/move.c | 4 | ||||
-rw-r--r-- | sway/input/cursor.c | 6 | ||||
-rw-r--r-- | sway/input/seat.c | 6 | ||||
-rw-r--r-- | sway/tree/layout.c | 4 |
5 files changed, 11 insertions, 11 deletions
diff --git a/include/sway/input/seat.h b/include/sway/input/seat.h index 07febe2c..92387601 100644 --- a/include/sway/input/seat.h +++ b/include/sway/input/seat.h | |||
@@ -99,7 +99,7 @@ void seat_configure_xcursor(struct sway_seat *seat); | |||
99 | void seat_set_focus(struct sway_seat *seat, struct sway_container *container); | 99 | void seat_set_focus(struct sway_seat *seat, struct sway_container *container); |
100 | 100 | ||
101 | void seat_set_focus_warp(struct sway_seat *seat, | 101 | void seat_set_focus_warp(struct sway_seat *seat, |
102 | struct sway_container *container, bool warp); | 102 | struct sway_container *container, bool warp, bool notify); |
103 | 103 | ||
104 | void seat_set_focus_surface(struct sway_seat *seat, | 104 | void seat_set_focus_surface(struct sway_seat *seat, |
105 | struct wlr_surface *surface, bool unfocus); | 105 | struct wlr_surface *surface, bool unfocus); |
diff --git a/sway/commands/move.c b/sway/commands/move.c index 1aae3838..46ebcd83 100644 --- a/sway/commands/move.c +++ b/sway/commands/move.c | |||
@@ -98,7 +98,7 @@ static struct cmd_results *cmd_move_container(struct sway_container *current, | |||
98 | container_move_to(current, destination); | 98 | container_move_to(current, destination); |
99 | struct sway_container *focus = seat_get_focus_inactive( | 99 | struct sway_container *focus = seat_get_focus_inactive( |
100 | config->handler_context.seat, old_parent); | 100 | config->handler_context.seat, old_parent); |
101 | seat_set_focus(config->handler_context.seat, focus); | 101 | seat_set_focus_warp(config->handler_context.seat, focus, true, false); |
102 | container_reap_empty(old_parent); | 102 | container_reap_empty(old_parent); |
103 | container_reap_empty(destination->parent); | 103 | container_reap_empty(destination->parent); |
104 | 104 | ||
@@ -135,7 +135,7 @@ static struct cmd_results *cmd_move_container(struct sway_container *current, | |||
135 | struct sway_container *old_parent = current->parent; | 135 | struct sway_container *old_parent = current->parent; |
136 | struct sway_container *old_ws = container_parent(current, C_WORKSPACE); | 136 | struct sway_container *old_ws = container_parent(current, C_WORKSPACE); |
137 | container_move_to(current, focus); | 137 | container_move_to(current, focus); |
138 | seat_set_focus(config->handler_context.seat, old_parent); | 138 | seat_set_focus_warp(config->handler_context.seat, old_parent, true, false); |
139 | container_reap_empty(old_parent); | 139 | container_reap_empty(old_parent); |
140 | container_reap_empty(focus->parent); | 140 | container_reap_empty(focus->parent); |
141 | 141 | ||
diff --git a/sway/input/cursor.c b/sway/input/cursor.c index 96ac7b33..d6fdc1da 100644 --- a/sway/input/cursor.c +++ b/sway/input/cursor.c | |||
@@ -349,7 +349,7 @@ void cursor_send_pointer_motion(struct sway_cursor *cursor, uint32_t time_msec, | |||
349 | output = container_parent(c, C_OUTPUT); | 349 | output = container_parent(c, C_OUTPUT); |
350 | } | 350 | } |
351 | if (output != focus) { | 351 | if (output != focus) { |
352 | seat_set_focus_warp(seat, c, false); | 352 | seat_set_focus_warp(seat, c, false, true); |
353 | } | 353 | } |
354 | } else if (c->type == C_VIEW) { | 354 | } else if (c->type == C_VIEW) { |
355 | // Focus c if the following are true: | 355 | // Focus c if the following are true: |
@@ -359,13 +359,13 @@ void cursor_send_pointer_motion(struct sway_cursor *cursor, uint32_t time_msec, | |||
359 | if (!wlr_seat_keyboard_has_grab(cursor->seat->wlr_seat) && | 359 | if (!wlr_seat_keyboard_has_grab(cursor->seat->wlr_seat) && |
360 | c != prev_c && | 360 | c != prev_c && |
361 | view_is_visible(c->sway_view)) { | 361 | view_is_visible(c->sway_view)) { |
362 | seat_set_focus_warp(seat, c, false); | 362 | seat_set_focus_warp(seat, c, false, true); |
363 | } else { | 363 | } else { |
364 | struct sway_container *next_focus = | 364 | struct sway_container *next_focus = |
365 | seat_get_focus_inactive(seat, &root_container); | 365 | seat_get_focus_inactive(seat, &root_container); |
366 | if (next_focus && next_focus->type == C_VIEW && | 366 | if (next_focus && next_focus->type == C_VIEW && |
367 | view_is_visible(next_focus->sway_view)) { | 367 | view_is_visible(next_focus->sway_view)) { |
368 | seat_set_focus_warp(seat, next_focus, false); | 368 | seat_set_focus_warp(seat, next_focus, false, true); |
369 | } | 369 | } |
370 | } | 370 | } |
371 | } | 371 | } |
diff --git a/sway/input/seat.c b/sway/input/seat.c index 76050aa9..fe3cbc53 100644 --- a/sway/input/seat.c +++ b/sway/input/seat.c | |||
@@ -617,7 +617,7 @@ static int handle_urgent_timeout(void *data) { | |||
617 | } | 617 | } |
618 | 618 | ||
619 | void seat_set_focus_warp(struct sway_seat *seat, | 619 | void seat_set_focus_warp(struct sway_seat *seat, |
620 | struct sway_container *container, bool warp) { | 620 | struct sway_container *container, bool warp, bool notify) { |
621 | if (seat->focused_layer) { | 621 | if (seat->focused_layer) { |
622 | return; | 622 | return; |
623 | } | 623 | } |
@@ -739,7 +739,7 @@ void seat_set_focus_warp(struct sway_seat *seat, | |||
739 | 739 | ||
740 | if (last_focus) { | 740 | if (last_focus) { |
741 | if (last_workspace) { | 741 | if (last_workspace) { |
742 | if (last_workspace != new_workspace) { | 742 | if (notify && last_workspace != new_workspace) { |
743 | ipc_event_workspace(last_workspace, new_workspace, "focus"); | 743 | ipc_event_workspace(last_workspace, new_workspace, "focus"); |
744 | } | 744 | } |
745 | if (!workspace_is_visible(last_workspace) | 745 | if (!workspace_is_visible(last_workspace) |
@@ -779,7 +779,7 @@ void seat_set_focus_warp(struct sway_seat *seat, | |||
779 | 779 | ||
780 | void seat_set_focus(struct sway_seat *seat, | 780 | void seat_set_focus(struct sway_seat *seat, |
781 | struct sway_container *container) { | 781 | struct sway_container *container) { |
782 | seat_set_focus_warp(seat, container, true); | 782 | seat_set_focus_warp(seat, container, true, true); |
783 | } | 783 | } |
784 | 784 | ||
785 | void seat_set_focus_surface(struct sway_seat *seat, | 785 | void seat_set_focus_surface(struct sway_seat *seat, |
diff --git a/sway/tree/layout.c b/sway/tree/layout.c index 9fbbccaf..1f82e534 100644 --- a/sway/tree/layout.c +++ b/sway/tree/layout.c | |||
@@ -1001,13 +1001,13 @@ static void swap_focus(struct sway_container *con1, | |||
1001 | if (focus == con1 && (con2->parent->layout == L_TABBED | 1001 | if (focus == con1 && (con2->parent->layout == L_TABBED |
1002 | || con2->parent->layout == L_STACKED)) { | 1002 | || con2->parent->layout == L_STACKED)) { |
1003 | if (workspace_is_visible(ws2)) { | 1003 | if (workspace_is_visible(ws2)) { |
1004 | seat_set_focus_warp(seat, con2, false); | 1004 | seat_set_focus_warp(seat, con2, false, true); |
1005 | } | 1005 | } |
1006 | seat_set_focus(seat, ws1 != ws2 ? con2 : con1); | 1006 | seat_set_focus(seat, ws1 != ws2 ? con2 : con1); |
1007 | } else if (focus == con2 && (con1->parent->layout == L_TABBED | 1007 | } else if (focus == con2 && (con1->parent->layout == L_TABBED |
1008 | || con1->parent->layout == L_STACKED)) { | 1008 | || con1->parent->layout == L_STACKED)) { |
1009 | if (workspace_is_visible(ws1)) { | 1009 | if (workspace_is_visible(ws1)) { |
1010 | seat_set_focus_warp(seat, con1, false); | 1010 | seat_set_focus_warp(seat, con1, false, true); |
1011 | } | 1011 | } |
1012 | seat_set_focus(seat, ws1 != ws2 ? con1 : con2); | 1012 | seat_set_focus(seat, ws1 != ws2 ? con1 : con2); |
1013 | } else if (ws1 != ws2) { | 1013 | } else if (ws1 != ws2) { |