aboutsummaryrefslogtreecommitdiffstats
path: root/sway
diff options
context:
space:
mode:
authorLibravatar Drew DeVault <sir@cmpwn.com>2018-04-02 21:07:46 -0400
committerLibravatar Drew DeVault <sir@cmpwn.com>2018-04-02 21:09:09 -0400
commit56078edd65d05c1db1aa5d6e72134499e907063d (patch)
tree7848b49de2f3e7493b6d88aa23d849605c5c9a6d /sway
parentIdentify topmost interactive layer post-arrange (diff)
downloadsway-56078edd65d05c1db1aa5d6e72134499e907063d.tar.gz
sway-56078edd65d05c1db1aa5d6e72134499e907063d.tar.zst
sway-56078edd65d05c1db1aa5d6e72134499e907063d.zip
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 @@
7#include <wlr/types/wlr_output_damage.h> 7#include <wlr/types/wlr_output_damage.h>
8#include <wlr/types/wlr_output.h> 8#include <wlr/types/wlr_output.h>
9#include <wlr/util/log.h> 9#include <wlr/util/log.h>
10#include "sway/input/input-manager.h"
11#include "sway/input/seat.h"
10#include "sway/layers.h" 12#include "sway/layers.h"
11#include "sway/output.h" 13#include "sway/output.h"
12#include "sway/server.h" 14#include "sway/server.h"
@@ -208,7 +210,10 @@ void arrange_layers(struct sway_output *output) {
208 } 210 }
209 } 211 }
210 212
211 wlr_log(L_DEBUG, "topmost layer: %p", topmost); 213 struct sway_seat *seat;
214 wl_list_for_each(seat, &input_manager->seats, link) {
215 seat_set_focus_layer(seat, topmost ? topmost->layer_surface : NULL);
216 }
212} 217}
213 218
214static void handle_output_destroy(struct wl_listener *listener, void *data) { 219static 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) {
352 352
353void seat_set_focus_warp(struct sway_seat *seat, 353void seat_set_focus_warp(struct sway_seat *seat,
354 struct sway_container *container, bool warp) { 354 struct sway_container *container, bool warp) {
355 struct sway_container *last_focus = seat_get_focus(seat); 355 if (seat->focused_layer) {
356 return;
357 }
356 358
359 struct sway_container *last_focus = seat_get_focus(seat);
357 if (container && last_focus == container) { 360 if (container && last_focus == container) {
358 return; 361 return;
359 } 362 }
@@ -419,6 +422,37 @@ void seat_set_focus(struct sway_seat *seat,
419 seat_set_focus_warp(seat, container, true); 422 seat_set_focus_warp(seat, container, true);
420} 423}
421 424
425void seat_set_focus_layer(struct sway_seat *seat,
426 struct wlr_layer_surface *layer) {
427 if (!layer) {
428 seat->focused_layer = NULL;
429 return;
430 }
431 if (seat->focused_layer == layer) {
432 return;
433 }
434 if (seat->has_focus) {
435 struct sway_container *focus = seat_get_focus(seat);
436 if (focus->type == C_VIEW) {
437 wlr_seat_keyboard_clear_focus(seat->wlr_seat);
438 view_set_activated(focus->sway_view, false);
439 }
440 }
441 if (layer->layer >= ZWLR_LAYER_SHELL_V1_LAYER_TOP) {
442 seat->focused_layer = layer;
443 }
444 struct wlr_keyboard *keyboard =
445 wlr_seat_get_keyboard(seat->wlr_seat);
446 if (keyboard) {
447 wlr_seat_keyboard_notify_enter(seat->wlr_seat,
448 layer->surface, keyboard->keycodes,
449 keyboard->num_keycodes, &keyboard->modifiers);
450 } else {
451 wlr_seat_keyboard_notify_enter(seat->wlr_seat,
452 layer->surface, NULL, 0, NULL);
453 }
454}
455
422struct sway_container *seat_get_focus_inactive(struct sway_seat *seat, 456struct sway_container *seat_get_focus_inactive(struct sway_seat *seat,
423 struct sway_container *container) { 457 struct sway_container *container) {
424 return seat_get_focus_by_type(seat, container, C_TYPES); 458 return seat_get_focus_by_type(seat, container, C_TYPES);