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
This commit is contained in:
patacongo 2012-05-13 00:45:13 +00:00
parent eac0bdf28a
commit a603b9f689
4 changed files with 65 additions and 46 deletions

View File

@ -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.

View File

@ -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);
}

View File

@ -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
****************************************************************************/

View File

@ -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