aboutsummaryrefslogtreecommitdiffstats
path: root/sway/input/seatop_default.c
diff options
context:
space:
mode:
authorLibravatar Erik Reider <35975961+ErikReider@users.noreply.github.com>2023-06-05 15:31:16 +0200
committerLibravatar Kenny Levinsen <kl@kl.wtf>2023-06-06 09:07:05 +0200
commit913a7679cbde98df0722b326d8c3cfc0f0576f6d (patch)
tree752fea000515bcd93a40fc175dbbace5221ee9c4 /sway/input/seatop_default.c
parentchase wlroots wlr_renderer_begin_buffer_pass change (diff)
downloadsway-913a7679cbde98df0722b326d8c3cfc0f0576f6d.tar.gz
sway-913a7679cbde98df0722b326d8c3cfc0f0576f6d.tar.zst
sway-913a7679cbde98df0722b326d8c3cfc0f0576f6d.zip
Add support for wlr-layer-shell ON_DEMAND keyboard interactivity
This allows for layer shell surfaces to receive focus while the surface is explicitly focused, i.e allowing text fields to receive keyboard input just like a regular surface.
Diffstat (limited to 'sway/input/seatop_default.c')
-rw-r--r--sway/input/seatop_default.c24
1 files changed, 20 insertions, 4 deletions
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);