summaryrefslogtreecommitdiff
path: root/nuttx/graphics/nxsu
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2012-11-16 16:49:21 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2012-11-16 16:49:21 +0000
commitdbda56e617cfde1910ecf6091a76038f44dff65d (patch)
tree2d8f43731bee5df1d21b090dfa3f4fec008cb16e /nuttx/graphics/nxsu
parentc96506f914b598e59fce7cc9b3c394a5ebe8d23c (diff)
downloadnuttx-dbda56e617cfde1910ecf6091a76038f44dff65d.tar.gz
nuttx-dbda56e617cfde1910ecf6091a76038f44dff65d.tar.bz2
nuttx-dbda56e617cfde1910ecf6091a76038f44dff65d.zip
Patches 4-6 from Petteri Aimonen
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@5364 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/graphics/nxsu')
-rw-r--r--nuttx/graphics/nxsu/nx_mousein.c30
1 files changed, 24 insertions, 6 deletions
diff --git a/nuttx/graphics/nxsu/nx_mousein.c b/nuttx/graphics/nxsu/nx_mousein.c
index bee4a2265..5b268358b 100644
--- a/nuttx/graphics/nxsu/nx_mousein.c
+++ b/nuttx/graphics/nxsu/nx_mousein.c
@@ -62,9 +62,10 @@
* Private Data
****************************************************************************/
-static struct nxgl_point_s g_mpos;
-static struct nxgl_point_s g_mrange;
-static uint8_t g_mbutton;
+static struct nxgl_point_s g_mpos;
+static struct nxgl_point_s g_mrange;
+static uint8_t g_mbutton;
+static struct nxbe_window_s *g_mwnd;
/****************************************************************************
* Public Data
@@ -148,6 +149,7 @@ int nx_mousein(NXHANDLE handle, nxgl_coord_t x, nxgl_coord_t y, uint8_t buttons)
{
FAR struct nxfe_state_s *fe = (FAR struct nxfe_state_s *)handle;
struct nxbe_window_s *wnd;
+ uint8_t oldbuttons;
int ret;
/* Clip x and y to within the bounding rectangle */
@@ -176,13 +178,27 @@ int nx_mousein(NXHANDLE handle, nxgl_coord_t x, nxgl_coord_t y, uint8_t buttons)
{
/* Update the mouse value */
+ oldbuttons = g_mbutton;
g_mpos.x = x;
g_mpos.y = y;
g_mbutton = buttons;
- /* Pick the window to receive the mouse event. Start with
- * the top window and go down. Step with the first window
- * that gets the mouse report
+ /* If a button is already down, regard this as part of a mouse drag
+ * event. Pass all the following events to the window where the drag
+ * started in.
+ */
+
+ if (oldbuttons && g_mwnd && g_mwnd->cb->mousein)
+ {
+ struct nxgl_point_s relpos;
+ nxgl_vectsubtract(&relpos, &g_mpos, &g_mwnd->bounds.pt1);
+ g_mwnd->cb->mousein((NXWINDOW)g_mwnd, &relpos, g_mbutton, g_mwnd->arg);
+ return OK;
+ }
+
+ /* Pick the window to receive the mouse event. Start with the top
+ * window and go down. Step with the first window that gets the mouse
+ * report
*/
for (wnd = fe->be.topwnd; wnd; wnd = wnd->below)
@@ -193,6 +209,8 @@ int nx_mousein(NXHANDLE handle, nxgl_coord_t x, nxgl_coord_t y, uint8_t buttons)
break;
}
}
+
+ g_mwnd = wnd;
}
return OK;
}