aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorinmarket <andrewh@inmarket.com.au>2014-08-07 11:22:14 +1000
committerinmarket <andrewh@inmarket.com.au>2014-08-07 11:22:14 +1000
commitd15c63abdbded078f0fa5b6bbfa782c1dfe9e22b (patch)
treea4316d38b9f959e72eab79144ab2861ea90eabf2 /src
parentb2b09319e47fe37dc293a0c80bb7ac3a563f13e2 (diff)
downloaduGFX-d15c63abdbded078f0fa5b6bbfa782c1dfe9e22b.tar.gz
uGFX-d15c63abdbded078f0fa5b6bbfa782c1dfe9e22b.tar.bz2
uGFX-d15c63abdbded078f0fa5b6bbfa782c1dfe9e22b.zip
Any visible window that obscures another window now prevents the underlying window from receiving mouse event.
Diffstat (limited to 'src')
-rw-r--r--src/gwin/gwidget.c43
1 files changed, 25 insertions, 18 deletions
diff --git a/src/gwin/gwidget.c b/src/gwin/gwidget.c
index a2e6f472..c9fff50e 100644
--- a/src/gwin/gwidget.c
+++ b/src/gwin/gwidget.c
@@ -86,6 +86,7 @@ static void gwidgetEvent(void *param, GEvent *pe) {
#define pte ((GEventToggle *)pe)
#define pde ((GEventDial *)pe)
+ GHandle h;
GHandle gh;
#if GFX_USE_GINPUT && (GINPUT_NEED_TOGGLE || GINPUT_NEED_DIAL)
uint16_t role;
@@ -99,32 +100,38 @@ static void gwidgetEvent(void *param, GEvent *pe) {
case GEVENT_MOUSE:
case GEVENT_TOUCH:
// Cycle through all windows
- for(gh = gwinGetNextWindow(0); gh; gh = gwinGetNextWindow(gh)) {
-
- // check if the widget matches this display
- if (gh->display != pme->display)
- continue;
+ for(gh = 0, h = gwinGetNextWindow(0); h; h = gwinGetNextWindow(h)) {
- // check if it is a widget that is enabled and visible
- if ((gh->flags & (GWIN_FLG_WIDGET|GWIN_FLG_SYSENABLED|GWIN_FLG_SYSVISIBLE)) != (GWIN_FLG_WIDGET|GWIN_FLG_SYSENABLED|GWIN_FLG_SYSVISIBLE))
+ // The window must be on this display and visible to be relevant
+ if (h->display != pme->display || !(h->flags & GWIN_FLG_SYSVISIBLE))
continue;
- // Are we captured?
- if ((gw->g.flags & GWIN_FLG_MOUSECAPTURE)) {
+ // Is the mouse currently captured by this widget?
+ if ((h->flags & (GWIN_FLG_WIDGET|GWIN_FLG_MOUSECAPTURE)) == (GWIN_FLG_WIDGET|GWIN_FLG_MOUSECAPTURE)) {
+ gh = h;
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)
- 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)
- wvmt->MouseMove(gw, pme->x - gw->g.x, pme->y - gw->g.y);
+ wvmt->MouseMove(gw, pme->x - gh->x, pme->y - gh->y);
+
+ // There is only ever one captured mouse. Prevent normal mouse processing if there is a captured mouse
+ gh = 0;
+ break;
+ }
+
+ // 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;
+ }
- // We are not captured - look for mouse downs over the widget
- } else if ((~pme->last_buttons & pme->current_buttons & GINPUT_MOUSE_BTN_LEFT)
- && pme->x >= gw->g.x && pme->x < gw->g.x + gw->g.width
- && pme->y >= gw->g.y && pme->y < gw->g.y + gw->g.height) {
- gw->g.flags |= GWIN_FLG_MOUSECAPTURE;
+ // 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)
- 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;