From 840b00819d70c6e80485918060e2efbe53a5ffe6 Mon Sep 17 00:00:00 2001 From: Levi Neely <141506390+lneely@users.noreply.github.com> Date: Wed, 13 May 2026 21:49:29 +0200 Subject: [PATCH] Route pointer events to deepest child view at click point In X11, the server delivers events to the deepest child window. In Wayland, all widgets share one frame_buf. WMHandleEvent now does hit-testing within the view tree to find the correct child widget for button press/release/motion events. --- WINGs/wevent.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/WINGs/wevent.c b/WINGs/wevent.c index e71b811..e6d886d 100644 --- a/WINGs/wevent.c +++ b/WINGs/wevent.c @@ -214,6 +214,24 @@ int WMHandleEvent(WMEvent * event) } else { extern W_View *W_GetViewForWindow(Window id); view = W_GetViewForWindow((Window)window); + /* Route pointer events to the deepest child at click point */ + if (view && (mask & (ButtonPressMask | ButtonReleaseMask | ButtonMotionMask))) { + int ex = event->u.button.x; + int ey = event->u.button.y; + W_View *child = view->childrenList; + while (child) { + if (child->flags.mapped && + ex >= child->pos.x && ex < child->pos.x + child->size.width && + ey >= child->pos.y && ey < child->pos.y + child->size.height) { + ex -= child->pos.x; + ey -= child->pos.y; + view = child; + child = view->childrenList; + } else { + child = child->nextSister; + } + } + } } if (!view) {