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.
This commit is contained in:
Levi Neely 2026-05-13 21:49:29 +02:00
parent 01f2e4463e
commit 840b00819d
1 changed files with 18 additions and 0 deletions

View File

@ -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) {