summaryrefslogtreecommitdiff
path: root/nuttx/graphics/nxmu/nxmu_mouse.c
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2008-12-01 16:33:44 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2008-12-01 16:33:44 +0000
commit8b2dc49a9d4b3fb69c3db170f6b6a87f0f4505f3 (patch)
treea8d62053a8b0c80dc2f0a283aee91ca983e7dc2a /nuttx/graphics/nxmu/nxmu_mouse.c
parent814adbc7cee2a5b90a89a9f9b94a6dd2c1fed31d (diff)
downloadpx4-nuttx-8b2dc49a9d4b3fb69c3db170f6b6a87f0f4505f3.tar.gz
px4-nuttx-8b2dc49a9d4b3fb69c3db170f6b6a87f0f4505f3.tar.bz2
px4-nuttx-8b2dc49a9d4b3fb69c3db170f6b6a87f0f4505f3.zip
Only provide mouse input if mouse is in window
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@1374 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/graphics/nxmu/nxmu_mouse.c')
-rw-r--r--nuttx/graphics/nxmu/nxmu_mouse.c32
1 files changed, 23 insertions, 9 deletions
diff --git a/nuttx/graphics/nxmu/nxmu_mouse.c b/nuttx/graphics/nxmu/nxmu_mouse.c
index 5650c8dd2..922b12c93 100644
--- a/nuttx/graphics/nxmu/nxmu_mouse.c
+++ b/nuttx/graphics/nxmu/nxmu_mouse.c
@@ -106,16 +106,30 @@ void nxmu_mousereport(struct nxbe_window_s *wnd)
struct nxclimsg_mousein_s outmsg;
int ret;
- outmsg.msgid = NX_CLIMSG_MOUSEIN;
- outmsg.wnd = wnd;
- outmsg.pos.x = g_mpos.x;
- outmsg.pos.y = g_mpos.y;
- outmsg.buttons = g_mbutton;
-
- ret = mq_send(wnd->conn->swrmq, outmsg, sizeof(struct nxclimsg_mousein_s), NX_SVRMSG_PRIO);
- if (ret < 0)
+ /* Does this window support mouse callbacks? */
+
+ if (win->cb->mousein)
{
- gdbg("mq_send failed: %d\n", errno);
+ /* Yes.. Does the mount position lie within the window? */
+
+ if (nxgl_rectinside(wnd->bounds, g_mpos))
+ {
+ /* Yes... Convert the mouse position to window relative
+ * coordinates and send it to the client
+ */
+
+ outmsg.msgid = NX_CLIMSG_MOUSEIN;
+ outmsg.wnd = wnd;
+ outmsg.buttons = g_mbutton;
+ nxgl_vectsubtract(&outmsg.pos, g_mpos, wnd->origin);
+
+ ret = mq_send(wnd->conn->swrmq, outmsg,
+ sizeof(struct nxclimsg_mousein_s), NX_SVRMSG_PRIO);
+ if (ret < 0)
+ {
+ gdbg("mq_send failed: %d\n", errno);
+ }
+ }
}
}