layer-shell: implement on-demand keyboard interactivity

This commit is contained in:
Aleksei Bavshin 2021-01-22 07:40:21 -08:00
parent 241ce2af83
commit 140321577e
No known key found for this signature in database
GPG key ID: 4F071603387A382A
2 changed files with 9 additions and 3 deletions

View file

@ -211,7 +211,8 @@ void arrange_layers(struct sway_output *output) {
for (size_t i = 0; i < nlayers; ++i) {
wl_list_for_each_reverse(layer,
&output->layers[layers_above_shell[i]], link) {
if (layer->layer_surface->current.keyboard_interactive &&
if (layer->layer_surface->current.keyboard_interactive ==
ZWLR_LAYER_SURFACE_V1_KEYBOARD_INTERACTIVITY_EXCLUSIVE &&
layer->layer_surface->mapped) {
topmost = layer;
break;
@ -227,7 +228,8 @@ void arrange_layers(struct sway_output *output) {
if (topmost != NULL) {
seat_set_focus_layer(seat, topmost->layer_surface);
} else if (seat->focused_layer &&
!seat->focused_layer->current.keyboard_interactive) {
seat->focused_layer->current.keyboard_interactive !=
ZWLR_LAYER_SURFACE_V1_KEYBOARD_INTERACTIVITY_EXCLUSIVE) {
seat_set_focus_layer(seat, NULL);
}
}

View file

@ -365,8 +365,12 @@ static void handle_button(struct sway_seat *seat, uint32_t time_msec,
if (surface && wlr_surface_is_layer_surface(surface)) {
struct wlr_layer_surface_v1 *layer =
wlr_layer_surface_v1_from_wlr_surface(surface);
if (layer->current.keyboard_interactive) {
if (layer->current.keyboard_interactive ==
ZWLR_LAYER_SURFACE_V1_KEYBOARD_INTERACTIVITY_EXCLUSIVE) {
seat_set_focus_layer(seat, layer);
} else if (layer->current.keyboard_interactive ==
ZWLR_LAYER_SURFACE_V1_KEYBOARD_INTERACTIVITY_ON_DEMAND) {
seat_set_focus_surface(seat, surface, true);
}
seat_pointer_notify_button(seat, time_msec, button, state);
return;