diff options
Diffstat (limited to 'sway/input')
-rw-r--r-- | sway/input/seat.c | 20 | ||||
-rw-r--r-- | sway/input/seatop_default.c | 24 |
2 files changed, 35 insertions, 9 deletions
diff --git a/sway/input/seat.c b/sway/input/seat.c index 5795f40f..fdd21057 100644 --- a/sway/input/seat.c +++ b/sway/input/seat.c | |||
@@ -1295,11 +1295,15 @@ static void seat_set_workspace_focus(struct sway_seat *seat, struct sway_node *n | |||
1295 | } | 1295 | } |
1296 | 1296 | ||
1297 | void seat_set_focus(struct sway_seat *seat, struct sway_node *node) { | 1297 | void seat_set_focus(struct sway_seat *seat, struct sway_node *node) { |
1298 | if (seat->focused_layer) { | 1298 | // Prevents the layer from losing focus if it has keyboard exclusivity |
1299 | if (seat->has_exclusive_layer) { | ||
1299 | struct wlr_layer_surface_v1 *layer = seat->focused_layer; | 1300 | struct wlr_layer_surface_v1 *layer = seat->focused_layer; |
1300 | seat_set_focus_layer(seat, NULL); | 1301 | seat_set_focus_layer(seat, NULL); |
1301 | seat_set_workspace_focus(seat, node); | 1302 | seat_set_workspace_focus(seat, node); |
1302 | seat_set_focus_layer(seat, layer); | 1303 | seat_set_focus_layer(seat, layer); |
1304 | } else if (seat->focused_layer) { | ||
1305 | seat_set_focus_layer(seat, NULL); | ||
1306 | seat_set_workspace_focus(seat, node); | ||
1303 | } else { | 1307 | } else { |
1304 | seat_set_workspace_focus(seat, node); | 1308 | seat_set_workspace_focus(seat, node); |
1305 | } | 1309 | } |
@@ -1347,14 +1351,20 @@ void seat_set_focus_layer(struct sway_seat *seat, | |||
1347 | seat_set_focus(seat, previous); | 1351 | seat_set_focus(seat, previous); |
1348 | } | 1352 | } |
1349 | return; | 1353 | return; |
1350 | } else if (!layer || seat->focused_layer == layer) { | 1354 | } else if (!layer) { |
1351 | return; | 1355 | return; |
1352 | } | 1356 | } |
1353 | assert(layer->surface->mapped); | 1357 | assert(layer->surface->mapped); |
1354 | seat_set_focus_surface(seat, layer->surface, true); | 1358 | if (layer->current.layer >= ZWLR_LAYER_SHELL_V1_LAYER_TOP && |
1355 | if (layer->current.layer >= ZWLR_LAYER_SHELL_V1_LAYER_TOP) { | 1359 | layer->current.keyboard_interactive |
1356 | seat->focused_layer = layer; | 1360 | == ZWLR_LAYER_SURFACE_V1_KEYBOARD_INTERACTIVITY_EXCLUSIVE) { |
1361 | seat->has_exclusive_layer = true; | ||
1362 | } | ||
1363 | if (seat->focused_layer == layer) { | ||
1364 | return; | ||
1357 | } | 1365 | } |
1366 | seat_set_focus_surface(seat, layer->surface, true); | ||
1367 | seat->focused_layer = layer; | ||
1358 | } | 1368 | } |
1359 | 1369 | ||
1360 | void seat_set_exclusive_client(struct sway_seat *seat, | 1370 | void seat_set_exclusive_client(struct sway_seat *seat, |
diff --git a/sway/input/seatop_default.c b/sway/input/seatop_default.c index 5a55c186..f4c63808 100644 --- a/sway/input/seatop_default.c +++ b/sway/input/seatop_default.c | |||
@@ -2,6 +2,7 @@ | |||
2 | #include <float.h> | 2 | #include <float.h> |
3 | #include <libevdev/libevdev.h> | 3 | #include <libevdev/libevdev.h> |
4 | #include <wlr/types/wlr_cursor.h> | 4 | #include <wlr/types/wlr_cursor.h> |
5 | #include <wlr/types/wlr_subcompositor.h> | ||
5 | #include <wlr/types/wlr_tablet_v2.h> | 6 | #include <wlr/types/wlr_tablet_v2.h> |
6 | #include <wlr/types/wlr_xcursor_manager.h> | 7 | #include <wlr/types/wlr_xcursor_manager.h> |
7 | #include "gesture.h" | 8 | #include "gesture.h" |
@@ -9,6 +10,7 @@ | |||
9 | #include "sway/input/cursor.h" | 10 | #include "sway/input/cursor.h" |
10 | #include "sway/input/seat.h" | 11 | #include "sway/input/seat.h" |
11 | #include "sway/input/tablet.h" | 12 | #include "sway/input/tablet.h" |
13 | #include "sway/layers.h" | ||
12 | #include "sway/output.h" | 14 | #include "sway/output.h" |
13 | #include "sway/tree/view.h" | 15 | #include "sway/tree/view.h" |
14 | #include "sway/tree/workspace.h" | 16 | #include "sway/tree/workspace.h" |
@@ -365,10 +367,9 @@ static void handle_button(struct sway_seat *seat, uint32_t time_msec, | |||
365 | return; | 367 | return; |
366 | } | 368 | } |
367 | 369 | ||
368 | // Handle clicking a layer surface | 370 | // Handle clicking a layer surface and its popups/subsurfaces |
369 | struct wlr_layer_surface_v1 *layer; | 371 | struct wlr_layer_surface_v1 *layer = NULL; |
370 | if (surface && | 372 | if ((layer = toplevel_layer_surface_from_surface(surface))) { |
371 | (layer = wlr_layer_surface_v1_try_from_wlr_surface(surface))) { | ||
372 | if (layer->current.keyboard_interactive) { | 373 | if (layer->current.keyboard_interactive) { |
373 | seat_set_focus_layer(seat, layer); | 374 | seat_set_focus_layer(seat, layer); |
374 | transaction_commit_dirty(); | 375 | transaction_commit_dirty(); |
@@ -544,6 +545,21 @@ static void check_focus_follows_mouse(struct sway_seat *seat, | |||
544 | if (wlr_output == NULL) { | 545 | if (wlr_output == NULL) { |
545 | return; | 546 | return; |
546 | } | 547 | } |
548 | |||
549 | struct wlr_surface *surface = NULL; | ||
550 | double sx, sy; | ||
551 | node_at_coords(seat, seat->cursor->cursor->x, seat->cursor->cursor->y, | ||
552 | &surface, &sx, &sy); | ||
553 | |||
554 | // Focus topmost layer surface | ||
555 | struct wlr_layer_surface_v1 *layer = NULL; | ||
556 | if ((layer = toplevel_layer_surface_from_surface(surface)) && | ||
557 | layer->current.keyboard_interactive) { | ||
558 | seat_set_focus_layer(seat, layer); | ||
559 | transaction_commit_dirty(); | ||
560 | return; | ||
561 | } | ||
562 | |||
547 | struct sway_output *hovered_output = wlr_output->data; | 563 | struct sway_output *hovered_output = wlr_output->data; |
548 | if (focus && hovered_output != node_get_output(focus)) { | 564 | if (focus && hovered_output != node_get_output(focus)) { |
549 | struct sway_workspace *ws = output_get_active_workspace(hovered_output); | 565 | struct sway_workspace *ws = output_get_active_workspace(hovered_output); |