wayland: proper hit testing that doesn't penetrate through widgets
All checks were successful
pyrite-dev/milsko/pipeline/head This commit looks good
All checks were successful
pyrite-dev/milsko/pipeline/head This commit looks good
This commit is contained in:
parent
ead5476c64
commit
269bbbe8b1
1 changed files with 23 additions and 4 deletions
|
|
@ -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;
|
||||
}
|
||||
|
||||
/* 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) {
|
||||
MwLL target = find_target(self, &p.point);
|
||||
|
||||
switch(state) {
|
||||
case WL_POINTER_BUTTON_STATE_PRESSED:
|
||||
MwLLDispatch(self, down, &p);
|
||||
MwLLDispatch(target, down, &p);
|
||||
break;
|
||||
case WL_POINTER_BUTTON_STATE_RELEASED:
|
||||
MwLLDispatch(self, up, &p);
|
||||
break;
|
||||
MwLLDispatch(target, up, &p);
|
||||
return;
|
||||
}
|
||||
|
||||
{
|
||||
|
|
@ -797,7 +817,6 @@ static void mouse_dispatch(MwLL self, MwMouse p, MwU32 state) {
|
|||
break;
|
||||
}
|
||||
|
||||
printf("%d\n", child->wayland.parent->wayland.type);
|
||||
mouse_dispatch(child, p, state);
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue