Fixed for multi-user NX mode

git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@1386 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
patacongo 2008-12-01 22:13:03 +00:00
parent c7b165ddd1
commit 0c3926c145
20 changed files with 159 additions and 38 deletions

View file

@ -429,6 +429,29 @@ CONFIG_EXAMPLES_NSH_FATSECTSIZE=512
CONFIG_EXAMPLES_NSH_FATNSECTORS=1024
CONFIG_EXAMPLES_NSH_FATMOUNTPT=/tmp
#
# Settings for examples/nx
#
# CONFIG_EXAMPLES_NX_VPLANE -- The plane to select from the frame-
# buffer driver for use in the test. Default: 0
# CONFIG_EXAMPLES_NX_BGCOLOR -- The color of the background. Default: ' '.
# CONFIG_EXAMPLES_NX_COLOR1 -- The color of window 1. Default: '1'
# CONFIG_EXAMPLES_NX_COLOR2 -- The color of window 2. Default: '2'
# CONFIG_EXAMPLES_NX_STACKSIZE -- The stacksize to use when creating
# the NX server. Default 2048
# CONFIG_EXAMPLES_NX_CLIENTPRIO -- The client priority. Default: 80
# CONFIG_EXAMPLES_NX_SERVERPRIO -- The server priority. Default: 120
# CONFIG_EXAMPLES_NX_NOTIFYSIGNO -- The signal number to use with
# nx_eventnotify(). Default: 4
CONFIG_EXAMPLES_NX_VPLANE=0
#CONFIG_EXAMPLES_NX_BGCOLOR
#CONFIG_EXAMPLES_NX_COLOR1
#CONFIG_EXAMPLES_NX_COLOR2
CONFIG_EXAMPLES_NX_STACKSIZE=8192
CONFIG_EXAMPLES_NX_CLIENTPRIO=80
CONFIG_EXAMPLES_NX_SERVERPRIO=120
CONFIG_EXAMPLES_NX_NOTIFYSIGNO=4
#
# Settings for examples/mount
CONFIG_EXAMPLES_MOUNT_DEVNAME="/dev/ram0"

View file

@ -429,6 +429,29 @@ CONFIG_EXAMPLES_NSH_FATSECTSIZE=512
CONFIG_EXAMPLES_NSH_FATNSECTORS=1024
CONFIG_EXAMPLES_NSH_FATMOUNTPT=/tmp
#
# Settings for examples/nx
#
# CONFIG_EXAMPLES_NX_VPLANE -- The plane to select from the frame-
# buffer driver for use in the test. Default: 0
# CONFIG_EXAMPLES_NX_BGCOLOR -- The color of the background. Default: ' '.
# CONFIG_EXAMPLES_NX_COLOR1 -- The color of window 1. Default: '1'
# CONFIG_EXAMPLES_NX_COLOR2 -- The color of window 2. Default: '2'
# CONFIG_EXAMPLES_NX_STACKSIZE -- The stacksize to use when creating
# the NX server. Default 2048
# CONFIG_EXAMPLES_NX_CLIENTPRIO -- The client priority. Default: 80
# CONFIG_EXAMPLES_NX_SERVERPRIO -- The server priority. Default: 120
# CONFIG_EXAMPLES_NX_NOTIFYSIGNO -- The signal number to use with
# nx_eventnotify(). Default: 4
CONFIG_EXAMPLES_NX_VPLANE=0
#CONFIG_EXAMPLES_NX_BGCOLOR
#CONFIG_EXAMPLES_NX_COLOR1
#CONFIG_EXAMPLES_NX_COLOR2
CONFIG_EXAMPLES_NX_STACKSIZE=8192
CONFIG_EXAMPLES_NX_CLIENTPRIO=80
CONFIG_EXAMPLES_NX_SERVERPRIO=120
CONFIG_EXAMPLES_NX_NOTIFYSIGNO=4
#
# Settings for examples/mount
CONFIG_EXAMPLES_MOUNT_DEVNAME="/dev/ram0"

View file

@ -54,6 +54,31 @@ examples/nsh
someday be a great NuttX application debugger. NSH is described
in its own README located at examples/nsh/README.txt
examples/nx
^^^^^^^^^^^
This directory contains a simple test of a subset of the NX APIs
defined in include/nuttx/nx.h. The following configuration options
can be selected:
CONFIG_EXAMPLES_NX_VPLANE -- The plane to select from the frame-
buffer driver for use in the test. Default: 0
CONFIG_EXAMPLES_NX_BGCOLOR -- The color of the background. Default: ' '.
CONFIG_EXAMPLES_NX_COLOR1 -- The color of window 1. Default: '1'
CONFIG_EXAMPLES_NX_COLOR2 -- The color of window 2. Default: '2'
This test can be performed with either the single-user version of
NX or with the multiple user version of NX selected with CONFIG_NX_MULTIUSER.
If CONFIG_NX_MULTIUSER is defined, then the following configuration
options also apply:
CONFIG_EXAMPLES_NX_STACKSIZE -- The stacksize to use when creating
the NX server. Default 2048
CONFIG_EXAMPLES_NX_CLIENTPRIO -- The client priority. Default: 80
CONFIG_EXAMPLES_NX_SERVERPRIO -- The server priority. Default: 120
CONFIG_EXAMPLES_NX_NOTIFYSIGNO -- The signal number to use with
nx_eventnotify(). Default: 4
examples/null
^^^^^^^^^^^^^

View file

@ -97,8 +97,11 @@
# ifndef CONFIG_EXAMPLES_NX_STACKSIZE
# define CONFIG_EXAMPLES_NX_STACKSIZE 2048
# endif
# ifndef CONFIG_EXAMPLES_NX_CLIENTPRIO
# define CONFIG_EXAMPLES_NX_CLIENTPRIO 80
# endif
# ifndef CONFIG_EXAMPLES_NX_SERVERPRIO
# define CONFIG_EXAMPLES_NX_SERVERPRIO 100
# define CONFIG_EXAMPLES_NX_SERVERPRIO 120
# endif
# ifndef CONFIG_EXAMPLES_NX_NOTIFYSIGNO
# define CONFIG_EXAMPLES_NX_NOTIFYSIGNO 4

View file

@ -485,7 +485,28 @@ static inline int nxeg_muinitialize(void)
while (!g_connected)
{
(void)sem_wait(&g_semevent);
/* Assuming that the incoming message queue is configured non-blocking,
* we can poll the event handler here. This accounts for the case where
* the server is higher prioirty than the client. In that case, the
* server will have already responded to the connection request BEFORE
* the nx_eventnotify was called.
*/
ret = nx_eventhandler(g_hnx);
if (ret == 0)
{
/* If a message was received, then we are connected */
g_connected = TRUE;
}
/* Otherwise, we will have to wait for the event handler to wake up up
* when we really are connected.
*/
else
{
(void)sem_wait(&g_semevent);
}
}
}
else

View file

@ -110,7 +110,7 @@ static uint32 g_nxcid = 1;
*
****************************************************************************/
NXHANDLE nx_connectionstance(FAR const char *svrmqname)
NXHANDLE nx_connectinstance(FAR const char *svrmqname)
{
FAR struct nxfe_conn_s *conn;
struct nxsvrmsg_s msg;

View file

@ -85,17 +85,17 @@
int nx_mousein(NXHANDLE handle, nxgl_coord_t x, nxgl_coord_t y, ubyte buttons)
{
FAR struct nxfe_conn_s *conn = (FAR struct nxfe_conn_s *)handle;
struct nxsvrmsg_mousein_s outmsg;
struct nxsvrmsg_mousein_s outmsg;
int ret;
/* Inform the server that this client no longer exists */
msg.msgid = NX_SVRMSG_MOUSEIN;
msg.pt.x = x;
msg.pt.y = y;
msg.buttons = buttons;
outmsg.msgid = NX_SVRMSG_MOUSEIN;
outmsg.pt.x = x;
outmsg.pt.y = y;
outmsg.buttons = buttons;
ret = mq_send(conn->c_cwrmq, &outmsg, sizeof(struct nxsvrmsg_mousein_s), NX_SVRMSG_PRIO);
ret = mq_send(conn->cwrmq, &outmsg, sizeof(struct nxsvrmsg_mousein_s), NX_SVRMSG_PRIO);
if (ret < 0)
{
gdbg("mq_send failed: %d\n", errno);

View file

@ -95,7 +95,7 @@ NXWINDOW nx_openwindow(NXHANDLE handle, FAR const struct nx_callback_s *cb,
int ret;
#ifdef CONFIG_DEBUG
if (!conn || !cb)
if (!handle || !cb)
{
errno = EINVAL;
return NULL;

View file

@ -1,5 +1,5 @@
/****************************************************************************
* graphics/nxsu/nx_releasebkgd.c
* graphics/nxmu/nx_releasebkgd.c
*
* Copyright (C) 2008 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>

View file

@ -104,13 +104,15 @@
* Input Parameters:
* handle - The handle returned by nx_connect
* cb - Callbacks to use for processing background window events
* arg - User provided argument (see nx_openwindow, nx_constructwindow)
*
* Return:
* OK: Success; ERROR of failure with errno set appropriately.
*
****************************************************************************/
int nx_requestbkgd(NXHANDLE handle, FAR const struct nx_callback_s *cb)
int nx_requestbkgd(NXHANDLE handle, FAR const struct nx_callback_s *cb,
FAR void *arg)
{
FAR struct nxfe_conn_s *conn = (FAR struct nxfe_conn_s *)handle;
struct nxsvrmsg_requestbkgd_s outmsg;
@ -129,6 +131,7 @@ int nx_requestbkgd(NXHANDLE handle, FAR const struct nx_callback_s *cb)
outmsg.msgid = NX_SVRMSG_REQUESTBKGD;
outmsg.conn = conn;
outmsg.cb = cb;
outmsg.arg = arg;
ret = mq_send(conn->cwrmq, &outmsg, sizeof(struct nxsvrmsg_requestbkgd_s), NX_SVRMSG_PRIO);
if (ret < 0)

View file

@ -231,7 +231,7 @@ struct nxclimsg_mousein_s
FAR struct nxbe_window_s *wnd; /* The handle of window receiving mouse input */
struct nxgl_point_s pos; /* Mouse X/Y position */
ubyte buttons; /* Mouse button set */
}
};
#endif
/* This message reports a new keypad event to a particular window */
@ -282,6 +282,7 @@ struct nxsvrmsg_requestbkgd_s
uint32 msgid; /* NX_SVRMSG_REQUESTBKGD */
FAR struct nxfe_conn_s *conn; /* The specific connection sending the message */
FAR const struct nx_callback_s *cb; /* Event handling callbacks */
FAR void *arg; /* Client argument used with callbacks */
};
/* This message informs the server that client wishes to close a window */
@ -392,9 +393,9 @@ struct nxsvrmsg_setbgcolor_s
struct nxsvrmsg_mousein_s
{
uint32 msgid; /* NX_SVRMSG_MOUSEIN */
struct nx_point_x pt; /* Mouse X/Y position */
struct nxgl_point_s pt; /* Mouse X/Y position */
ubyte buttons; /* Mouse button set */
}
};
#endif
/* This message reports a new keyboard event from a hardware controller attached to
@ -408,7 +409,7 @@ struct nxsvrmsg_kbdin_s
uint32 msgid; /* NX_SVRMSG_KBDIN */
ubyte nch /* Number of characters received */
ubyte ch[1]; /* Array of received characters */
}
};
#endif
/****************************************************************************
@ -505,6 +506,7 @@ EXTERN void nxmu_openwindow(FAR struct nxbe_state_s *be,
* conn - The client containing connection information [IN]
* be - The server state structure [IN]
* cb - Callbacks used to process window events
* arg - User provided argument (see nx_openwindow, nx_constructwindow)
*
* Return:
* None
@ -513,7 +515,8 @@ EXTERN void nxmu_openwindow(FAR struct nxbe_state_s *be,
EXTERN void nxmu_requestbkgd(FAR struct nxfe_conn_s *conn,
FAR struct nxbe_state_s *be,
FAR const struct nx_callback_s *cb);
FAR const struct nx_callback_s *cb,
FAR void *arg);
/****************************************************************************
* Name: nxmu_releasebkgd
@ -594,8 +597,8 @@ EXTERN int nxmu_mousereport(struct nxbe_window_s *wnd);
****************************************************************************/
#ifdef CONFIG_NX_MOUSE
EXTERN nxmu_mousein(FAR struct nxfe_state_s *fe,
FAR const struct nxgl_point_s *pos, int button);
EXTERN int nxmu_mousein(FAR struct nxfe_state_s *fe,
FAR const struct nxgl_point_s *pos, int button);
#endif
/****************************************************************************

View file

@ -130,7 +130,7 @@ int nxmu_mousereport(struct nxbe_window_s *wnd)
outmsg.buttons = g_mbutton;
nxgl_vectsubtract(&outmsg.pos, &g_mpos, &wnd->origin);
ret = mq_send(wnd->conn->swrmq, outmsg,
ret = mq_send(wnd->conn->swrmq, &outmsg,
sizeof(struct nxclimsg_mousein_s), NX_SVRMSG_PRIO);
if (ret < 0)
{
@ -155,8 +155,8 @@ int nxmu_mousereport(struct nxbe_window_s *wnd)
*
****************************************************************************/
void nxmu_mousein(FAR struct nxfe_state_s *fe,
FAR const struct nxgl_point_s *pos, int buttons)
int nxmu_mousein(FAR struct nxfe_state_s *fe,
FAR const struct nxgl_point_s *pos, int buttons)
{
struct nxbe_window_s *wnd;
nxgl_coord_t x = pos->x;
@ -193,7 +193,6 @@ void nxmu_mousein(FAR struct nxfe_state_s *fe,
g_mpos.y = y;
g_mbutton = buttons;
/* Pick the window to receive the mouse event. Start with
* the top window and go down. Step with the first window
* that gets the mouse report
@ -201,13 +200,23 @@ void nxmu_mousein(FAR struct nxfe_state_s *fe,
for (wnd = fe->be.topwnd; wnd; wnd = wnd->below)
{
ret = nxsu_mousereport(wnd);
if (ret == 0)
/* The background window normally has no callback structure
* (unless a client has taken control of the background via
* nx_requestbkgd()).
*/
if (wnd->cb)
{
break;
ret = nxmu_mousereport(wnd);
if (ret == 0)
{
break;
}
}
}
}
return OK;
}
#endif /* CONFIG_NX_MOUSE */

View file

@ -1,5 +1,5 @@
/****************************************************************************
* graphics/nxsu/nxmu_releasebkgd.c
* graphics/nxmu/nxmu_releasebkgd.c
*
* Copyright (C) 2008 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
@ -101,6 +101,7 @@ void nxmu_releasebkgd(FAR struct nxfe_state_s *fe)
*/
be->bkgd.cb = NULL;
be->bkgd.arg = NULL;
be->bkgd.conn = &fe->conn;
/* Redraw the background window */

View file

@ -81,6 +81,7 @@
* conn - The client containing connection information [IN]
* be - The server state structure [IN]
* cb - Callbacks used to process window events
* arg - User provided argument (see nx_openwindow, nx_constructwindow)
*
* Return:
* None
@ -89,7 +90,8 @@
void nxmu_requestbkgd(FAR struct nxfe_conn_s *conn,
FAR struct nxbe_state_s *be,
FAR const struct nx_callback_s *cb)
FAR const struct nx_callback_s *cb,
FAR void *arg)
{
#ifdef CONFIG_DEBUG
if (!conn || !be || !cb)
@ -103,6 +105,7 @@ void nxmu_requestbkgd(FAR struct nxfe_conn_s *conn,
*/
be->bkgd.cb = cb;
be->bkgd.arg = arg;
be->bkgd.conn = conn;
/* Report the size/position of the background window to the client */
@ -116,7 +119,7 @@ void nxmu_requestbkgd(FAR struct nxfe_conn_s *conn,
/* Provide the mouse settings */
#ifdef CONFIG_NX_MOUSE
nxsu_mousereport(&be->bkgd);
nxmu_mousereport(&be->bkgd);
#endif
}

View file

@ -96,7 +96,7 @@ void nxsu_mouseinit(int x, int y)
}
/****************************************************************************
* Name: nxmu_mousereport
* Name: nxsu_mousereport
*
* Description:
* Report mouse position info to the specified window

View file

@ -100,7 +100,8 @@ int nx_releasebkgd(NXWINDOW hwnd)
/* Restore the NX background window callbacks */
be->bkgd.cb = &g_bkgdcb;
be->bkgd.cb = &g_bkgdcb;
be->bkgd.arg = NULL;
/* Redraw the background window */

View file

@ -103,13 +103,15 @@
* Input Parameters:
* handle - The handle returned by nx_connect
* cb - Callbacks to use for processing background window events
* arg - User provided argument (see nx_openwindow, nx_constructwindow)
*
* Return:
* OK on success; ERROR on failure with errno set appropriately
*
****************************************************************************/
int nx_requestbkgd(NXHANDLE handle, FAR const struct nx_callback_s *cb)
int nx_requestbkgd(NXHANDLE handle, FAR const struct nx_callback_s *cb,
FAR void *arg)
{
FAR struct nxfe_state_s *fe = (FAR struct nxfe_state_s *)handle;
FAR struct nxbe_state_s *be = &fe->be;
@ -124,7 +126,8 @@ int nx_requestbkgd(NXHANDLE handle, FAR const struct nx_callback_s *cb)
/* Replace the NX background windo callbacks with the client's callbacks */
be->bkgd.cb = cb;
be->bkgd.cb = cb;
be->bkgd.arg = arg;
/* Report the size/position of the background window to the client */

View file

@ -1,5 +1,5 @@
/****************************************************************************
* graphics/nxmu/nxsu_redrawreq.c
* graphics/nxsu/nxsu_redrawreq.c
*
* Copyright (C) 2008 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>

View file

@ -81,7 +81,7 @@ struct nxtk_rawwindow_s
static void nxtk_close(NXTWINDOW hwnd)
{
FAR struct nxtk_rawwindow_s *this = (FAR struct nxtk_rawwindow_s *)hwnd;
nx_close(this->hwnd);
nx_closewindow(this->hwnd);
free(this);
}

View file

@ -256,8 +256,8 @@ EXTERN int nx_runinstance(FAR const char *mqname, FAR struct fb_vtable_s *fb);
****************************************************************************/
#ifdef CONFIG_NX_MULTIUSER
EXTERN NXHANDLE nx_connectionstance(FAR const char *svrmqname);
# define nx_connect(cb) nx_connectionstance(NX_DEFAULT_SERVER_MQNAME)
EXTERN NXHANDLE nx_connectinstance(FAR const char *svrmqname);
# define nx_connect(cb) nx_connectinstance(NX_DEFAULT_SERVER_MQNAME)
#endif
/****************************************************************************
@ -458,13 +458,16 @@ EXTERN int nx_closewindow(NXWINDOW hwnd);
* Input Parameters:
* handle - The handle returned by nx_connect
* cb - Callbacks to use for processing background window events
* arg - User provided argument (see nx_openwindow, nx_constructwindow)
*
* Return:
* OK on success; ERROR on failure with errno set appropriately
*
****************************************************************************/
EXTERN int nx_requestbkgd(NXHANDLE handle, FAR const struct nx_callback_s *cb);
EXTERN int nx_requestbkgd(NXHANDLE handle,
FAR const struct nx_callback_s *cb,
FAR void *arg);
/****************************************************************************
* Name: nx_releasebkgd