Always give keyboard focus to the topmost layer

This commit is contained in:
Drew DeVault 2018-04-02 15:48:22 -04:00
parent 883d8d306c
commit a94f4d0edc
4 changed files with 89 additions and 7 deletions

View file

@ -214,7 +214,12 @@ void arrange_layers(struct roots_output *output) {
break;
}
}
wlr_log(L_DEBUG, "topmost interactive layer: %p", topmost);
struct roots_input *input = output->desktop->server->input;
struct roots_seat *seat;
wl_list_for_each(seat, &input->seats, link) {
roots_seat_set_focus_layer(seat, topmost);
}
}
static void handle_output_destroy(struct wl_listener *listener, void *data) {

View file

@ -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,30 @@ void roots_seat_set_focus(struct roots_seat *seat, struct roots_view *view) {
}
}
void roots_seat_set_focus_layer(struct roots_seat *seat,
struct roots_layer_surface *layer) {
struct wlr_keyboard *keyboard = wlr_seat_get_keyboard(seat->seat);
seat->focused_layer = layer;
if (!layer) {
wlr_seat_keyboard_clear_focus(seat->seat);
return;
}
if (seat->has_focus) {
struct roots_view *prev_focus = roots_seat_get_focus(seat);
view_activate(prev_focus, false);
}
seat->has_focus = false;
struct wlr_layer_surface *layer_surface = layer->layer_surface;
if (keyboard != NULL) {
wlr_seat_keyboard_notify_enter(seat->seat, layer_surface->surface,
keyboard->keycodes, keyboard->num_keycodes,
&keyboard->modifiers);
} else {
wlr_seat_keyboard_notify_enter(seat->seat, layer_surface->surface,
NULL, 0, NULL);
}
}
void roots_seat_cycle_focus(struct roots_seat *seat) {
if (wl_list_empty(&seat->views)) {
return;
@ -826,6 +854,7 @@ void roots_seat_cycle_focus(struct roots_seat *seat) {
}
void roots_seat_begin_move(struct roots_seat *seat, struct roots_view *view) {
wlr_log(L_DEBUG, "begin move");
struct roots_cursor *cursor = seat->cursor;
cursor->mode = ROOTS_CURSOR_MOVE;
cursor->offs_x = cursor->cursor->x;