diff --git a/sway/input/seatop_default.c b/sway/input/seatop_default.c index 5a55c1866d..cb8aed9b74 100644 --- a/sway/input/seatop_default.c +++ b/sway/input/seatop_default.c @@ -369,7 +369,11 @@ static void handle_button(struct sway_seat *seat, uint32_t time_msec, struct wlr_layer_surface_v1 *layer; if (surface && (layer = wlr_layer_surface_v1_try_from_wlr_surface(surface))) { - if (layer->current.keyboard_interactive) { + if (layer->current.keyboard_interactive + || !(seat->focused_layer + && seat->focused_layer->current.keyboard_interactive + && seat->focused_layer != layer)) { + seat_set_focus(seat, NULL); seat_set_focus_layer(seat, layer); transaction_commit_dirty(); } @@ -380,6 +384,12 @@ static void handle_button(struct sway_seat *seat, uint32_t time_msec, return; } + // Don't change focus and don't send any inputs if there's a focused layer + // with keyboard exclusivity + if (seat->focused_layer && seat->focused_layer->current.keyboard_interactive) { + return; + } + // Handle tiling resize via border if (cont && resize_edge && button == BTN_LEFT && state == WLR_BUTTON_PRESSED && !is_floating) { @@ -443,6 +453,9 @@ static void handle_button(struct sway_seat *seat, uint32_t time_msec, } } + // Move the focus from the layer non-keyboard exclusive layer + seat_set_focus_layer(seat, NULL); + seat_set_focus(seat, node); transaction_commit_dirty(); } @@ -565,6 +578,11 @@ static void check_focus_follows_mouse(struct sway_seat *seat, return; } + // Prevents the layer from losing focus if it has keyboard exclusivity + if (seat->focused_layer && seat->focused_layer->current.keyboard_interactive) { + return; + } + // This is where we handle the common case. We don't want to focus inactive // tabs, hence the view_is_visible check. if (node_is_view(hovered_node) && @@ -575,6 +593,9 @@ static void check_focus_follows_mouse(struct sway_seat *seat, // But if focus_follows_mouse is "always", we do. if (hovered_node != e->previous_node || config->focus_follows_mouse == FOLLOWS_ALWAYS) { + // Move the focus from the layer non-keyboard exclusive layer + seat_set_focus_layer(seat, NULL); + seat_set_focus(seat, hovered_node); transaction_commit_dirty(); }