diff options
author | patacongo <patacongo@7fd9a85b-ad96-42d3-883c-3090e2eb8679> | 2012-05-13 00:45:13 +0000 |
---|---|---|
committer | patacongo <patacongo@7fd9a85b-ad96-42d3-883c-3090e2eb8679> | 2012-05-13 00:45:13 +0000 |
commit | 6798ffe9be77f8ca18352e1c0f36fd59cb414d2b (patch) | |
tree | 19477eacf939b2457a9547b9a70d6925ec9223eb /nuttx | |
parent | e16fc112d83924fb75ff874b19119a9c38419461 (diff) | |
download | px4-firmware-6798ffe9be77f8ca18352e1c0f36fd59cb414d2b.tar.gz px4-firmware-6798ffe9be77f8ca18352e1c0f36fd59cb414d2b.tar.bz2 px4-firmware-6798ffe9be77f8ca18352e1c0f36fd59cb414d2b.zip |
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/ChangeLog | 6 | ||||
-rw-r--r-- | nuttx/graphics/nxtk/nxtk_events.c | 22 | ||||
-rw-r--r-- | nuttx/graphics/nxtk/nxtk_internal.h | 42 | ||||
-rw-r--r-- | nuttx/include/nuttx/nx/nxtk.h | 41 |
4 files changed, 65 insertions, 46 deletions
diff --git a/nuttx/ChangeLog b/nuttx/ChangeLog index 4b5ab66d0..42ab7ec85 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 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 ****************************************************************************/ diff --git a/nuttx/include/nuttx/nx/nxtk.h b/nuttx/include/nuttx/nx/nxtk.h index 8bf711f26..00bce82e6 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 |