From 147b9d0694e81f2cc1a38b4c0866f4c2d012feaa Mon Sep 17 00:00:00 2001 From: Levi Neely <141506390+lneely@users.noreply.github.com> Date: Wed, 13 May 2026 18:21:07 +0200 Subject: [PATCH] Fix hit-testing: prefer child frame_bufs over parents MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit frame_buf_at was returning the parent frame instead of child windows (titlebar, content area) because the parent was later in the list. Now prefers children (frame_bufs with parent_id set) over parents. This fixes menu titlebar click detection — clicking the titlebar now dispatches to titlebarMouseDown/menuTitleMouseDown instead of menuMouseDown, enabling menu pinning and drag-to-move. --- src/backend/wayland/wl_backend.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/backend/wayland/wl_backend.c b/src/backend/wayland/wl_backend.c index f2683db..9aff056 100644 --- a/src/backend/wayland/wl_backend.c +++ b/src/backend/wayland/wl_backend.c @@ -3555,8 +3555,11 @@ frame_buf_at(int px, int py) if (!fb->scene_buf || !fb->scene_buf->node.enabled) continue; if (px >= fb->x && px < fb->x + fb->width && - py >= fb->y && py < fb->y + fb->height) - hit = fb; /* last match = topmost in scene order */ + py >= fb->y && py < fb->y + fb->height) { + /* Prefer children (more specific) over parents */ + if (!hit || fb->parent_id) + hit = fb; + } } return hit; }