summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2012-05-17 22:16:02 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2012-05-17 22:16:02 +0000
commitd53035bc78b3fbbd640a6a7535b9cdf7ca0d9667 (patch)
tree166f99f4788c23b3649826405468b34f475d4726
parentb1bbea743d6eef38eebf9975a3b19bbfb7e71233 (diff)
downloadnuttx-d53035bc78b3fbbd640a6a7535b9cdf7ca0d9667.tar.gz
nuttx-d53035bc78b3fbbd640a6a7535b9cdf7ca0d9667.tar.bz2
nuttx-d53035bc78b3fbbd640a6a7535b9cdf7ca0d9667.zip
Implement an NX interface to block flush message queues in multi-user mode. This is necessary to prevent stale window handles when a window is closed
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4745 42af7a65-404d-4744-a932-0658087f49c3
-rw-r--r--NxWidgets/libnxwidgets/include/ccallback.hxx77
-rw-r--r--NxWidgets/libnxwidgets/include/cwidgetcontrol.hxx25
-rw-r--r--NxWidgets/libnxwidgets/include/cwindoweventhandler.hxx6
-rw-r--r--NxWidgets/libnxwidgets/include/cwindoweventhandlerlist.hxx6
-rw-r--r--NxWidgets/libnxwidgets/src/ccallback.cxx140
-rw-r--r--NxWidgets/libnxwidgets/src/cwindoweventhandlerlist.cxx11
-rw-r--r--nuttx/ChangeLog5
-rw-r--r--nuttx/graphics/nxbe/nxbe.h15
-rw-r--r--nuttx/graphics/nxmu/Make.defs2
-rw-r--r--nuttx/graphics/nxmu/nx_block.c145
-rw-r--r--nuttx/graphics/nxmu/nx_eventhandler.c18
-rw-r--r--nuttx/graphics/nxmu/nxfe.h24
-rw-r--r--nuttx/graphics/nxmu/nxmu_sendclient.c112
-rw-r--r--nuttx/graphics/nxmu/nxmu_sendserver.c112
-rw-r--r--nuttx/graphics/nxmu/nxmu_sendwindow.c114
-rw-r--r--nuttx/graphics/nxmu/nxmu_server.c26
-rw-r--r--nuttx/graphics/nxtk/Make.defs2
-rw-r--r--nuttx/graphics/nxtk/nxtk_block.c107
-rw-r--r--nuttx/include/nuttx/nx/nx.h63
-rw-r--r--nuttx/include/nuttx/nx/nxtk.h33
20 files changed, 959 insertions, 84 deletions
diff --git a/NxWidgets/libnxwidgets/include/ccallback.hxx b/NxWidgets/libnxwidgets/include/ccallback.hxx
index 0e0d5de8b..ca3313a9b 100644
--- a/NxWidgets/libnxwidgets/include/ccallback.hxx
+++ b/NxWidgets/libnxwidgets/include/ccallback.hxx
@@ -99,16 +99,16 @@ namespace NXWidgets
* either be the context of the owning thread or, in the case of multi-
* user NX, the context of the NX event listener thread.
*
- * @param hWindow Handle to a specific NX window.
- * @param pRect The rectangle that needs to be re-drawn (in window
+ * @param hwnd Handle to a specific NX window.
+ * @param rect The rectangle that needs to be re-drawn (in window
* relative coordinates).
* @param bMore true: More re-draw requests will follow.
- * @param pvArg User provided argument (see nx_openwindow, nx_requestbg,
+ * @param arg User provided argument (see nx_openwindow, nx_requestbg,
* nxtk_openwindow, or nxtk_opentoolbar).
*/
- static void redraw(NXHANDLE hWindow, FAR const struct nxgl_rect_s *pRect,
- bool bMore, FAR void *pvArg);
+ static void redraw(NXHANDLE hwnd, FAR const struct nxgl_rect_s *rect,
+ bool bMore, FAR void *arg);
/**
* Position Callback. The new positional data is handled by
@@ -118,19 +118,19 @@ namespace NXWidgets
* either be the context of the owning thread or, in the case of multi-
* user NX, the context of the NX event listener thread.
*
- * @param hWindow Handle to a specific NX window.
- * @param pSize The size of the window.
- * @param pPos The position of the upper left hand corner of the window on
+ * @param hwnd Handle to a specific NX window.
+ * @param size The size of the window.
+ * @param pos The position of the upper left hand corner of the window on
* the overall display.
- * @param pBounds The bounding rectangle that describes the entire display.
- * @param pvArg User provided argument (see nx_openwindow, nx_requestbg,
+ * @param bounds The bounding rectangle that describes the entire display.
+ * @param arg User provided argument (see nx_openwindow, nx_requestbg,
* nxtk_openwindow, or nxtk_opentoolbar).
*/
- static void position(NXHANDLE hWindow, FAR const struct nxgl_size_s *pSize,
- FAR const struct nxgl_point_s *pPos,
- FAR const struct nxgl_rect_s *pBounds,
- FAR void *pvArg);
+ static void position(NXHANDLE hwnd, FAR const struct nxgl_size_s *size,
+ FAR const struct nxgl_point_s *pos,
+ FAR const struct nxgl_rect_s *bounds,
+ FAR void *arg);
/**
* New mouse data is available for the window. The new mouse
@@ -144,16 +144,17 @@ namespace NXWidgets
* The GUI thread is probably sleeping a semaphore, waiting to be
* awakened by a mouse or keyboard event.
*
- * @param hWindow Handle to a specific NX window.
- * @param pPos The (x,y) position of the mouse.
+ * @param hwnd Handle to a specific NX window.
+ * @param pos The (x,y) position of the mouse.
* @param buttons See NX_MOUSE_* definitions.
- * @param pvArg User provided argument (see nx_openwindow, nx_requestbg,
+ * @param arg User provided argument (see nx_openwindow, nx_requestbg,
* nxtk_openwindow, or nxtk_opentoolbar).
*/
#ifdef CONFIG_NX_MOUSE
- static void newMouseEvent(NXHANDLE hWindow, FAR const struct nxgl_point_s *pPos,
- uint8_t buttons, FAR void *pvArg);
+ static void newMouseEvent(NXHANDLE hwnd,
+ FAR const struct nxgl_point_s *pos,
+ uint8_t buttons, FAR void *arg);
#endif /* CONFIG_NX_MOUSE */
/**
@@ -168,27 +169,49 @@ namespace NXWidgets
* The GUI thread is probably sleeping a semaphore, waiting to be
* awakened by a mouse or keyboard event.
*
- * @param hWindow Handle to a specific NX window.
- * @param nCh The number of characters that are available in pStr[].
- * @param pStr The array of characters.
- * @param pvArg User provided argument (see nx_openwindow, nx_requestbg,
+ * @param hwnd Handle to a specific NX window.
+ * @param nCh The number of characters that are available in str[].
+ * @param str The array of characters.
+ * @param arg User provided argument (see nx_openwindow, nx_requestbg,
* nxtk_openwindow, or nxtk_opentoolbar).
*/
#ifdef CONFIG_NX_KBD
- static void newKeyboardEvent(NXHANDLE hWindow, uint8_t nCh, FAR const uint8_t *pStr,
- FAR void *pvArg);
+ static void newKeyboardEvent(NXHANDLE hwnd, uint8_t nCh,
+ FAR const uint8_t *str, FAR void *arg);
#endif // CONFIG_NX_KBD
+ /**
+ * This callback is the response from nx_block (or nxtk_block). Those
+ * blocking interfaces are used to assure that no further messages are
+ * directed to the window. Receipt of the blocked callback signifies
+ * that (1) there are no further pending callbacks and (2) that the
+ * window is now 'defunct' and will receive no further callbacks.
+ *
+ * This callback supports coordinated destruction of a window in multi-
+ * user mode. In multi-use mode, the client window logic must stay
+ * intact until all of the queued callbacks are processed. Then the
+ * window may be safely closed. Closing the window prior with pending
+ * callbacks can lead to bad behavior when the callback is executed.
+ *
+ * @param hwnd. Window handle of the blocked window
+ * @param arg. User provided argument (see nx_openwindow, nx_requestbkgd,
+ * nxtk_openwindow, or nxtk_opentoolbar)
+ */
+
+#ifdef CONFIG_NX_MULTIUSER
+ static void windowBlocked(NXWINDOW hwnd, FAR void *arg);
+#endif
+
public:
/**
* Constructor.
*
- * @param pWidgetControl Control object associated with this window
+ * @param widgetControl Control object associated with this window
*/
- CCallback(CWidgetControl *pWidgetControl);
+ CCallback(CWidgetControl *widgetControl);
/**
* Destructor.
diff --git a/NxWidgets/libnxwidgets/include/cwidgetcontrol.hxx b/NxWidgets/libnxwidgets/include/cwidgetcontrol.hxx
index 757dc1c5b..453cc1115 100644
--- a/NxWidgets/libnxwidgets/include/cwidgetcontrol.hxx
+++ b/NxWidgets/libnxwidgets/include/cwidgetcontrol.hxx
@@ -597,6 +597,31 @@ namespace NXWidgets
#endif
/**
+ * This event is the response from nx_block (or nxtk_block). Those
+ * blocking interfaces are used to assure that no further messages are
+ * directed to the window. Receipt of the blocked callback signifies
+ * that (1) there are no further pending events and (2) that the
+ * window is now 'defunct' and will receive no further events.
+ *
+ * This event supports coordinated destruction of a window in multi-
+ * user mode. In multi-use mode, the client window logic must stay
+ * intact until all of the queued callbacks are processed. Then the
+ * window may be safely closed. Closing the window prior with pending
+ * callbacks can lead to bad behavior when the callback is executed.
+ *
+ * @param hwnd. Window handle of the blocked window
+ * @param arg. User provided argument (see nx_openwindow, nx_requestbkgd,
+ * nxtk_openwindow, or nxtk_opentoolbar)
+ */
+
+#ifdef CONFIG_NX_MULTIUSER
+ inline void windowBlocked(void)
+ {
+ m_eventHandlers.raiseBlockedEvent();
+ }
+#endif
+
+ /**
* This event means that cursor control data is available for the window.
*
* @param cursorControl The cursor control code received.
diff --git a/NxWidgets/libnxwidgets/include/cwindoweventhandler.hxx b/NxWidgets/libnxwidgets/include/cwindoweventhandler.hxx
index 1cea0ba68..c414abadb 100644
--- a/NxWidgets/libnxwidgets/include/cwindoweventhandler.hxx
+++ b/NxWidgets/libnxwidgets/include/cwindoweventhandler.hxx
@@ -105,6 +105,12 @@ namespace NXWidgets
#ifdef CONFIG_NX_KBD
virtual void handleKeyboardEvent(void) { }
#endif
+
+ /**
+ * Handle a NX window blocked event
+ */
+
+ virtual void handleBlockedEvent(void) { }
};
}
diff --git a/NxWidgets/libnxwidgets/include/cwindoweventhandlerlist.hxx b/NxWidgets/libnxwidgets/include/cwindoweventhandlerlist.hxx
index 582805691..d9e17de09 100644
--- a/NxWidgets/libnxwidgets/include/cwindoweventhandlerlist.hxx
+++ b/NxWidgets/libnxwidgets/include/cwindoweventhandlerlist.hxx
@@ -160,6 +160,12 @@ namespace NXWidgets
#ifdef CONFIG_NX_KBD
void raiseKeyboardEvent(void);
#endif
+
+ /**
+ * Raise an NX window blocked event.
+ */
+
+ void raiseBlockedEvent(void);
};
}
diff --git a/NxWidgets/libnxwidgets/src/ccallback.cxx b/NxWidgets/libnxwidgets/src/ccallback.cxx
index 25cb228b3..09dc53a5a 100644
--- a/NxWidgets/libnxwidgets/src/ccallback.cxx
+++ b/NxWidgets/libnxwidgets/src/ccallback.cxx
@@ -60,108 +60,113 @@ using namespace NXWidgets;
/**
* Constructor.
*
- * @param pWidgetControl Control object associated with this window
+ * @param widgetControl Control object associated with this window
*/
-CCallback::CCallback(CWidgetControl *pWidgetControl)
+CCallback::CCallback(CWidgetControl *widgetControl)
{
// Initialize the callback vtable
m_callbacks.redraw = redraw;
m_callbacks.position = position;
+#ifdef CONFIG_NX_MOUSE
m_callbacks.mousein = newMouseEvent;
+#endif
+#ifdef CONFIG_NX_KBD
m_callbacks.kbdin = newKeyboardEvent;
+#endif
+ m_callbacks.blocked = windowBlocked;
}
/**
* ReDraw Callback. The redraw action is handled by CWidgetControl:redrawEvent.
*
- * @param hWindow Handle to a specific NX window.
- * @param pRect The rectangle that needs to be re-drawn (in window
+ * @param hwnd Handle to a specific NX window.
+ * @param rect The rectangle that needs to be re-drawn (in window
* relative coordinates).
* @param bMore true: More re-draw requests will follow.
- * @param pvArg User provided argument (see nx_openwindow, nx_requestbg,
+ * @param arg User provided argument (see nx_openwindow, nx_requestbg,
* nxtk_openwindow, or nxtk_opentoolbar).
*/
-void CCallback::redraw(NXHANDLE hWindow,
- FAR const struct nxgl_rect_s *pRect,
- bool bMore, FAR void *pvArg)
+void CCallback::redraw(NXHANDLE hwnd,
+ FAR const struct nxgl_rect_s *rect,
+ bool bMore, FAR void *arg)
{
- gvdbg("hWindow=%p pRect={(%d,%d),(%d,%d)} bMore=%s\n",
- hWindow,
- pRect->pt1.x, pRect->pt1.y, pRect->pt2.x, pRect->pt2.y,
+ gvdbg("hwnd=%p rect={(%d,%d),(%d,%d)} bMore=%s\n",
+ hwnd,
+ rect->pt1.x, rect->pt1.y, rect->pt2.x, rect->pt2.y,
bMore ? "true" : "false");
// The argument must be the CWidgetControl instance
- CWidgetControl *This = (CWidgetControl *)pvArg;
+ CWidgetControl *This = (CWidgetControl *)arg;
// Just forward the callback to the CWidgetControl::redrawEvent method
- This->redrawEvent(pRect, bMore);
+ This->redrawEvent(rect, bMore);
}
/**
* Position Callback. The new positional data is handled by
* CWidgetControl::geometryEvent.
*
- * @param hWindow Handle to a specific NX window.
- * @param pSize The size of the window.
- * @param pPos The position of the upper left hand corner of the window on
+ * @param hwnd Handle to a specific NX window.
+ * @param size The size of the window.
+ * @param pos The position of the upper left hand corner of the window on
* the overall display.
- * @param pBounds The bounding rectangle that describes the entire display.
- * @param pvArg User provided argument (see nx_openwindow, nx_requestbg,
+ * @param bounds The bounding rectangle that describes the entire display.
+ * @param arg User provided argument (see nx_openwindow, nx_requestbg,
* nxtk_openwindow, or nxtk_opentoolbar).
*/
-void CCallback::position(NXHANDLE hWindow,
- FAR const struct nxgl_size_s *pSize,
- FAR const struct nxgl_point_s *pPos,
- FAR const struct nxgl_rect_s *pBounds,
- FAR void *pvArg)
+void CCallback::position(NXHANDLE hwnd,
+ FAR const struct nxgl_size_s *size,
+ FAR const struct nxgl_point_s *pos,
+ FAR const struct nxgl_rect_s *bounds,
+ FAR void *arg)
{
- gvdbg("hWindow=%p pSize=(%d,%d) pPos=(%d,%d) pBounds={(%d,%d),(%d,%d)} pvArg=%p\n",
- hWindow, pSize->w, pSize->h, pPos->x, pPos->y,
- pBounds->pt1.x, pBounds->pt1.y, pBounds->pt2.x, pBounds->pt2.y,
- pvArg);
+ gvdbg("hwnd=%p size=(%d,%d) pos=(%d,%d) bounds={(%d,%d),(%d,%d)} arg=%p\n",
+ hwnd, size->w, size->h, pos->x, pos->y,
+ bounds->pt1.x, bounds->pt1.y, bounds->pt2.x, bounds->pt2.y,
+ arg);
// The argument must be the CWidgetControl instance
- CWidgetControl *This = (CWidgetControl *)pvArg;
+ CWidgetControl *This = (CWidgetControl *)arg;
// Just forward the callback to the CWidgetControl::geometry method
- This->geometryEvent(hWindow, pSize, pPos, pBounds);
+ This->geometryEvent(hwnd, size, pos, bounds);
}
/**
* New mouse data is available for the window. The new mouse data is
* handled by CWidgetControl::newMouseEvent.
*
- * @param hWindow Handle to a specific NX window.
- * @param pPos The (x,y) position of the mouse.
+ * @param hwnd Handle to a specific NX window.
+ * @param pos The (x,y) position of the mouse.
* @param buttons See NX_MOUSE_* definitions.
- * @param pvArg User provided argument (see nx_openwindow, nx_requestbg,
+ * @param arg User provided argument (see nx_openwindow, nx_requestbg,
* nxtk_openwindow, or nxtk_opentoolbar).
*/
-
+
#ifdef CONFIG_NX_MOUSE
-void CCallback::newMouseEvent(NXHANDLE hWindow,
- FAR const struct nxgl_point_s *pPos,
- uint8_t buttons, FAR void *pvArg)
+void CCallback::newMouseEvent(NXHANDLE hwnd,
+ FAR const struct nxgl_point_s *pos,
+ uint8_t buttons, FAR void *arg)
{
- gvdbg("hWindow=%p pPos=(%d,%d) buttons=%02x pvArg=%p\n",
- hWindow, pPos->x, pPos->y, buttons, pvArg);
+ gvdbg("hwnd=%p pos=(%d,%d) buttons=%02x arg=%p\n",
+ hwnd, pos->x, pos->y, buttons, arg);
// The argument must be the CWidgetControl instance
- CWidgetControl *This = (CWidgetControl *)pvArg;
+ CWidgetControl *This = (CWidgetControl *)arg;
// Just forward the callback to the CWidgetControl::newMouseEvent method
- This->newMouseEvent(pPos, buttons);
+ This->newMouseEvent(pos, buttons);
}
#endif /* CONFIG_NX_MOUSE */
@@ -169,27 +174,60 @@ void CCallback::newMouseEvent(NXHANDLE hWindow,
* New keyboard/keypad data is available for the window. The new keyboard
* data is handled by CWidgetControl::newKeyboardEvent.
*
- * @param hWindow Handle to a specific NX window.
- * @param nCh The number of characters that are available in pStr[].
- * @param pStr The array of characters.
- * @param pvArg User provided argument (see nx_openwindow, nx_requestbg,
+ * @param hwnd Handle to a specific NX window.
+ * @param nCh The number of characters that are available in str[].
+ * @param str The array of characters.
+ * @param arg User provided argument (see nx_openwindow, nx_requestbg,
* nxtk_openwindow, or nxtk_opentoolbar).
*/
#ifdef CONFIG_NX_KBD
-void CCallback::newKeyboardEvent(NXHANDLE hWindow, uint8_t nCh,
- FAR const uint8_t *pStr,
- FAR void *pvArg)
+void CCallback::newKeyboardEvent(NXHANDLE hwnd, uint8_t nCh,
+ FAR const uint8_t *str,
+ FAR void *arg)
{
- gvdbg("hWindow=%p nCh=%d pvArg=%p\n",
- hWindow, nCh, pvArg);
+ gvdbg("hwnd=%p nCh=%d arg=%p\n", hwnd, nCh, arg);
// The argument must be the CWidgetControl instance
- CWidgetControl *This = (CWidgetControl *)pvArg;
+ CWidgetControl *This = (CWidgetControl *)arg;
// Just forward the callback to the CWidgetControl::newKeyboardEvent method
- This->newKeyboardEvent(nCh, pStr);
+ This->newKeyboardEvent(nCh, str);
+}
+
+/**
+ * This callback is the response from nx_block (or nxtk_block). Those
+ * blocking interfaces are used to assure that no further messages are
+ * directed to the window. Receipt of the blocked callback signifies
+ * that (1) there are no further pending callbacks and (2) that the
+ * window is now 'defunct' and will receive no further callbacks.
+ *
+ * This callback supports coordinated destruction of a window in multi-
+ * user mode. In multi-use more, the client window logic must stay
+ * intact until all of the queued callbacks are processed. Then the
+ * window may be safely closed. Closing the window prior with pending
+ * callbacks can lead to bad behavior when the callback is executed.
+ *
+ * @param hwnd. Window handle of the blocked window
+ * @param arg. User provided argument (see nx_openwindow, nx_requestbkgd,
+ * nxtk_openwindow, or nxtk_opentoolbar)
+ */
+
+#ifdef CONFIG_NX_MULTIUSER
+void CCallback::windowBlocked(NXWINDOW hwnd, FAR void *arg)
+{
+ gvdbg("hwnd=%p arg=%p\n", hwnd, arg);
+
+ // The argument must be the CWidgetControl instance
+
+ CWidgetControl *This = (CWidgetControl *)arg;
+
+ // Just forward the callback to the CWidgetControl::windowBlocked method
+
+ This->windowBlocked();
}
+#endif
+
#endif // CONFIG_NX_KBD
diff --git a/NxWidgets/libnxwidgets/src/cwindoweventhandlerlist.cxx b/NxWidgets/libnxwidgets/src/cwindoweventhandlerlist.cxx
index 5f3048b63..15b2c65ff 100644
--- a/NxWidgets/libnxwidgets/src/cwindoweventhandlerlist.cxx
+++ b/NxWidgets/libnxwidgets/src/cwindoweventhandlerlist.cxx
@@ -160,3 +160,14 @@ void CWindowEventHandlerList::raiseKeyboardEvent(void)
#endif
}
+/**
+ * Raise an NX window blocked event.
+ */
+
+void CWindowEventHandlerList::raiseBlockedEvent(void)
+{
+ for (int i = 0; i < m_eventHandlers.size(); ++i)
+ {
+ m_eventHandlers.at(i)->handleBlockedEvent();
+ }
+}
diff --git a/nuttx/ChangeLog b/nuttx/ChangeLog
index 944fd5718..3845c66a8 100644
--- a/nuttx/ChangeLog
+++ b/nuttx/ChangeLog
@@ -2775,4 +2775,7 @@
* graphic/nxmu/nxmu_sendserver.c, nxmu_sendwindow.c, and nxmu_sendclient.c:
Refactor NX messaging logic in preparation for a new message control
feature.
-
+ * graphics/nxtk, graphics/nxmu, include/nuttx/nx: Add a new window communication
+ to support blocking and flushing of client window messages. If there are
+ stale, queue window messages at the time that a window is destroyed, very bad
+ things happen.
diff --git a/nuttx/graphics/nxbe/nxbe.h b/nuttx/graphics/nxbe/nxbe.h
index 089196fdd..aff42d6b3 100644
--- a/nuttx/graphics/nxbe/nxbe.h
+++ b/nuttx/graphics/nxbe/nxbe.h
@@ -62,6 +62,7 @@
# define CONFIG_NX_NCOLORS 256
#endif
+/* NXBE Definitions *********************************************************/
/* These are the values for the clipping order provided to nx_clipper */
#define NX_CLIPORDER_TLRB (0) /* Top-left-right-bottom */
@@ -70,6 +71,14 @@
#define NX_CLIPORDER_BRLT (3) /* Bottom-right-left-top */
#define NX_CLIPORDER_DEFAULT NX_CLIPORDER_TLRB
+/* Window flags and helper macros */
+
+#define NXBE_WINDOW_BLOCKED (1 << 0) /* The window is blocked and will not
+ * receive further input. */
+
+#define NXBE_ISBLOCKED(wnd) (((wnd)->flags & NXBE_WINDOW_BLOCKED) != 0)
+#define NXBE_SETBLOCKED(wnd) do { (wnd)->flags |= NXBE_WINDOW_BLOCKED; } while (0)
+
/****************************************************************************
* Public Types
****************************************************************************/
@@ -157,6 +166,12 @@ struct nxbe_window_s
struct nxgl_rect_s bounds; /* The bounding rectangle of window */
+ /* Window flags (see the NXBE_* bit definitions above) */
+
+#ifdef CONFIG_NX_MULTIUSER /* Currently used only in multi-user mode */
+ uint8_t flags;
+#endif
+
/* Client state information this is provide in window callbacks */
FAR void *arg;
diff --git a/nuttx/graphics/nxmu/Make.defs b/nuttx/graphics/nxmu/Make.defs
index b1370640c..23bf8995b 100644
--- a/nuttx/graphics/nxmu/Make.defs
+++ b/nuttx/graphics/nxmu/Make.defs
@@ -40,7 +40,7 @@ NXAPI_CSRCS = nx_bitmap.c nx_closewindow.c nx_connect.c nx_disconnect.c \
nx_mousein.c nx_move.c nx_openwindow.c nx_raise.c \
nx_releasebkgd.c nx_requestbkgd.c nx_setpixel.c nx_setsize.c \
nx_setbgcolor.c nx_setposition.c nx_drawcircle.c nx_drawline.c \
- nx_fillcircle.c
+ nx_fillcircle.c nx_block.c
NXMU_CSRCS = nxmu_constructwindow.c nxmu_kbdin.c nxmu_mouse.c \
nxmu_openwindow.c nxmu_redrawreq.c nxmu_releasebkgd.c \
nxmu_requestbkgd.c nxmu_reportposition.c nxmu_sendclient.c \
diff --git a/nuttx/graphics/nxmu/nx_block.c b/nuttx/graphics/nxmu/nx_block.c
new file mode 100644
index 000000000..10dad8b94
--- /dev/null
+++ b/nuttx/graphics/nxmu/nx_block.c
@@ -0,0 +1,145 @@
+/****************************************************************************
+ * graphics/nxmu/nx_block.c
+ *
+ * Copyright (C) 2012 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt <gnutt@nuttx.org>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name NuttX nor the names of its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <errno.h>
+#include <debug.h>
+
+#include <nuttx/nx/nx.h>
+
+#include "nxbe.h"
+#include "nxfe.h"
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Types
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+/****************************************************************************
+ * Public Data
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: nx_block
+ *
+ * Description:
+ * This is callback will do to things: (1) any queue a 'blocked' callback
+ * to the window and then (2) block any further window messaging.
+ *
+ * The 'blocked' callback is the response from nx_block (or nxtk_block).
+ * Those blocking interfaces are used to assure that no further messages are
+ * are directed to the window. Receipt of the blocked callback signifies
+ * that (1) there are no further pending callbacks and (2) that the
+ * window is now 'defunct' and will receive no further callbacks.
+ *
+ * This callback supports coordinated destruction of a window in multi-
+ * user mode. In multi-use mode, the client window logic must stay
+ * intact until all of the queued callbacks are processed. Then the
+ * window may be safely closed. Closing the window prior with pending
+ * callbacks can lead to bad behavior when the callback is executed.
+ *
+ * Multiple user mode only!
+ *
+ * Input Parameters:
+ * wnd - The window to be blocked
+ *
+ * Return:
+ * OK on success; ERROR on failure with errno set appropriately
+ *
+ ****************************************************************************/
+
+int nx_block(NXWINDOW hwnd)
+{
+ FAR struct nxbe_window_s *wnd = (FAR struct nxbe_window_s *)hwnd;
+ struct nxsvrmsg_blocked_s outmsg;
+ int ret = OK;
+
+#ifdef CONFIG_DEBUG
+ if (!hwnd)
+ {
+ errno = EINVAL;
+ return NULL;
+ }
+#endif
+
+ /* Ignore additional attempts to block messages (no errors reported) */
+
+ if (!NXBE_ISBLOCKED(wnd))
+ {
+ /* Mark the window as blocked. This will stop all messages to the window
+ * (EXCEPT the NX_SVRMSG_BLOCKED). Blocking the messages before sending the
+ * blocked message is awkward but assures that no other messages sneak into
+ * the message queue before we can set the blocked state.
+ */
+
+ NXBE_SETBLOCKED(wnd);
+
+ /* Send the message inicating that the window is blocked (and because of
+ * queue also that there are no additional queue messages for the window)
+ */
+
+ outmsg.msgid = NX_SVRMSG_BLOCKED;
+ outmsg.wnd = wnd;
+
+ /* Send the window message via nxmu_sendserver (vs. nxmu_sendwindow) so
+ * that it will not be blocked.
+ */
+
+ ret = nxmu_sendserver(wnd->conn, &outmsg, sizeof(struct nxbe_window_s));
+ }
+
+ return ret;
+}
+
diff --git a/nuttx/graphics/nxmu/nx_eventhandler.c b/nuttx/graphics/nxmu/nx_eventhandler.c
index d59364c2e..75300b248 100644
--- a/nuttx/graphics/nxmu/nx_eventhandler.c
+++ b/nuttx/graphics/nxmu/nx_eventhandler.c
@@ -1,8 +1,8 @@
/****************************************************************************
* graphics/nxmu/nx_eventhandler.c
*
- * Copyright (C) 2008-2009, 2011 Gregory Nutt. All rights reserved.
- * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
+ * Copyright (C) 2008-2009, 2011-2012 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -229,7 +229,7 @@ int nx_eventhandler(NXHANDLE handle)
{
FAR struct nxclimsg_kbdin_s *kbd = (FAR struct nxclimsg_kbdin_s *)buffer;
wnd = kbd->wnd;
- DEBUGASSERT(wnd);
+ DEBUGASSERT(wnd);
if (wnd->cb->kbdin)
{
wnd->cb->kbdin((NXWINDOW)wnd, kbd->nch, kbd->ch, wnd->arg);
@@ -238,6 +238,18 @@ int nx_eventhandler(NXHANDLE handle)
break;
#endif
+ case NX_CLIMSG_BLOCKED:
+ {
+ FAR struct nxclimsg_blocked_s *blocked = (FAR struct nxclimsg_blocked_s *)buffer;
+ wnd = blocked->wnd;
+ DEBUGASSERT(wnd);
+ if (wnd->cb->blocked)
+ {
+ wnd->cb->blocked((NXWINDOW)wnd, wnd->arg);
+ }
+ }
+ break;
+
default:
gdbg("Unrecognized message opcode: %d\n", ((FAR struct nxsvrmsg_s *)buffer)->msgid);
break;
diff --git a/nuttx/graphics/nxmu/nxfe.h b/nuttx/graphics/nxmu/nxfe.h
index 2b87b2a40..a70e635f5 100644
--- a/nuttx/graphics/nxmu/nxfe.h
+++ b/nuttx/graphics/nxmu/nxfe.h
@@ -146,6 +146,7 @@ enum nxmsg_e
NX_CLIMSG_NEWPOSITION, /* New window size/position */
NX_CLIMSG_MOUSEIN, /* New mouse positional data available for window */
NX_CLIMSG_KBDIN, /* New keypad input available for window */
+ NX_CLIMSG_BLOCKED, /* The window is blocked */
/* Client-to-Server Messages **********************************************/
@@ -153,6 +154,7 @@ enum nxmsg_e
NX_SVRMSG_DISCONNECT, /* Tear down connection with terminating client */
NX_SVRMSG_OPENWINDOW, /* Create a new window */
NX_SVRMSG_CLOSEWINDOW, /* Close an existing window */
+ NX_SVRMSG_BLOCKED, /* The window is blocked */
NX_SVRMSG_REQUESTBKGD, /* Open the background window */
NX_SVRMSG_RELEASEBKGD, /* Release the background window */
NX_SVRMSG_SETPOSITION, /* Window position has changed */
@@ -248,6 +250,16 @@ struct nxclimsg_kbdin_s
};
#endif
+/* This messsage confirms that that all queued window messages have been
+ * flushed and that the all further window messages are blocked.
+ */
+
+struct nxclimsg_blocked_s
+{
+ uint32_t msgid; /* NX_CLIMSG_BLOCKED */
+ FAR struct nxbe_window_s *wnd; /* The window that is blocked */
+};
+
/* Client-to-Server Message Structures **************************************/
/* The generic message structure. All server messages begin with this form. Also
@@ -277,6 +289,18 @@ struct nxsvrmsg_closewindow_s
FAR struct nxbe_window_s *wnd; /* The window to be closed */
};
+/* This messsage is just a marker that is queued and forwarded by the server
+ * (NX_CLIMSG_BLOCKED). Messages to the window were blocked just after this
+ * message was sent. Receipt of this message indicates both that the window
+ * blocked and that there are no further queued messages for the window.
+ */
+
+struct nxsvrmsg_blocked_s
+{
+ uint32_t msgid; /* NX_SVRMSG_BLOCKED */
+ FAR struct nxbe_window_s *wnd; /* The window that is blocked */
+};
+
/* This message requests the server to create a new window */
struct nxsvrmsg_requestbkgd_s
diff --git a/nuttx/graphics/nxmu/nxmu_sendclient.c b/nuttx/graphics/nxmu/nxmu_sendclient.c
new file mode 100644
index 000000000..8b7f12104
--- /dev/null
+++ b/nuttx/graphics/nxmu/nxmu_sendclient.c
@@ -0,0 +1,112 @@
+/****************************************************************************
+ * graphics/nxmu/nxmu_sendclient.c
+ *
+ * Copyright (C) 2012 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt <gnutt@nuttx.org>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name NuttX nor the names of its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <mqueue.h>
+#include <errno.h>
+#include <debug.h>
+
+#include "nxfe.h"
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Types
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+/****************************************************************************
+ * Public Data
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: nxmu_sendclient
+ *
+ * Description:
+ * Send a message to the client at NX_CLIMSG_PRIO priority
+ *
+ * Input Parameters:
+ * conn - A pointer to the server connection structure
+ * msg - A pointer to the message to send
+ * msglen - The length of the message in bytes.
+ *
+ * Return:
+ * OK on success; ERROR on failure with errno set appropriately
+ *
+ ****************************************************************************/
+
+int nxmu_sendclient(FAR struct nxfe_conn_s *conn, FAR const void *msg,
+ size_t msglen)
+{
+ int ret;
+
+ /* Sanity checking */
+
+#ifdef CONFIG_DEBUG
+ if (!conn || conn->swrmq)
+ {
+ errno = EINVAL;
+ return ERROR;
+ }
+#endif
+
+ /* Send the message to the client */
+
+ ret = mq_send(conn->swrmq, msg, msglen, NX_CLIMSG_PRIO);
+ if (ret < 0)
+ {
+ gdbg("mq_send failed: %d\n", errno);
+ }
+
+ return ret;
+}
diff --git a/nuttx/graphics/nxmu/nxmu_sendserver.c b/nuttx/graphics/nxmu/nxmu_sendserver.c
new file mode 100644
index 000000000..7007b81da
--- /dev/null
+++ b/nuttx/graphics/nxmu/nxmu_sendserver.c
@@ -0,0 +1,112 @@
+/****************************************************************************
+ * graphics/nxmu/nxmu_sendserver.c
+ *
+ * Copyright (C) 2012 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt <gnutt@nuttx.org>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name NuttX nor the names of its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <mqueue.h>
+#include <errno.h>
+#include <debug.h>
+
+#include "nxfe.h"
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Types
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+/****************************************************************************
+ * Public Data
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: nxmu_sendserver
+ *
+ * Description:
+ * Send a message to the server at NX_SVRMSG_PRIO priority
+ *
+ * Input Parameters:
+ * conn - A pointer to the server connection structure
+ * msg - A pointer to the message to send
+ * msglen - The length of the message in bytes.
+ *
+ * Return:
+ * OK on success; ERROR on failure with errno set appropriately
+ *
+ ****************************************************************************/
+
+int nxmu_sendserver(FAR struct nxfe_conn_s *conn, FAR const void *msg,
+ size_t msglen)
+{
+ int ret;
+
+ /* Sanity checking */
+
+#ifdef CONFIG_DEBUG
+ if (!conn || conn->cwrmq)
+ {
+ errno = EINVAL;
+ return ERROR;
+ }
+#endif
+
+ /* Send the message to the server */
+
+ ret = mq_send(conn->cwrmq, msg, msglen, NX_SVRMSG_PRIO);
+ if (ret < 0)
+ {
+ gdbg("mq_send failed: %d\n", errno);
+ }
+
+ return ret;
+}
diff --git a/nuttx/graphics/nxmu/nxmu_sendwindow.c b/nuttx/graphics/nxmu/nxmu_sendwindow.c
new file mode 100644
index 000000000..6f64ffff2
--- /dev/null
+++ b/nuttx/graphics/nxmu/nxmu_sendwindow.c
@@ -0,0 +1,114 @@
+/****************************************************************************
+ * graphics/nxmu/nxmu_sendserver.c
+ *
+ * Copyright (C) 2012 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt <gnutt@nuttx.org>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name NuttX nor the names of its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <mqueue.h>
+#include <errno.h>
+#include <debug.h>
+
+#include "nxfe.h"
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Types
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+/****************************************************************************
+ * Public Data
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: nxmu_sendwindow
+ *
+ * Description:
+ * Send a message to the server detined for a specific window at
+ * NX_SVRMSG_PRIO priority
+ *
+ * Input Parameters:
+ * wnd - A pointer to the back-end window structure
+ * msg - A pointer to the message to send
+ * msglen - The length of the message in bytes.
+ *
+ * Return:
+ * OK on success; ERROR on failure with errno set appropriately
+ *
+ ****************************************************************************/
+
+int nxmu_sendwindow(FAR struct nxbe_window_s *wnd, FAR const void *msg,
+ size_t msglen)
+{
+ int ret = OK;
+
+ /* Sanity checking */
+
+#ifdef CONFIG_DEBUG
+ if (!wnd || !wnd->conn)
+ {
+ errno = EINVAL;
+ return ERROR;
+ }
+#endif
+
+ /* Ignore messages destined to a blocked window (no errors reported) */
+
+ if (!NXBE_ISBLOCKED(wnd))
+ {
+ /* Send the message to the server */
+
+ ret = nxmu_sendserver(wnd->conn, msg, msglen);
+ }
+
+ return ret;
+}
diff --git a/nuttx/graphics/nxmu/nxmu_server.c b/nuttx/graphics/nxmu/nxmu_server.c
index 6b6009e80..c412b1492 100644
--- a/nuttx/graphics/nxmu/nxmu_server.c
+++ b/nuttx/graphics/nxmu/nxmu_server.c
@@ -151,6 +151,25 @@ static inline void nxmu_shutdown(FAR struct nxfe_state_s *fe)
}
/****************************************************************************
+ * Name: nxmu_blocked
+ ****************************************************************************/
+
+static inline void nxmu_blocked(FAR struct nxbe_window_s *wnd)
+{
+ struct nxclimsg_blocked_s outmsg;
+ int ret;
+
+ outmsg.msgid = NX_CLIMSG_BLOCKED;
+ outmsg.wnd = wnd;
+
+ ret = nxmu_sendclient(wnd->conn, &outmsg, sizeof(struct nxclimsg_blocked_s));
+ if (ret < 0)
+ {
+ gdbg("nxmu_sendclient failed: %d\n", errno);
+ }
+}
+
+/****************************************************************************
* Name: nxmu_setup
****************************************************************************/
@@ -358,6 +377,13 @@ int nx_runinstance(FAR const char *mqname, FAR NX_DRIVERTYPE *dev)
}
break;
+ case NX_SVRMSG_BLOCKED: /* Block messsages to a window */
+ {
+ FAR struct nxsvrmsg_blocked_s *blocked = (FAR struct nxsvrmsg_blocked_s *)buffer;
+ nxmu_blocked(blocked->wnd);
+ }
+ break;
+
case NX_SVRMSG_REQUESTBKGD: /* Give access to the background window */
{
FAR struct nxsvrmsg_requestbkgd_s *rqbgmsg = (FAR struct nxsvrmsg_requestbkgd_s *)buffer;
diff --git a/nuttx/graphics/nxtk/Make.defs b/nuttx/graphics/nxtk/Make.defs
index be3e1f721..cc744309f 100644
--- a/nuttx/graphics/nxtk/Make.defs
+++ b/nuttx/graphics/nxtk/Make.defs
@@ -39,7 +39,7 @@ NXTKWIN_CSRCS = nxtk_openwindow.c nxtk_closewindow.c nxtk_getposition.c \
nxtk_fillwindow.c nxtk_getwindow.c nxtk_filltrapwindow.c \
nxtk_movewindow.c nxtk_bitmapwindow.c nxtk_events.c \
nxtk_setsubwindows.c nxtk_drawcirclewindow.c nxtk_drawlinewindow.c \
- nxtk_fillcirclewindow.c
+ nxtk_fillcirclewindow.c nxtk_block.c
NXTKTB_CSRCS = nxtk_opentoolbar.c nxtk_closetoolbar.c nxtk_filltoolbar.c \
nxtk_gettoolbar.c nxtk_filltraptoolbar.c nxtk_movetoolbar.c \
nxtk_bitmaptoolbar.c nxtk_drawcircletoolbar.c nxtk_drawlinetoolbar.c \
diff --git a/nuttx/graphics/nxtk/nxtk_block.c b/nuttx/graphics/nxtk/nxtk_block.c
new file mode 100644
index 000000000..d011525fe
--- /dev/null
+++ b/nuttx/graphics/nxtk/nxtk_block.c
@@ -0,0 +1,107 @@
+/****************************************************************************
+ * graphics/nxtk/nxtk_block.c
+ *
+ * Copyright (C) 2012 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt <gnutt@nuttx.org>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name NuttX nor the names of its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <nuttx/nx/nx.h>
+#include <nuttx/nx/nxtk.h>
+
+#include "nxfe.h"
+
+#ifdef CONFIG_NX_MULTIUSER
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Types
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+/****************************************************************************
+ * Public Data
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: nxtk_block
+ *
+ * Description:
+ * This is callback will do to things: (1) any queue a 'blocked' callback
+ * to the window and then (2) block any further window messaging.
+ *
+ * The 'blocked' callback is the response from nx_block (or nxtk_block).
+ * Those blocking interfaces are used to assure that no further messages are
+ * are directed to the window. Receipt of the blocked callback signifies
+ * that (1) there are no further pending callbacks and (2) that the
+ * window is now 'defunct' and will receive no further callbacks.
+ *
+ * This callback supports coordinated destruction of a window in multi-
+ * user mode. In multi-use mode, the client window logic must stay
+ * intact until all of the queued callbacks are processed. Then the
+ * window may be safely closed. Closing the window prior with pending
+ * callbacks can lead to bad behavior when the callback is executed.
+ *
+ * Multiple user mode only!
+ *
+ * Input Parameters:
+ * hfwnd - The window to be blocked
+ *
+ * Return:
+ * OK on success; ERROR on failure with errno set appropriately
+ *
+ ****************************************************************************/
+
+int nxtk_block(NXTKWINDOW hfwnd)
+{
+ return nx_block((NXWINDOW)hfwnd);
+}
+
+#endif /* CONFIG_NX_MULTIUSER */
diff --git a/nuttx/include/nuttx/nx/nx.h b/nuttx/include/nuttx/nx/nx.h
index bba098398..4a228de25 100644
--- a/nuttx/include/nuttx/nx/nx.h
+++ b/nuttx/include/nuttx/nx/nx.h
@@ -190,6 +190,36 @@ struct nx_callback_s
#ifdef CONFIG_NX_KBD
void (*kbdin)(NXWINDOW hwnd, uint8_t nch, FAR const uint8_t *ch, FAR void *arg);
#endif
+
+ /**************************************************************************
+ * Name: blocked
+ *
+ * Descripton:
+ * This callback is the response from nx_block (or nxtk_block). Those
+ * blocking interfaces are used to assure that no further messages are
+ * directed to the window. Receipt of the blocked callback signifies
+ * that (1) there are no further pending callbacks and (2) that the
+ * window is now 'defunct' and will receive no further callbacks.
+ *
+ * This callback supports coordinated destruction of a window in multi-
+ * user mode. In multi-use mode, the client window logic must stay
+ * intact until all of the queued callbacks are processed. Then the
+ * window may be safely closed. Closing the window prior with pending
+ * callbacks can lead to bad behavior when the callback is executed.
+ *
+ * Input Parameters:
+ * hwnd - Window handle of the blocked window
+ * arg - User provided argument (see nx_openwindow, nx_requestbkgd,
+ * nxtk_openwindow, or nxtk_opentoolbar)
+ *
+ * Returned Value:
+ * None
+ *
+ **************************************************************************/
+
+#ifdef CONFIG_NX_MULTIUSER
+ void (*blocked)(NXWINDOW hwnd, FAR void *arg);
+#endif
};
/****************************************************************************
@@ -435,6 +465,39 @@ EXTERN NXWINDOW nx_openwindow(NXHANDLE handle,
EXTERN int nx_closewindow(NXWINDOW hwnd);
/****************************************************************************
+ * Name: nx_block
+ *
+ * Description:
+ * This is callback will do to things: (1) any queue a 'blocked' callback
+ * to the window and then (2) block any further window messaging.
+ *
+ * The 'blocked' callback is the response from nx_block (or nxtk_block).
+ * Those blocking interfaces are used to assure that no further messages are
+ * are directed to the window. Receipt of the blocked callback signifies
+ * that (1) there are no further pending callbacks and (2) that the
+ * window is now 'defunct' and will receive no further callbacks.
+ *
+ * This callback supports coordinated destruction of a window in multi-
+ * user mode. In multi-use more, the client window logic must stay
+ * intact until all of the queued callbacks are processed. Then the
+ * window may be safely closed. Closing the window prior with pending
+ * callbacks can lead to bad behavior when the callback is executed.
+ *
+ * Multiple user mode only!
+ *
+ * Input Parameters:
+ * wnd - The window to be blocked
+ *
+ * Return:
+ * OK on success; ERROR on failure with errno set appropriately
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_NX_MULTIUSER
+EXTERN int nx_block(NXWINDOW hwnd);
+#endif
+
+/****************************************************************************
* Name: nx_requestbkgd
*
* Description:
diff --git a/nuttx/include/nuttx/nx/nxtk.h b/nuttx/include/nuttx/nx/nxtk.h
index 00bce82e6..a69d17775 100644
--- a/nuttx/include/nuttx/nx/nxtk.h
+++ b/nuttx/include/nuttx/nx/nxtk.h
@@ -151,6 +151,39 @@ EXTERN NXTKWINDOW nxtk_openwindow(NXHANDLE handle,
EXTERN int nxtk_closewindow(NXTKWINDOW hfwnd);
/****************************************************************************
+ * Name: nxtk_block
+ *
+ * Description:
+ * This is callback will do to things: (1) any queue a 'blocked' callback
+ * to the window and then (2) block any further window messaging.
+ *
+ * The 'blocked' callback is the response from nx_block (or nxtk_block).
+ * Those blocking interfaces are used to assure that no further messages are
+ * are directed to the window. Receipt of the blocked callback signifies
+ * that (1) there are no further pending callbacks and (2) that the
+ * window is now 'defunct' and will receive no further callbacks.
+ *
+ * This callback supports coordinated destruction of a window in multi-
+ * user mode. In multi-use mode, the client window logic must stay
+ * intact until all of the queued callbacks are processed. Then the
+ * window may be safely closed. Closing the window prior with pending
+ * callbacks can lead to bad behavior when the callback is executed.
+ *
+ * Multiple user mode only!
+ *
+ * Input Parameters:
+ * hfwnd - The window to be blocked
+ *
+ * Return:
+ * OK on success; ERROR on failure with errno set appropriately
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_NX_MULTIUSER
+EXTERN int nxtk_block(NXTKWINDOW hfwnd);
+#endif
+
+/****************************************************************************
* Name: nxtk_getposition
*
* Description: