diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2012-05-13 00:45:13 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2012-05-13 00:45:13 +0000 |
commit | dddc850bfc8afdd0fb6e02d1541636931abaa70a (patch) | |
tree | 19477eacf939b2457a9547b9a70d6925ec9223eb /nuttx/graphics | |
parent | cb492203382e21b52dce512d70efb487715392df (diff) | |
download | px4-nuttx-dddc850bfc8afdd0fb6e02d1541636931abaa70a.tar.gz px4-nuttx-dddc850bfc8afdd0fb6e02d1541636931abaa70a.tar.bz2 px4-nuttx-dddc850bfc8afdd0fb6e02d1541636931abaa70a.zip |
Fix a critical NXTK bug related to mouse/touchscreen positions within framed windows
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4728 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/graphics')
-rw-r--r-- | nuttx/graphics/nxtk/nxtk_events.c | 22 | ||||
-rw-r--r-- | nuttx/graphics/nxtk/nxtk_internal.h | 42 |
2 files changed, 18 insertions, 46 deletions
diff --git a/nuttx/graphics/nxtk/nxtk_events.c b/nuttx/graphics/nxtk/nxtk_events.c index 7b081ec77..4451b13be 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 763b1bfe8..87a098845 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 ****************************************************************************/ |