diff --git a/src/backend/wayland/wl_handlers.c b/src/backend/wayland/wl_handlers.c index 293317c..1006d19 100644 --- a/src/backend/wayland/wl_handlers.c +++ b/src/backend/wayland/wl_handlers.c @@ -269,12 +269,28 @@ handle_pointer_button(struct wl_listener *listener, void *data) case 0x112: wev.u.button.button = 2; break; default: wev.u.button.button = (ev->button - 0x110) + 1; break; } - /* For WINGs views, resolve the child widget at click coordinates */ + /* For WINGs views, resolve the child widget at click coordinates. + * Two cases: + * 1. fb->id >= 0x20000000 — fb IS a WINGs view frame_buf, use directly. + * 2. fb->id < 0x20000000 but has a WWindow with client_leader — + * the fb is a WM fake_leader; look up the WINGs panel via leader. */ struct W_View *target = NULL; + WNativeWindow wings_id = 0; if (fb && fb->id >= 0x20000000) { + wings_id = fb->id; + } else if (fb) { + /* Try to find a WWindow whose client_leader is a WINGs view */ + WObjDescriptor *desc = wm_backend->context_find(fb->id, WM_CTX_CLIENT_WIN); + if (desc && desc->parent_type == WCLASS_WINDOW) { + WWindow *wwin = (WWindow *)desc->parent; + if (wwin->client_leader >= 0x20000000) + wings_id = wwin->client_leader; + } + } + if (wings_id) { extern W_View *W_GetViewForWindow(unsigned long id); extern struct W_View *W_FindViewAtPoint(struct W_View *parent, int x, int y); - W_View *toplevel = W_GetViewForWindow((unsigned long)fb->id); + W_View *toplevel = W_GetViewForWindow((unsigned long)wings_id); if (toplevel) { target = W_FindViewAtPoint(toplevel, wev.u.button.x, wev.u.button.y);