mirror of
https://github.com/swaywm/sway.git
synced 2024-11-11 21:14:10 +01:00
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.
This commit is contained in:
parent
b2ac234569
commit
03eaf444a4
@ -99,7 +99,7 @@ void seat_configure_xcursor(struct sway_seat *seat);
|
||||
void seat_set_focus(struct sway_seat *seat, struct sway_container *container);
|
||||
|
||||
void seat_set_focus_warp(struct sway_seat *seat,
|
||||
struct sway_container *container, bool warp);
|
||||
struct sway_container *container, bool warp, bool notify);
|
||||
|
||||
void seat_set_focus_surface(struct sway_seat *seat,
|
||||
struct wlr_surface *surface, bool unfocus);
|
||||
|
@ -98,7 +98,7 @@ static struct cmd_results *cmd_move_container(struct sway_container *current,
|
||||
container_move_to(current, destination);
|
||||
struct sway_container *focus = seat_get_focus_inactive(
|
||||
config->handler_context.seat, old_parent);
|
||||
seat_set_focus(config->handler_context.seat, focus);
|
||||
seat_set_focus_warp(config->handler_context.seat, focus, true, false);
|
||||
container_reap_empty(old_parent);
|
||||
container_reap_empty(destination->parent);
|
||||
|
||||
@ -135,7 +135,7 @@ static struct cmd_results *cmd_move_container(struct sway_container *current,
|
||||
struct sway_container *old_parent = current->parent;
|
||||
struct sway_container *old_ws = container_parent(current, C_WORKSPACE);
|
||||
container_move_to(current, focus);
|
||||
seat_set_focus(config->handler_context.seat, old_parent);
|
||||
seat_set_focus_warp(config->handler_context.seat, old_parent, true, false);
|
||||
container_reap_empty(old_parent);
|
||||
container_reap_empty(focus->parent);
|
||||
|
||||
|
@ -349,7 +349,7 @@ void cursor_send_pointer_motion(struct sway_cursor *cursor, uint32_t time_msec,
|
||||
output = container_parent(c, C_OUTPUT);
|
||||
}
|
||||
if (output != focus) {
|
||||
seat_set_focus_warp(seat, c, false);
|
||||
seat_set_focus_warp(seat, c, false, true);
|
||||
}
|
||||
} else if (c->type == C_VIEW) {
|
||||
// Focus c if the following are true:
|
||||
@ -359,13 +359,13 @@ void cursor_send_pointer_motion(struct sway_cursor *cursor, uint32_t time_msec,
|
||||
if (!wlr_seat_keyboard_has_grab(cursor->seat->wlr_seat) &&
|
||||
c != prev_c &&
|
||||
view_is_visible(c->sway_view)) {
|
||||
seat_set_focus_warp(seat, c, false);
|
||||
seat_set_focus_warp(seat, c, false, true);
|
||||
} else {
|
||||
struct sway_container *next_focus =
|
||||
seat_get_focus_inactive(seat, &root_container);
|
||||
if (next_focus && next_focus->type == C_VIEW &&
|
||||
view_is_visible(next_focus->sway_view)) {
|
||||
seat_set_focus_warp(seat, next_focus, false);
|
||||
seat_set_focus_warp(seat, next_focus, false, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -617,7 +617,7 @@ static int handle_urgent_timeout(void *data) {
|
||||
}
|
||||
|
||||
void seat_set_focus_warp(struct sway_seat *seat,
|
||||
struct sway_container *container, bool warp) {
|
||||
struct sway_container *container, bool warp, bool notify) {
|
||||
if (seat->focused_layer) {
|
||||
return;
|
||||
}
|
||||
@ -739,7 +739,7 @@ void seat_set_focus_warp(struct sway_seat *seat,
|
||||
|
||||
if (last_focus) {
|
||||
if (last_workspace) {
|
||||
if (last_workspace != new_workspace) {
|
||||
if (notify && last_workspace != new_workspace) {
|
||||
ipc_event_workspace(last_workspace, new_workspace, "focus");
|
||||
}
|
||||
if (!workspace_is_visible(last_workspace)
|
||||
@ -779,7 +779,7 @@ void seat_set_focus_warp(struct sway_seat *seat,
|
||||
|
||||
void seat_set_focus(struct sway_seat *seat,
|
||||
struct sway_container *container) {
|
||||
seat_set_focus_warp(seat, container, true);
|
||||
seat_set_focus_warp(seat, container, true, true);
|
||||
}
|
||||
|
||||
void seat_set_focus_surface(struct sway_seat *seat,
|
||||
|
@ -1001,13 +1001,13 @@ static void swap_focus(struct sway_container *con1,
|
||||
if (focus == con1 && (con2->parent->layout == L_TABBED
|
||||
|| con2->parent->layout == L_STACKED)) {
|
||||
if (workspace_is_visible(ws2)) {
|
||||
seat_set_focus_warp(seat, con2, false);
|
||||
seat_set_focus_warp(seat, con2, false, true);
|
||||
}
|
||||
seat_set_focus(seat, ws1 != ws2 ? con2 : con1);
|
||||
} else if (focus == con2 && (con1->parent->layout == L_TABBED
|
||||
|| con1->parent->layout == L_STACKED)) {
|
||||
if (workspace_is_visible(ws1)) {
|
||||
seat_set_focus_warp(seat, con1, false);
|
||||
seat_set_focus_warp(seat, con1, false, true);
|
||||
}
|
||||
seat_set_focus(seat, ws1 != ws2 ? con1 : con2);
|
||||
} else if (ws1 != ws2) {
|
||||
|
Loading…
Reference in New Issue
Block a user