feat: update to wlr_layer_shell v4

This commit is contained in:
DreamMaoMao 2025-06-11 13:39:55 +08:00
parent 731eea06d4
commit 46ff9d54f1

View file

@ -2495,7 +2495,9 @@ void arrangelayers(Monitor *m) {
/* Find topmost keyboard interactive layer, if such a layer exists */ /* Find topmost keyboard interactive layer, if such a layer exists */
for (i = 0; i < (int)LENGTH(layers_above_shell); i++) { for (i = 0; i < (int)LENGTH(layers_above_shell); i++) {
wl_list_for_each_reverse(l, &m->layers[layers_above_shell[i]], link) { wl_list_for_each_reverse(l, &m->layers[layers_above_shell[i]], link) {
if (locked || !l->layer_surface->current.keyboard_interactive || if (locked ||
l->layer_surface->current.keyboard_interactive !=
ZWLR_LAYER_SURFACE_V1_KEYBOARD_INTERACTIVITY_EXCLUSIVE ||
!l->mapped) !l->mapped)
continue; continue;
/* Deactivate the focused client. */ /* Deactivate the focused client. */
@ -2730,13 +2732,11 @@ buttonpress(struct wl_listener *listener, void *data) {
struct wlr_keyboard *keyboard; struct wlr_keyboard *keyboard;
uint32_t mods; uint32_t mods;
Client *c; Client *c;
LayerSurface *l;
struct wlr_surface *surface;
Client *tmpc; Client *tmpc;
int ji; int ji;
const MouseBinding *b; const MouseBinding *b;
struct wlr_surface *surface;
struct wlr_surface *old_pointer_focus_surface =
seat->pointer_state.focused_surface;
handlecursoractivity(); handlecursoractivity();
wlr_idle_notifier_v1_notify_activity(idle_notifier, seat); wlr_idle_notifier_v1_notify_activity(idle_notifier, seat);
@ -2748,13 +2748,17 @@ buttonpress(struct wl_listener *listener, void *data) {
if (locked) if (locked)
break; break;
/* Change focus if the button was _pressed_ over a client */ xytonode(cursor->x, cursor->y, &surface, NULL, NULL, NULL, NULL);
xytonode(cursor->x, cursor->y, &surface, &c, NULL, NULL, NULL); if (toplevel_from_wlr_surface(surface, &c, &l) >= 0) {
if (c && (!client_is_unmanaged(c) || client_wants_focus(c))) if (c && (!client_is_unmanaged(c) || client_wants_focus(c)))
focusclient(c, 1); focusclient(c, 1);
if (surface != old_pointer_focus_surface) if (l && l->layer_surface->current.keyboard_interactive) {
wlr_seat_pointer_notify_clear_focus(seat); focusclient(NULL, 0);
client_notify_enter(l->layer_surface->surface,
wlr_seat_get_keyboard(seat));
}
}
keyboard = wlr_seat_get_keyboard(seat); keyboard = wlr_seat_get_keyboard(seat);
mods = keyboard ? wlr_keyboard_get_modifiers(keyboard) : 0; mods = keyboard ? wlr_keyboard_get_modifiers(keyboard) : 0;
@ -3010,6 +3014,11 @@ void commitlayersurfacenotify(struct wl_listener *listener, void *data) {
return; return;
} }
if (layer_surface == exclusive_focus &&
layer_surface->current.keyboard_interactive !=
ZWLR_LAYER_SURFACE_V1_KEYBOARD_INTERACTIVITY_EXCLUSIVE)
exclusive_focus = NULL;
if (layer_surface->current.committed == 0 && if (layer_surface->current.committed == 0 &&
l->mapped == layer_surface->surface->mapped) l->mapped == layer_surface->surface->mapped)
return; return;
@ -4000,7 +4009,8 @@ void focusclient(Client *c, int lift) {
int type = int type =
toplevel_from_wlr_surface(old_keyboard_focus_surface, &w, &l); toplevel_from_wlr_surface(old_keyboard_focus_surface, &w, &l);
if (type == LayerShell && l->scene->node.enabled && if (type == LayerShell && l->scene->node.enabled &&
l->layer_surface->current.layer >= ZWLR_LAYER_SHELL_V1_LAYER_TOP) { l->layer_surface->current.layer >= ZWLR_LAYER_SHELL_V1_LAYER_TOP &&
!l->layer_surface->current.keyboard_interactive) {
return; return;
} else if (w && w == exclusive_focus && client_wants_focus(w)) { } else if (w && w == exclusive_focus && client_wants_focus(w)) {
return; return;