summaryrefslogtreecommitdiffstats
path: root/nuttx
diff options
context:
space:
mode:
authorpatacongo <patacongo@7fd9a85b-ad96-42d3-883c-3090e2eb8679>2012-05-13 00:45:13 +0000
committerpatacongo <patacongo@7fd9a85b-ad96-42d3-883c-3090e2eb8679>2012-05-13 00:45:13 +0000
commitcfc06967c723a3eef528c8ff97e0d70727af8cef (patch)
tree19477eacf939b2457a9547b9a70d6925ec9223eb /nuttx
parent6d8f308798bbe7c3707142d798dac497f31a5371 (diff)
Fix a critical NXTK bug related to mouse/touchscreen positions within framed windows
git-svn-id: https://nuttx.svn.sourceforge.net/svnroot/nuttx/trunk@4728 7fd9a85b-ad96-42d3-883c-3090e2eb8679
Diffstat (limited to 'nuttx')
-rw-r--r--nuttx/ChangeLog6
-rw-r--r--nuttx/graphics/nxtk/nxtk_events.c22
-rw-r--r--nuttx/graphics/nxtk/nxtk_internal.h42
-rw-r--r--nuttx/include/nuttx/nx/nxtk.h41
4 files changed, 65 insertions, 46 deletions
diff --git a/nuttx/ChangeLog b/nuttx/ChangeLog
index 4b5ab66d09..42ab7ec854 100644
--- a/nuttx/ChangeLog
+++ b/nuttx/ChangeLog
@@ -2741,3 +2741,9 @@
the worker thread, disabling interrupts does not provide protected; Need to
disable pre-emption. (2) Fix handling of touch ID and (2) add some logic to
prevent certain kinds of data overrun.
+ * include/nx/nxtk.h and graphics/nx/nxtk/nxtk_internal.h: Move setting
+ of configuration defaults from the internal header file to a place where
+ other logic can use the defaults.
+ * graphics/nxtk/nxtk_events.c: Fixed an important but in the logic that
+ translates the mouse/touchscreen position data for framed windows and toolbars.
+
diff --git a/nuttx/graphics/nxtk/nxtk_events.c b/nuttx/graphics/nxtk/nxtk_events.c
index 7b081ec77b..4451b13be4 100644
--- a/nuttx/graphics/nxtk/nxtk_events.c
+++ b/nuttx/graphics/nxtk/nxtk_events.c
@@ -217,21 +217,35 @@ static void nxtk_mousein(NXWINDOW hwnd, FAR const struct nxgl_point_s *pos,
uint8_t buttons, FAR void *arg)
{
FAR struct nxtk_framedwindow_s *fwnd = (FAR struct nxtk_framedwindow_s *)hwnd;
+ struct nxgl_point_s abspos;
struct nxgl_point_s relpos;
+ /* When we get here, the mouse position that we receive has already been
+ * offset by the window origin. Here we need to detect mouse events in
+ * the various regions of the windows: The toolbar, the client window,
+ * or the frame. And then offset the position accordingly.
+ */
+
+ /* The fwrect and tbrect boxes are both in absolute display coordinates. So
+ * the easiest thing to do is to restore the mouse position to absolute
+ * display coordiantes before making the comparisons and adjustments.
+ */
+
+ nxgl_vectoradd(&abspos, pos, &fwnd->wnd.bounds.pt1);
+
/* Is the mouse position inside of the client window region? */
- if (fwnd->fwcb->mousein && nxgl_rectinside(&fwnd->fwrect, pos))
+ if (fwnd->fwcb->mousein && nxgl_rectinside(&fwnd->fwrect, &abspos))
{
- nxgl_vectsubtract(&relpos, pos, &fwnd->fwrect.pt1);
+ nxgl_vectsubtract(&relpos, &abspos, &fwnd->fwrect.pt1);
fwnd->fwcb->mousein((NXTKWINDOW)fwnd, &relpos, buttons, fwnd->fwarg);
}
/* If the mouse position inside the toobar region? */
- else if (fwnd->tbcb->mousein && nxgl_rectinside(&fwnd->tbrect, pos))
+ else if (fwnd->tbcb->mousein && nxgl_rectinside(&fwnd->tbrect, &abspos))
{
- nxgl_vectsubtract(&relpos, pos, &fwnd->tbrect.pt1);
+ 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 763b1bfe8b..87a098845a 100644
--- a/nuttx/graphics/nxtk/nxtk_internal.h
+++ b/nuttx/graphics/nxtk/nxtk_internal.h
@@ -50,48 +50,6 @@
* Pre-processor definitions
****************************************************************************/
-/* Configuration ************************************************************/
-
-#ifndef CONFIG_NXTK_BORDERWIDTH
-# define CONFIG_NXTK_BORDERWIDTH 4
-#endif
-
-#ifndef CONFIG_NXTK_BORDERCOLOR1
-# if !defined(CONFIG_NX_DISABLE_32BPP) || !defined(CONFIG_NX_DISABLE_24BPP)
-# define CONFIG_NXTK_BORDERCOLOR1 0x00a9a9a9
-# elif !defined(CONFIG_NX_DISABLE_16BPP)
-# define CONFIG_NXTK_BORDERCOLOR1 0xad55
-# elif !defined(CONFIG_NX_DISABLE_4BPP)
-# define CONFIG_NXTK_BORDERCOLOR1 6
-# else
-# define CONFIG_NXTK_BORDERCOLOR1 'B'
-# endif
-#endif
-
-#ifndef CONFIG_NXTK_BORDERCOLOR2
-# if !defined(CONFIG_NX_DISABLE_32BPP) || !defined(CONFIG_NX_DISABLE_24BPP)
-# define CONFIG_NXTK_BORDERCOLOR2 0x00696969
-# elif !defined(CONFIG_NX_DISABLE_16BPP)
-# define CONFIG_NXTK_BORDERCOLOR2 0x6b4d
-# elif !defined(CONFIG_NX_DISABLE_4BPP)
-# define CONFIG_NXTK_BORDERCOLOR2 4
-# else
-# define CONFIG_NXTK_BORDERCOLOR2 'b'
-# endif
-#endif
-
-#ifndef CONFIG_NXTK_BORDERCOLOR3
-# if !defined(CONFIG_NX_DISABLE_32BPP) || !defined(CONFIG_NX_DISABLE_24BPP)
-# define CONFIG_NXTK_BORDERCOLOR3 0x00d9d9d9
-# elif !defined(CONFIG_NX_DISABLE_16BPP)
-# define CONFIG_NXTK_BORDERCOLOR3 0xdedb
-# elif !defined(CONFIG_NX_DISABLE_4BPP)
-# define CONFIG_NXTK_BORDERCOLOR3 8
-# else
-# define CONFIG_NXTK_BORDERCOLOR3 'S'
-# endif
-#endif
-
/****************************************************************************
* Public Types
****************************************************************************/
diff --git a/nuttx/include/nuttx/nx/nxtk.h b/nuttx/include/nuttx/nx/nxtk.h
index 8bf711f264..00bce82e69 100644
--- a/nuttx/include/nuttx/nx/nxtk.h
+++ b/nuttx/include/nuttx/nx/nxtk.h
@@ -47,6 +47,47 @@
/****************************************************************************
* Pre-processor definitions
****************************************************************************/
+/* Configuration ************************************************************/
+
+#ifndef CONFIG_NXTK_BORDERWIDTH
+# define CONFIG_NXTK_BORDERWIDTH 4
+#endif
+
+#ifndef CONFIG_NXTK_BORDERCOLOR1
+# if !defined(CONFIG_NX_DISABLE_32BPP) || !defined(CONFIG_NX_DISABLE_24BPP)
+# define CONFIG_NXTK_BORDERCOLOR1 0x00a9a9a9
+# elif !defined(CONFIG_NX_DISABLE_16BPP)
+# define CONFIG_NXTK_BORDERCOLOR1 0xad55
+# elif !defined(CONFIG_NX_DISABLE_4BPP)
+# define CONFIG_NXTK_BORDERCOLOR1 6
+# else
+# define CONFIG_NXTK_BORDERCOLOR1 'B'
+# endif
+#endif
+
+#ifndef CONFIG_NXTK_BORDERCOLOR2
+# if !defined(CONFIG_NX_DISABLE_32BPP) || !defined(CONFIG_NX_DISABLE_24BPP)
+# define CONFIG_NXTK_BORDERCOLOR2 0x00696969
+# elif !defined(CONFIG_NX_DISABLE_16BPP)
+# define CONFIG_NXTK_BORDERCOLOR2 0x6b4d
+# elif !defined(CONFIG_NX_DISABLE_4BPP)
+# define CONFIG_NXTK_BORDERCOLOR2 4
+# else
+# define CONFIG_NXTK_BORDERCOLOR2 'b'
+# endif
+#endif
+
+#ifndef CONFIG_NXTK_BORDERCOLOR3
+# if !defined(CONFIG_NX_DISABLE_32BPP) || !defined(CONFIG_NX_DISABLE_24BPP)
+# define CONFIG_NXTK_BORDERCOLOR3 0x00d9d9d9
+# elif !defined(CONFIG_NX_DISABLE_16BPP)
+# define CONFIG_NXTK_BORDERCOLOR3 0xdedb
+# elif !defined(CONFIG_NX_DISABLE_4BPP)
+# define CONFIG_NXTK_BORDERCOLOR3 8
+# else
+# define CONFIG_NXTK_BORDERCOLOR3 'S'
+# endif
+#endif
/****************************************************************************
* Public Types