From dbda56e617cfde1910ecf6091a76038f44dff65d Mon Sep 17 00:00:00 2001 From: patacongo Date: Fri, 16 Nov 2012 16:49:21 +0000 Subject: Patches 4-6 from Petteri Aimonen git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@5364 42af7a65-404d-4744-a932-0658087f49c3 --- NxWidgets/ChangeLog.txt | 9 +++++--- NxWidgets/nxwm/src/cstartwindow.cxx | 7 +++++- nuttx/ChangeLog | 6 +++++ nuttx/graphics/nxmu/nx_block.c | 2 +- nuttx/graphics/nxmu/nxmu_mouse.c | 44 +++++++++++++++++++++++++++---------- nuttx/graphics/nxsu/nx_mousein.c | 30 ++++++++++++++++++++----- nuttx/graphics/nxtk/nxtk_events.c | 15 +++++++++++-- nuttx/graphics/nxtk/nxtk_internal.h | 5 +++++ 8 files changed, 93 insertions(+), 25 deletions(-) diff --git a/NxWidgets/ChangeLog.txt b/NxWidgets/ChangeLog.txt index dca1f856d..ece08e4fd 100644 --- a/NxWidgets/ChangeLog.txt +++ b/NxWidgets/ChangeLog.txt @@ -198,9 +198,12 @@ This commit adds a simple forward declaration to the relevant files, based on the configured icon. If the icon does not exist, linker will give an error about it. Contributed by Petteri Aimonen. -* NxWidgets/nxwm/src/ctaskbar.cxx: Highlight the current window in the task bar. +* NxWidgets::CTaskBar: Highlight the current window in the task bar. Contributed by Petteri Aimonen. * NxWidgets/libnxwidgets/src/glyph_cycle.cxx: Width of glyph_cycle was wrong; - Desctructor needs to by public. From Petteri Aimonen. -* CNumericEdit. This is basically a label with plus and minus buttons. + Destructor needs to by public. From Petteri Aimonen. +* NxWidgets::CNumericEdit. This is basically a label with plus and minus buttons. Contributed by Petteri, Aimonen. +* NxWM::CStartWindow: Fix mq_receive error handling with signal is recieved. + From Petteri Aimonen. + diff --git a/NxWidgets/nxwm/src/cstartwindow.cxx b/NxWidgets/nxwm/src/cstartwindow.cxx index a99e81d88..cc8802b7c 100644 --- a/NxWidgets/nxwm/src/cstartwindow.cxx +++ b/NxWidgets/nxwm/src/cstartwindow.cxx @@ -654,8 +654,13 @@ int CStartWindow::startWindow(int argc, char *argv[]) { gdbg("ERROR: mq_receive failed: %d\n", errval); } + else + { + gdbg("mq_receive interrupted by signal\n"); + } + + continue; } - while (nbytes < 0); gvdbg("Received msgid=%d nbytes=%d\n", msg.msgId, nbytes); DEBUGASSERT(nbytes = sizeof(struct SStartWindowMessage) && msg.instance); diff --git a/nuttx/ChangeLog b/nuttx/ChangeLog index 72fab8a71..c53f9c891 100644 --- a/nuttx/ChangeLog +++ b/nuttx/ChangeLog @@ -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. diff --git a/nuttx/graphics/nxmu/nx_block.c b/nuttx/graphics/nxmu/nx_block.c index 3a051f9d7..7b198613c 100644 --- a/nuttx/graphics/nxmu/nx_block.c +++ b/nuttx/graphics/nxmu/nx_block.c @@ -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; diff --git a/nuttx/graphics/nxmu/nxmu_mouse.c b/nuttx/graphics/nxmu/nxmu_mouse.c index 3ebe062d2..93441cc01 100644 --- a/nuttx/graphics/nxmu/nxmu_mouse.c +++ b/nuttx/graphics/nxmu/nxmu_mouse.c @@ -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; diff --git a/nuttx/graphics/nxsu/nx_mousein.c b/nuttx/graphics/nxsu/nx_mousein.c index bee4a2265..5b268358b 100644 --- a/nuttx/graphics/nxsu/nx_mousein.c +++ b/nuttx/graphics/nxsu/nx_mousein.c @@ -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; } diff --git a/nuttx/graphics/nxtk/nxtk_events.c b/nuttx/graphics/nxtk/nxtk_events.c index aaec16b5a..facf92176 100644 --- a/nuttx/graphics/nxtk/nxtk_events.c +++ b/nuttx/graphics/nxtk/nxtk_events.c @@ -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); diff --git a/nuttx/graphics/nxtk/nxtk_internal.h b/nuttx/graphics/nxtk/nxtk_internal.h index 87a098845..3a31215d8 100644 --- a/nuttx/graphics/nxtk/nxtk_internal.h +++ b/nuttx/graphics/nxtk/nxtk_internal.h @@ -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; }; /**************************************************************************** -- cgit v1.2.3