aboutsummaryrefslogtreecommitdiff
path: root/sway
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2018-04-02 21:07:46 -0400
committerDrew DeVault <sir@cmpwn.com>2018-04-02 21:09:09 -0400
commit56078edd65d05c1db1aa5d6e72134499e907063d (patch)
tree7848b49de2f3e7493b6d88aa23d849605c5c9a6d /sway
parent623a08e14fa1434afe5cd0aa0c1b0f5789baa12d (diff)
Give exclusive focus to layers above shell layer
Diffstat (limited to 'sway')
-rw-r--r--sway/desktop/layer_shell.c7
-rw-r--r--sway/input/seat.c36
2 files changed, 41 insertions, 2 deletions
diff --git a/sway/desktop/layer_shell.c b/sway/desktop/layer_shell.c
index a187432b..3c7b45f7 100644
--- a/sway/desktop/layer_shell.c
+++ b/sway/desktop/layer_shell.c
@@ -7,6 +7,8 @@
#include <wlr/types/wlr_output_damage.h>
#include <wlr/types/wlr_output.h>
#include <wlr/util/log.h>
+#include "sway/input/input-manager.h"
+#include "sway/input/seat.h"
#include "sway/layers.h"
#include "sway/output.h"
#include "sway/server.h"
@@ -208,7 +210,10 @@ void arrange_layers(struct sway_output *output) {
}
}
- wlr_log(L_DEBUG, "topmost layer: %p", topmost);
+ struct sway_seat *seat;
+ wl_list_for_each(seat, &input_manager->seats, link) {
+ seat_set_focus_layer(seat, topmost ? topmost->layer_surface : NULL);
+ }
}
static void handle_output_destroy(struct wl_listener *listener, void *data) {
diff --git a/sway/input/seat.c b/sway/input/seat.c
index c41f7b2e..cf519a82 100644
--- a/sway/input/seat.c
+++ b/sway/input/seat.c
@@ -352,8 +352,11 @@ void seat_configure_xcursor(struct sway_seat *seat) {
void seat_set_focus_warp(struct sway_seat *seat,
struct sway_container *container, bool warp) {
- struct sway_container *last_focus = seat_get_focus(seat);
+ if (seat->focused_layer) {
+ return;
+ }
+ struct sway_container *last_focus = seat_get_focus(seat);
if (container && last_focus == container) {
return;
}
@@ -419,6 +422,37 @@ void seat_set_focus(struct sway_seat *seat,
seat_set_focus_warp(seat, container, true);
}
+void seat_set_focus_layer(struct sway_seat *seat,
+ struct wlr_layer_surface *layer) {
+ if (!layer) {
+ seat->focused_layer = NULL;
+ return;
+ }
+ if (seat->focused_layer == layer) {
+ return;
+ }
+ if (seat->has_focus) {
+ struct sway_container *focus = seat_get_focus(seat);
+ if (focus->type == C_VIEW) {
+ wlr_seat_keyboard_clear_focus(seat->wlr_seat);
+ view_set_activated(focus->sway_view, false);
+ }
+ }
+ if (layer->layer >= ZWLR_LAYER_SHELL_V1_LAYER_TOP) {
+ seat->focused_layer = layer;
+ }
+ struct wlr_keyboard *keyboard =
+ wlr_seat_get_keyboard(seat->wlr_seat);
+ if (keyboard) {
+ wlr_seat_keyboard_notify_enter(seat->wlr_seat,
+ layer->surface, keyboard->keycodes,
+ keyboard->num_keycodes, &keyboard->modifiers);
+ } else {
+ wlr_seat_keyboard_notify_enter(seat->wlr_seat,
+ layer->surface, NULL, 0, NULL);
+ }
+}
+
struct sway_container *seat_get_focus_inactive(struct sway_seat *seat,
struct sway_container *container) {
return seat_get_focus_by_type(seat, container, C_TYPES);