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
This commit is contained in:
parent
0608930e20
commit
6d58ba972f
14 changed files with 772 additions and 6 deletions
|
@ -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.
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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 \
|
||||
|
|
145
graphics/nxmu/nx_block.c
Normal file
145
graphics/nxmu/nx_block.c
Normal file
|
@ -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;
|
||||
}
|
||||
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
112
graphics/nxmu/nxmu_sendclient.c
Normal file
112
graphics/nxmu/nxmu_sendclient.c
Normal file
|
@ -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;
|
||||
}
|
112
graphics/nxmu/nxmu_sendserver.c
Normal file
112
graphics/nxmu/nxmu_sendserver.c
Normal file
|
@ -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;
|
||||
}
|
114
graphics/nxmu/nxmu_sendwindow.c
Normal file
114
graphics/nxmu/nxmu_sendwindow.c
Normal file
|
@ -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;
|
||||
}
|
|
@ -150,6 +150,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;
|
||||
|
|
|
@ -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 \
|
||||
|
|
107
graphics/nxtk/nxtk_block.c
Normal file
107
graphics/nxtk/nxtk_block.c
Normal file
|
@ -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 */
|
|
@ -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
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
|
@ -434,6 +464,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
|
||||
*
|
||||
|
|
|
@ -150,6 +150,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
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue