Any visible window that obscures another window now prevents the underlying window from receiving mouse event.
This commit is contained in:
parent
b2b09319e4
commit
d15c63abdb
1 changed files with 25 additions and 18 deletions
|
@ -86,6 +86,7 @@ static void gwidgetEvent(void *param, GEvent *pe) {
|
||||||
#define pte ((GEventToggle *)pe)
|
#define pte ((GEventToggle *)pe)
|
||||||
#define pde ((GEventDial *)pe)
|
#define pde ((GEventDial *)pe)
|
||||||
|
|
||||||
|
GHandle h;
|
||||||
GHandle gh;
|
GHandle gh;
|
||||||
#if GFX_USE_GINPUT && (GINPUT_NEED_TOGGLE || GINPUT_NEED_DIAL)
|
#if GFX_USE_GINPUT && (GINPUT_NEED_TOGGLE || GINPUT_NEED_DIAL)
|
||||||
uint16_t role;
|
uint16_t role;
|
||||||
|
@ -99,32 +100,38 @@ static void gwidgetEvent(void *param, GEvent *pe) {
|
||||||
case GEVENT_MOUSE:
|
case GEVENT_MOUSE:
|
||||||
case GEVENT_TOUCH:
|
case GEVENT_TOUCH:
|
||||||
// Cycle through all windows
|
// Cycle through all windows
|
||||||
for(gh = gwinGetNextWindow(0); gh; gh = gwinGetNextWindow(gh)) {
|
for(gh = 0, h = gwinGetNextWindow(0); h; h = gwinGetNextWindow(h)) {
|
||||||
|
|
||||||
// check if the widget matches this display
|
// The window must be on this display and visible to be relevant
|
||||||
if (gh->display != pme->display)
|
if (h->display != pme->display || !(h->flags & GWIN_FLG_SYSVISIBLE))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// check if it is a widget that is enabled and visible
|
// Is the mouse currently captured by this widget?
|
||||||
if ((gh->flags & (GWIN_FLG_WIDGET|GWIN_FLG_SYSENABLED|GWIN_FLG_SYSVISIBLE)) != (GWIN_FLG_WIDGET|GWIN_FLG_SYSENABLED|GWIN_FLG_SYSVISIBLE))
|
if ((h->flags & (GWIN_FLG_WIDGET|GWIN_FLG_MOUSECAPTURE)) == (GWIN_FLG_WIDGET|GWIN_FLG_MOUSECAPTURE)) {
|
||||||
continue;
|
gh = h;
|
||||||
|
|
||||||
// Are we captured?
|
|
||||||
if ((gw->g.flags & GWIN_FLG_MOUSECAPTURE)) {
|
|
||||||
if ((pme->last_buttons & ~pme->current_buttons & GINPUT_MOUSE_BTN_LEFT)) {
|
if ((pme->last_buttons & ~pme->current_buttons & GINPUT_MOUSE_BTN_LEFT)) {
|
||||||
gw->g.flags &= ~GWIN_FLG_MOUSECAPTURE;
|
gh->flags &= ~GWIN_FLG_MOUSECAPTURE;
|
||||||
if (wvmt->MouseUp)
|
if (wvmt->MouseUp)
|
||||||
wvmt->MouseUp(gw, pme->x - gw->g.x, pme->y - gw->g.y);
|
wvmt->MouseUp(gw, pme->x - gh->x, pme->y - gh->y);
|
||||||
} else if (wvmt->MouseMove)
|
} else if (wvmt->MouseMove)
|
||||||
wvmt->MouseMove(gw, pme->x - gw->g.x, pme->y - gw->g.y);
|
wvmt->MouseMove(gw, pme->x - gh->x, pme->y - gh->y);
|
||||||
|
|
||||||
// We are not captured - look for mouse downs over the widget
|
// There is only ever one captured mouse. Prevent normal mouse processing if there is a captured mouse
|
||||||
} else if ((~pme->last_buttons & pme->current_buttons & GINPUT_MOUSE_BTN_LEFT)
|
gh = 0;
|
||||||
&& pme->x >= gw->g.x && pme->x < gw->g.x + gw->g.width
|
break;
|
||||||
&& pme->y >= gw->g.y && pme->y < gw->g.y + gw->g.height) {
|
}
|
||||||
gw->g.flags |= GWIN_FLG_MOUSECAPTURE;
|
|
||||||
|
// Save the highest z-order window that the mouse is over
|
||||||
|
if (pme->x >= h->x && pme->x < h->x + h->width && pme->y >= h->y && pme->y < h->y + h->height)
|
||||||
|
gh = h;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Process any mouse down over the highest order window if it is an enabled widget
|
||||||
|
if (gh && (gh->flags & (GWIN_FLG_WIDGET|GWIN_FLG_SYSENABLED)) == (GWIN_FLG_WIDGET|GWIN_FLG_SYSENABLED)) {
|
||||||
|
if ((~pme->last_buttons & pme->current_buttons & GINPUT_MOUSE_BTN_LEFT)) {
|
||||||
|
gh->flags |= GWIN_FLG_MOUSECAPTURE;
|
||||||
if (wvmt->MouseDown)
|
if (wvmt->MouseDown)
|
||||||
wvmt->MouseDown(gw, pme->x - gw->g.x, pme->y - gw->g.y);
|
wvmt->MouseDown(gw, pme->x - gh->x, pme->y - gh->y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Add table
Reference in a new issue