Patches 4-6 from Petteri Aimonen
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@5364 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
parent
35e380ac6d
commit
39ce8b1fab
@ -3635,4 +3635,10 @@
|
||||
* Config.mk: Defined DELIM to be either / or \, depending upon
|
||||
CONFIG_WINDOWS_NATIVE. This will allow me to eliminate a lot of
|
||||
conditional logic elsewhere.
|
||||
* nuttx/graphics: One a mouse button is pressed, continue to report all
|
||||
mouse button events to the first window that received the the initial
|
||||
button down event, even if the mouse attempts to dray outside the
|
||||
window. From Petteri Aimonen.
|
||||
* nuttx/graphics/nxmu/nx_block.c: One more fixe to the NX block message
|
||||
logic from Petteri Aimonen.
|
||||
|
||||
|
@ -140,7 +140,7 @@ int nx_block(NXWINDOW hwnd, FAR void *arg)
|
||||
* that it will not be blocked.
|
||||
*/
|
||||
|
||||
ret = nxmu_sendserver(wnd->conn, &outmsg, sizeof(struct nxbe_window_s));
|
||||
ret = nxmu_sendserver(wnd->conn, &outmsg, sizeof(struct nxsvrmsg_blocked_s));
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
@ -61,9 +61,10 @@
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
static struct nxgl_point_s g_mpos;
|
||||
static struct nxgl_point_s g_mrange;
|
||||
static uint8_t g_mbutton;
|
||||
static struct nxgl_point_s g_mpos;
|
||||
static struct nxgl_point_s g_mrange;
|
||||
static uint8_t g_mbutton;
|
||||
static struct nxbe_window_s *g_mwnd;
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
@ -154,6 +155,7 @@ int nxmu_mousein(FAR struct nxfe_state_s *fe,
|
||||
struct nxbe_window_s *wnd;
|
||||
nxgl_coord_t x = pos->x;
|
||||
nxgl_coord_t y = pos->y;
|
||||
uint8_t oldbuttons;
|
||||
int ret;
|
||||
|
||||
/* Clip x and y to within the bounding rectangle */
|
||||
@ -182,20 +184,36 @@ int nxmu_mousein(FAR struct nxfe_state_s *fe,
|
||||
{
|
||||
/* Update the mouse value */
|
||||
|
||||
g_mpos.x = x;
|
||||
g_mpos.y = y;
|
||||
g_mbutton = buttons;
|
||||
oldbuttons = g_mbutton;
|
||||
g_mpos.x = x;
|
||||
g_mpos.y = y;
|
||||
g_mbutton = buttons;
|
||||
|
||||
/* Pick the window to receive the mouse event. Start with
|
||||
* the top window and go down. Stop with the first window
|
||||
* that gets the mouse report
|
||||
/* If a button is already down, regard this as part of a mouse drag
|
||||
* event. Pass all the following events to the window where the drag
|
||||
* started in.
|
||||
*/
|
||||
|
||||
if (oldbuttons && g_mwnd && g_mwnd->cb->mousein)
|
||||
{
|
||||
struct nxclimsg_mousein_s outmsg;
|
||||
outmsg.msgid = NX_CLIMSG_MOUSEIN;
|
||||
outmsg.wnd = g_mwnd;
|
||||
outmsg.buttons = g_mbutton;
|
||||
nxgl_vectsubtract(&outmsg.pos, &g_mpos, &g_mwnd->bounds.pt1);
|
||||
|
||||
return nxmu_sendclient(g_mwnd->conn, &outmsg, sizeof(struct nxclimsg_mousein_s));
|
||||
}
|
||||
|
||||
/* Pick the window to receive the mouse event. Start with the top
|
||||
* window and go down. Stop with the first window that gets the mouse
|
||||
* report
|
||||
*/
|
||||
|
||||
for (wnd = fe->be.topwnd; wnd; wnd = wnd->below)
|
||||
{
|
||||
/* The background window normally has no callback structure
|
||||
* (unless a client has taken control of the background via
|
||||
* nx_requestbkgd()).
|
||||
/* The background window normally has no callback structure (unless
|
||||
* a client has taken control of the background via nx_requestbkgd()).
|
||||
*/
|
||||
|
||||
if (wnd->cb)
|
||||
@ -207,6 +225,8 @@ int nxmu_mousein(FAR struct nxfe_state_s *fe,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
g_mwnd = wnd;
|
||||
}
|
||||
|
||||
return OK;
|
||||
|
@ -62,9 +62,10 @@
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
static struct nxgl_point_s g_mpos;
|
||||
static struct nxgl_point_s g_mrange;
|
||||
static uint8_t g_mbutton;
|
||||
static struct nxgl_point_s g_mpos;
|
||||
static struct nxgl_point_s g_mrange;
|
||||
static uint8_t g_mbutton;
|
||||
static struct nxbe_window_s *g_mwnd;
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
@ -148,6 +149,7 @@ int nx_mousein(NXHANDLE handle, nxgl_coord_t x, nxgl_coord_t y, uint8_t buttons)
|
||||
{
|
||||
FAR struct nxfe_state_s *fe = (FAR struct nxfe_state_s *)handle;
|
||||
struct nxbe_window_s *wnd;
|
||||
uint8_t oldbuttons;
|
||||
int ret;
|
||||
|
||||
/* Clip x and y to within the bounding rectangle */
|
||||
@ -176,13 +178,27 @@ int nx_mousein(NXHANDLE handle, nxgl_coord_t x, nxgl_coord_t y, uint8_t buttons)
|
||||
{
|
||||
/* Update the mouse value */
|
||||
|
||||
oldbuttons = g_mbutton;
|
||||
g_mpos.x = x;
|
||||
g_mpos.y = y;
|
||||
g_mbutton = buttons;
|
||||
|
||||
/* Pick the window to receive the mouse event. Start with
|
||||
* the top window and go down. Step with the first window
|
||||
* that gets the mouse report
|
||||
/* If a button is already down, regard this as part of a mouse drag
|
||||
* event. Pass all the following events to the window where the drag
|
||||
* started in.
|
||||
*/
|
||||
|
||||
if (oldbuttons && g_mwnd && g_mwnd->cb->mousein)
|
||||
{
|
||||
struct nxgl_point_s relpos;
|
||||
nxgl_vectsubtract(&relpos, &g_mpos, &g_mwnd->bounds.pt1);
|
||||
g_mwnd->cb->mousein((NXWINDOW)g_mwnd, &relpos, g_mbutton, g_mwnd->arg);
|
||||
return OK;
|
||||
}
|
||||
|
||||
/* Pick the window to receive the mouse event. Start with the top
|
||||
* window and go down. Step with the first window that gets the mouse
|
||||
* report
|
||||
*/
|
||||
|
||||
for (wnd = fe->be.topwnd; wnd; wnd = wnd->below)
|
||||
@ -193,6 +209,8 @@ int nx_mousein(NXHANDLE handle, nxgl_coord_t x, nxgl_coord_t y, uint8_t buttons)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
g_mwnd = wnd;
|
||||
}
|
||||
return OK;
|
||||
}
|
||||
|
@ -261,9 +261,20 @@ static void nxtk_mousein(NXWINDOW hwnd, FAR const struct nxgl_point_s *pos,
|
||||
|
||||
nxgl_vectoradd(&abspos, pos, &fwnd->wnd.bounds.pt1);
|
||||
|
||||
/* In order to deliver mouse release events to the same window where the
|
||||
* mouse down event happened, we store the initial mouse down location.
|
||||
*/
|
||||
|
||||
if (fwnd->mbutton == 0 && buttons != 0)
|
||||
{
|
||||
fwnd->mpos = abspos;
|
||||
}
|
||||
|
||||
fwnd->mbutton = buttons;
|
||||
|
||||
/* Is the mouse position inside of the client window region? */
|
||||
|
||||
if (fwnd->fwcb->mousein && nxgl_rectinside(&fwnd->fwrect, &abspos))
|
||||
if (fwnd->fwcb->mousein && nxgl_rectinside(&fwnd->fwrect, &fwnd->mpos))
|
||||
{
|
||||
nxgl_vectsubtract(&relpos, &abspos, &fwnd->fwrect.pt1);
|
||||
fwnd->fwcb->mousein((NXTKWINDOW)fwnd, &relpos, buttons, fwnd->fwarg);
|
||||
@ -271,7 +282,7 @@ static void nxtk_mousein(NXWINDOW hwnd, FAR const struct nxgl_point_s *pos,
|
||||
|
||||
/* If the mouse position inside the toobar region? */
|
||||
|
||||
else if (fwnd->tbcb->mousein && nxgl_rectinside(&fwnd->tbrect, &abspos))
|
||||
else if (fwnd->tbcb->mousein && nxgl_rectinside(&fwnd->tbrect, &fwnd->mpos))
|
||||
{
|
||||
nxgl_vectsubtract(&relpos, &abspos, &fwnd->tbrect.pt1);
|
||||
fwnd->tbcb->mousein((NXTKWINDOW)fwnd, &relpos, buttons, fwnd->tbarg);
|
||||
|
@ -72,6 +72,11 @@ struct nxtk_framedwindow_s
|
||||
struct nxgl_rect_s fwrect;
|
||||
FAR const struct nx_callback_s *fwcb;
|
||||
FAR void *fwarg;
|
||||
|
||||
/* Initial mouse down location */
|
||||
|
||||
uint8_t mbutton;
|
||||
struct nxgl_point_s mpos;
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
|
Loading…
Reference in New Issue
Block a user