From 46ff9d54f19297cd325633fa65d14c2f6f161dae Mon Sep 17 00:00:00 2001 From: DreamMaoMao <2523610504@qq.com> Date: Wed, 11 Jun 2025 13:39:55 +0800 Subject: [PATCH] feat: update to wlr_layer_shell v4 --- src/maomao.c | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/src/maomao.c b/src/maomao.c index b092040..4f2a634 100644 --- a/src/maomao.c +++ b/src/maomao.c @@ -2495,7 +2495,9 @@ void arrangelayers(Monitor *m) { /* Find topmost keyboard interactive layer, if such a layer exists */ for (i = 0; i < (int)LENGTH(layers_above_shell); i++) { 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) continue; /* Deactivate the focused client. */ @@ -2730,13 +2732,11 @@ buttonpress(struct wl_listener *listener, void *data) { struct wlr_keyboard *keyboard; uint32_t mods; Client *c; + LayerSurface *l; + struct wlr_surface *surface; Client *tmpc; int ji; const MouseBinding *b; - struct wlr_surface *surface; - - struct wlr_surface *old_pointer_focus_surface = - seat->pointer_state.focused_surface; handlecursoractivity(); wlr_idle_notifier_v1_notify_activity(idle_notifier, seat); @@ -2748,13 +2748,17 @@ buttonpress(struct wl_listener *listener, void *data) { if (locked) break; - /* Change focus if the button was _pressed_ over a client */ - xytonode(cursor->x, cursor->y, &surface, &c, NULL, NULL, NULL); - if (c && (!client_is_unmanaged(c) || client_wants_focus(c))) - focusclient(c, 1); + xytonode(cursor->x, cursor->y, &surface, NULL, NULL, NULL, NULL); + if (toplevel_from_wlr_surface(surface, &c, &l) >= 0) { + if (c && (!client_is_unmanaged(c) || client_wants_focus(c))) + focusclient(c, 1); - if (surface != old_pointer_focus_surface) - wlr_seat_pointer_notify_clear_focus(seat); + if (l && l->layer_surface->current.keyboard_interactive) { + focusclient(NULL, 0); + client_notify_enter(l->layer_surface->surface, + wlr_seat_get_keyboard(seat)); + } + } keyboard = wlr_seat_get_keyboard(seat); mods = keyboard ? wlr_keyboard_get_modifiers(keyboard) : 0; @@ -3010,6 +3014,11 @@ void commitlayersurfacenotify(struct wl_listener *listener, void *data) { 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 && l->mapped == layer_surface->surface->mapped) return; @@ -4000,7 +4009,8 @@ void focusclient(Client *c, int lift) { int type = toplevel_from_wlr_surface(old_keyboard_focus_surface, &w, &l); 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; } else if (w && w == exclusive_focus && client_wants_focus(w)) { return;