aboutsummaryrefslogtreecommitdiff
path: root/nuttx/graphics
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
commit0ac67b46fba7412d7bfaf999108af5a9c409f1f5 (patch)
tree2d8f43731bee5df1d21b090dfa3f4fec008cb16e /nuttx/graphics
parent48247aa52fa3d5d88f01db31d82f941526876d6e (diff)
downloadpx4-firmware-0ac67b46fba7412d7bfaf999108af5a9c409f1f5.tar.gz
px4-firmware-0ac67b46fba7412d7bfaf999108af5a9c409f1f5.tar.bz2
px4-firmware-0ac67b46fba7412d7bfaf999108af5a9c409f1f5.zip
Patches 4-6 from Petteri Aimonen
git-svn-id: http://svn.code.sf.net/p/nuttx/code/trunk@5364 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/graphics')
-rw-r--r--nuttx/graphics/nxmu/nx_block.c2
-rw-r--r--nuttx/graphics/nxmu/nxmu_mouse.c44
-rw-r--r--nuttx/graphics/nxsu/nx_mousein.c30
-rw-r--r--nuttx/graphics/nxtk/nxtk_events.c15
-rw-r--r--nuttx/graphics/nxtk/nxtk_internal.h5
5 files changed, 75 insertions, 21 deletions
diff --git a/nuttx/graphics/nxmu/nx_block.c b/nuttx/graphics/nxmu/nx_block.c
index 3a051f9d7..7b198613c 100644
--- a/nuttx/graphics/nxmu/nx_block.c
+++ b/nuttx/graphics/nxmu/nx_block.c
@@ -140,7 +140,7 @@ int nx_block(NXWINDOW hwnd, FAR void *arg)
* that it will not be blocked.
*/
- ret = nxmu_sendserver(wnd->conn, &outmsg, sizeof(struct nxbe_window_s));
+ ret = nxmu_sendserver(wnd->conn, &outmsg, sizeof(struct nxsvrmsg_blocked_s));
}
return ret;
diff --git a/nuttx/graphics/nxmu/nxmu_mouse.c b/nuttx/graphics/nxmu/nxmu_mouse.c
index 3ebe062d2..93441cc01 100644
--- a/nuttx/graphics/nxmu/nxmu_mouse.c
+++ b/nuttx/graphics/nxmu/nxmu_mouse.c
@@ -61,9 +61,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
@@ -154,6 +155,7 @@ int nxmu_mousein(FAR struct nxfe_state_s *fe,
struct nxbe_window_s *wnd;
nxgl_coord_t x = pos->x;
nxgl_coord_t y = pos->y;
+ uint8_t oldbuttons;
int ret;
/* Clip x and y to within the bounding rectangle */
@@ -182,20 +184,36 @@ int nxmu_mousein(FAR struct nxfe_state_s *fe,
{
/* Update the mouse value */
- g_mpos.x = x;
- g_mpos.y = y;
- g_mbutton = buttons;
+ 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. Stop 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 nxclimsg_mousein_s outmsg;
+ outmsg.msgid = NX_CLIMSG_MOUSEIN;
+ outmsg.wnd = g_mwnd;
+ outmsg.buttons = g_mbutton;
+ nxgl_vectsubtract(&outmsg.pos, &g_mpos, &g_mwnd->bounds.pt1);
+
+ return nxmu_sendclient(g_mwnd->conn, &outmsg, sizeof(struct nxclimsg_mousein_s));
+ }
+
+ /* Pick the window to receive the mouse event. Start with the top
+ * window and go down. Stop with the first window that gets the mouse
+ * report
*/
for (wnd = fe->be.topwnd; wnd; wnd = wnd->below)
{
- /* The background window normally has no callback structure
- * (unless a client has taken control of the background via
- * nx_requestbkgd()).
+ /* The background window normally has no callback structure (unless
+ * a client has taken control of the background via nx_requestbkgd()).
*/
if (wnd->cb)
@@ -207,6 +225,8 @@ int nxmu_mousein(FAR struct nxfe_state_s *fe,
}
}
}
+
+ g_mwnd = wnd;
}
return OK;
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;
}
diff --git a/nuttx/graphics/nxtk/nxtk_events.c b/nuttx/graphics/nxtk/nxtk_events.c
index aaec16b5a..facf92176 100644
--- a/nuttx/graphics/nxtk/nxtk_events.c
+++ b/nuttx/graphics/nxtk/nxtk_events.c
@@ -261,9 +261,20 @@ static void nxtk_mousein(NXWINDOW hwnd, FAR const struct nxgl_point_s *pos,
nxgl_vectoradd(&abspos, pos, &fwnd->wnd.bounds.pt1);
+ /* In order to deliver mouse release events to the same window where the
+ * mouse down event happened, we store the initial mouse down location.
+ */
+
+ if (fwnd->mbutton == 0 && buttons != 0)
+ {
+ fwnd->mpos = abspos;
+ }
+
+ fwnd->mbutton = buttons;
+
/* Is the mouse position inside of the client window region? */
- if (fwnd->fwcb->mousein && nxgl_rectinside(&fwnd->fwrect, &abspos))
+ if (fwnd->fwcb->mousein && nxgl_rectinside(&fwnd->fwrect, &fwnd->mpos))
{
nxgl_vectsubtract(&relpos, &abspos, &fwnd->fwrect.pt1);
fwnd->fwcb->mousein((NXTKWINDOW)fwnd, &relpos, buttons, fwnd->fwarg);
@@ -271,7 +282,7 @@ static void nxtk_mousein(NXWINDOW hwnd, FAR const struct nxgl_point_s *pos,
/* If the mouse position inside the toobar region? */
- else if (fwnd->tbcb->mousein && nxgl_rectinside(&fwnd->tbrect, &abspos))
+ else if (fwnd->tbcb->mousein && nxgl_rectinside(&fwnd->tbrect, &fwnd->mpos))
{
nxgl_vectsubtract(&relpos, &abspos, &fwnd->tbrect.pt1);
fwnd->tbcb->mousein((NXTKWINDOW)fwnd, &relpos, buttons, fwnd->tbarg);
diff --git a/nuttx/graphics/nxtk/nxtk_internal.h b/nuttx/graphics/nxtk/nxtk_internal.h
index 87a098845..3a31215d8 100644
--- a/nuttx/graphics/nxtk/nxtk_internal.h
+++ b/nuttx/graphics/nxtk/nxtk_internal.h
@@ -72,6 +72,11 @@ struct nxtk_framedwindow_s
struct nxgl_rect_s fwrect;
FAR const struct nx_callback_s *fwcb;
FAR void *fwarg;
+
+ /* Initial mouse down location */
+
+ uint8_t mbutton;
+ struct nxgl_point_s mpos;
};
/****************************************************************************