diff options
author | Drew DeVault <sir@cmpwn.com> | 2018-04-02 20:45:39 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-04-02 20:45:39 -0400 |
commit | 9ce53d7dc4c49da7cb9c56a3d552969180422380 (patch) | |
tree | d43fa4066ce792f81f88e5e1161c6da4284e977b /rootston/seat.c | |
parent | 7279054bffb3c2ba4523c56f3441a5916dc8be67 (diff) | |
parent | 333ab599022a645f92facf41cde03ab03866b08f (diff) |
Merge pull request #804 from swaywm/keyboard-layers
Add keyboard input to layer surfaces
Diffstat (limited to 'rootston/seat.c')
-rw-r--r-- | rootston/seat.c | 43 |
1 files changed, 39 insertions, 4 deletions
diff --git a/rootston/seat.c b/rootston/seat.c index bdcad5c7..cfdeab00 100644 --- a/rootston/seat.c +++ b/rootston/seat.c @@ -4,6 +4,7 @@ #include <wayland-server.h> #include <wlr/config.h> #include <wlr/types/wlr_idle.h> +#include <wlr/types/wlr_layer_shell.h> #include <wlr/types/wlr_xcursor_manager.h> #include <wlr/util/log.h> #include "rootston/cursor.h" @@ -723,7 +724,6 @@ void roots_seat_set_focus(struct roots_seat *seat, struct roots_view *view) { wl_list_insert(&seat->input->server->desktop->views, &view->link); } - bool unfullscreen = true; #ifdef WLR_HAS_XWAYLAND @@ -781,14 +781,18 @@ void roots_seat_set_focus(struct roots_seat *seat, struct roots_view *view) { return; } - view_activate(view, true); - - seat->has_focus = true; wl_list_remove(&seat_view->link); wl_list_insert(&seat->views, &seat_view->link); view_damage_whole(view); + if (seat->focused_layer) { + return; + } + + view_activate(view, true); + seat->has_focus = true; + struct wlr_keyboard *keyboard = wlr_seat_get_keyboard(seat->seat); if (keyboard != NULL) { wlr_seat_keyboard_notify_enter(seat->seat, view->wlr_surface, @@ -800,6 +804,37 @@ void roots_seat_set_focus(struct roots_seat *seat, struct roots_view *view) { } } +/** + * Focus semantics of layer surfaces are somewhat detached from the normal focus + * flow. For layers above the shell layer, for example, you cannot unfocus them. + * You also cannot alt-tab between layer surfaces and shell surfaces. + */ +void roots_seat_set_focus_layer(struct roots_seat *seat, + struct wlr_layer_surface *layer) { + struct wlr_keyboard *keyboard = wlr_seat_get_keyboard(seat->seat); + if (!layer) { + seat->focused_layer = NULL; + return; + } + if (seat->has_focus) { + struct roots_view *prev_focus = roots_seat_get_focus(seat); + wlr_seat_keyboard_clear_focus(seat->seat); + view_activate(prev_focus, false); + } + seat->has_focus = false; + if (layer->layer >= ZWLR_LAYER_SHELL_V1_LAYER_TOP) { + seat->focused_layer = layer; + } + if (keyboard != NULL) { + wlr_seat_keyboard_notify_enter(seat->seat, layer->surface, + keyboard->keycodes, keyboard->num_keycodes, + &keyboard->modifiers); + } else { + wlr_seat_keyboard_notify_enter(seat->seat, layer->surface, + NULL, 0, NULL); + } +} + void roots_seat_cycle_focus(struct roots_seat *seat) { if (wl_list_empty(&seat->views)) { return; |