wayland: proper hit testing that doesn't penetrate through widgets
All checks were successful
pyrite-dev/milsko/pipeline/head This commit looks good

This commit is contained in:
IoIxD 2026-09-26 13:38:35 -07:00
commit 269bbbe8b1

View file

@ -754,14 +754,34 @@ static MwBool hit_detect(MwLL child, MwLL* _topmost_parent, MwPoint* _point, MwP
point.y >= absolute_pos.y && point.y <= absolute_pos.y + child->wayland.wh; point.y >= absolute_pos.y && point.y <= absolute_pos.y + child->wayland.wh;
} }
/* deepest, topmost-z sublevel under the pointer, or self if none */
static MwLL find_target(MwLL self, MwPoint* local) {
MwLL* children = MwLLWaylandSublevelsByZIndex(self);
MwLL target = self;
int i;
for(i = arrlen(children) - 1; i >= 0; i--) {
MwLL tp;
MwPoint pt, rel, abs;
if(hit_detect(children[i], &tp, &pt, &rel, &abs)) {
*local = rel;
target = find_target(children[i], local);
break;
}
}
arrfree(children);
return target;
}
static void mouse_dispatch(MwLL self, MwMouse p, MwU32 state) { static void mouse_dispatch(MwLL self, MwMouse p, MwU32 state) {
MwLL target = find_target(self, &p.point);
switch(state) { switch(state) {
case WL_POINTER_BUTTON_STATE_PRESSED: case WL_POINTER_BUTTON_STATE_PRESSED:
MwLLDispatch(self, down, &p); MwLLDispatch(target, down, &p);
break; break;
case WL_POINTER_BUTTON_STATE_RELEASED: case WL_POINTER_BUTTON_STATE_RELEASED:
MwLLDispatch(self, up, &p); MwLLDispatch(target, up, &p);
break; return;
} }
{ {
@ -797,7 +817,6 @@ static void mouse_dispatch(MwLL self, MwMouse p, MwU32 state) {
break; break;
} }
printf("%d\n", child->wayland.parent->wayland.type);
mouse_dispatch(child, p, state); mouse_dispatch(child, p, state);
break; break;
} }