mirror of
https://github.com/apache/nuttx.git
synced 2025-01-13 08:38:38 +08:00
Only provide mouse input if mouse is in window
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@1374 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
parent
ab44f107d3
commit
c16178c20d
2 changed files with 34 additions and 10 deletions
|
@ -106,16 +106,30 @@ void nxmu_mousereport(struct nxbe_window_s *wnd)
|
|||
struct nxclimsg_mousein_s outmsg;
|
||||
int ret;
|
||||
|
||||
outmsg.msgid = NX_CLIMSG_MOUSEIN;
|
||||
outmsg.wnd = wnd;
|
||||
outmsg.pos.x = g_mpos.x;
|
||||
outmsg.pos.y = g_mpos.y;
|
||||
outmsg.buttons = g_mbutton;
|
||||
/* Does this window support mouse callbacks? */
|
||||
|
||||
ret = mq_send(wnd->conn->swrmq, outmsg, sizeof(struct nxclimsg_mousein_s), NX_SVRMSG_PRIO);
|
||||
if (ret < 0)
|
||||
if (win->cb->mousein)
|
||||
{
|
||||
gdbg("mq_send failed: %d\n", errno);
|
||||
/* Yes.. Does the mount position lie within the window? */
|
||||
|
||||
if (nxgl_rectinside(wnd->bounds, g_mpos))
|
||||
{
|
||||
/* Yes... Convert the mouse position to window relative
|
||||
* coordinates and send it to the client
|
||||
*/
|
||||
|
||||
outmsg.msgid = NX_CLIMSG_MOUSEIN;
|
||||
outmsg.wnd = wnd;
|
||||
outmsg.buttons = g_mbutton;
|
||||
nxgl_vectsubtract(&outmsg.pos, g_mpos, wnd->origin);
|
||||
|
||||
ret = mq_send(wnd->conn->swrmq, outmsg,
|
||||
sizeof(struct nxclimsg_mousein_s), NX_SVRMSG_PRIO);
|
||||
if (ret < 0)
|
||||
{
|
||||
gdbg("mq_send failed: %d\n", errno);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -103,11 +103,21 @@ void nxsu_mouseinit(int x, int y)
|
|||
|
||||
void nxsu_mousereport(struct nxbe_window_s *wnd)
|
||||
{
|
||||
/* Give the keypad event only to the top child */
|
||||
struct nxgl_point_s relpos;
|
||||
|
||||
/* Does this window support mouse callbacks? */
|
||||
|
||||
if (win->cb->mousein)
|
||||
{
|
||||
win->cb->mousein((NXWINDOW)wnd, &g_mpos, g_mbutton, wnd->arg);
|
||||
/* Yes.. Does the mount position lie within the window? */
|
||||
|
||||
if (nxgl_rectinside(wnd->bounds, g_mpos))
|
||||
{
|
||||
/* Yes... Convert the mouse position to window relative coordinates */
|
||||
|
||||
nxgl_vectsubtract(&relpos, g_mpos, wnd->origin);
|
||||
win->cb->mousein((NXWINDOW)wnd, &relpos, g_mbutton, wnd->arg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue