summaryrefslogtreecommitdiff
path: root/nuttx/graphics/nxmu
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2008-11-29 20:26:18 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2008-11-29 20:26:18 +0000
commit4afd2594d4fe1bbe5e96ea83e5f77b102849221f (patch)
tree113e2564990fdb41b3caafce055a24d0c668a53d /nuttx/graphics/nxmu
parenta9a76255e924240cd29d9cd9f596292d71bae8cb (diff)
downloadpx4-nuttx-4afd2594d4fe1bbe5e96ea83e5f77b102849221f.tar.gz
px4-nuttx-4afd2594d4fe1bbe5e96ea83e5f77b102849221f.tar.bz2
px4-nuttx-4afd2594d4fe1bbe5e96ea83e5f77b102849221f.zip
Using wrong(invalid) callback structure
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@1357 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/graphics/nxmu')
-rw-r--r--nuttx/graphics/nxmu/nx_eventhandler.c60
-rw-r--r--nuttx/graphics/nxmu/nx_eventnotify.c3
-rw-r--r--nuttx/graphics/nxmu/nx_openwindow.c9
-rw-r--r--nuttx/graphics/nxmu/nxfe.h33
-rw-r--r--nuttx/graphics/nxmu/nxmu_openwindow.c16
-rw-r--r--nuttx/graphics/nxmu/nxmu_server.c19
6 files changed, 78 insertions, 62 deletions
diff --git a/nuttx/graphics/nxmu/nx_eventhandler.c b/nuttx/graphics/nxmu/nx_eventhandler.c
index 136ff9b5f..a9ef438f0 100644
--- a/nuttx/graphics/nxmu/nx_eventhandler.c
+++ b/nuttx/graphics/nxmu/nx_eventhandler.c
@@ -187,45 +187,53 @@ int nx_eventhandler(NXHANDLE handle)
return ERROR;
case NX_CLIMSG_REDRAW:
- if (conn->cb->redraw)
- {
- FAR struct nxclimsg_redraw_s *redraw = (FAR struct nxclimsg_redraw_s *)buffer;
- wnd = redraw->wnd;
- DEBUGASSERT(wnd);
- wnd->cb->redraw((NXWINDOW)wnd, &redraw->rect, redraw->more);
- }
+ {
+ FAR struct nxclimsg_redraw_s *redraw = (FAR struct nxclimsg_redraw_s *)buffer;
+ wnd = redraw->wnd;
+ DEBUGASSERT(wnd);
+ if (wnd->cb->redraw)
+ {
+ wnd->cb->redraw((NXWINDOW)wnd, &redraw->rect, redraw->more);
+ }
+ }
break;
case NX_CLIMSG_NEWPOSITION:
- if (conn->cb->position)
- {
- FAR struct nxclimsg_newposition_s *postn = (FAR struct nxclimsg_newposition_s *)buffer;
- wnd = postn->wnd;
- DEBUGASSERT(wnd);
- wnd->cb->position((NXWINDOW)wnd, &postn->size, &postn->pos, &postn->bounds);
- }
+ {
+ FAR struct nxclimsg_newposition_s *postn = (FAR struct nxclimsg_newposition_s *)buffer;
+ wnd = postn->wnd;
+ DEBUGASSERT(wnd);
+ if (wnd->cb->position)
+ {
+ wnd->cb->position((NXWINDOW)wnd, &postn->size, &postn->pos, &postn->bounds);
+ }
+ }
break;
#ifdef CONFIG_NX_KBD
case NX_CLIMSG_MOUSEIN:
- if (conn->cb->mousein)
- {
- FAR struct nxclimsg_mousein_s *mouse = (FAR struct nxclimsg_mousein_s *)buffer;
- wnd = mouse->wnd;
- DEBUGASSERT(wnd);
- wnd->cb->mousein((NXWINDOW)wnd, &mouse->pos, mouse->buttons);
+ {
+ FAR struct nxclimsg_mousein_s *mouse = (FAR struct nxclimsg_mousein_s *)buffer;
+ wnd = mouse->wnd;
+ DEBUGASSERT(wnd);
+ if (wnd->cb->mousein)
+ {
+ wnd->cb->mousein((NXWINDOW)wnd, &mouse->pos, mouse->buttons);
+ }
}
break;
#endif
#ifdef CONFIG_NX_KBD
case NX_CLIMSG_KBDIN:
- if (conn->cb->kbdin)
- {
- FAR struct nxclimsg_kbdin_s *kbd = (FAR struct nxclimsg_kbdin_s *)buffer;
- wnd = kbd->wnd;
- DEBUGASSERT(wnd);
- wnd->cb->kbdin((NXWINDOW)wnd, kbd->nch, kbd->ch);
+ {
+ FAR struct nxclimsg_kbdin_s *kbd = (FAR struct nxclimsg_kbdin_s *)buffer;
+ wnd = kbd->wnd;
+ DEBUGASSERT(wnd);
+ if (wnd->cb->kbdin)
+ {
+ wnd->cb->kbdin((NXWINDOW)wnd, kbd->nch, kbd->ch);
+ }
}
break;
#endif
diff --git a/nuttx/graphics/nxmu/nx_eventnotify.c b/nuttx/graphics/nxmu/nx_eventnotify.c
index 9432f3361..e722c0dce 100644
--- a/nuttx/graphics/nxmu/nx_eventnotify.c
+++ b/nuttx/graphics/nxmu/nx_eventnotify.c
@@ -84,6 +84,9 @@
* client can then call nv_eventhandler() only when incoming events are
* available.
*
+ * Only one such event is issued. Upon receipt of the signal, if the client
+ * wishes further notifications, it must call nx_eventnotify again.
+ *
* Input Parameters:
* handle - the handle returned by nx_connect
*
diff --git a/nuttx/graphics/nxmu/nx_openwindow.c b/nuttx/graphics/nxmu/nx_openwindow.c
index 03fa9786b..8a834d4ba 100644
--- a/nuttx/graphics/nxmu/nx_openwindow.c
+++ b/nuttx/graphics/nxmu/nx_openwindow.c
@@ -111,12 +111,17 @@ NXWINDOW nx_openwindow(NXHANDLE handle, FAR const struct nx_callback_s *cb)
return NULL;
}
+ /* Setup only the connection structure. We'll need this to communicate with
+ * the server. The server will set everything else up.
+ */
+
+ wnd->conn = conn;
+ wnd->cb = cb;
+
/* Request initialization the new window from the server */
outmsg.msgid = NX_SVRMSG_OPENWINDOW;
- outmsg.conn = conn;
outmsg.wnd = wnd;
- outmsg.cb = cb;
ret = mq_send(conn->cwrmq, &outmsg, sizeof(struct nxsvrmsg_openwindow_s), NX_SVRMSG_PRIO);
if (ret < 0)
diff --git a/nuttx/graphics/nxmu/nxfe.h b/nuttx/graphics/nxmu/nxfe.h
index 88ea87830..50cf50b09 100644
--- a/nuttx/graphics/nxmu/nxfe.h
+++ b/nuttx/graphics/nxmu/nxfe.h
@@ -110,7 +110,6 @@ struct nxfe_conn_s
mqd_t crdmq; /* MQ to read from the server (may be non-blocking) */
mqd_t cwrmq; /* MQ to write to the server (blocking) */
- FAR const struct nx_callback_s *cb; /* Message handling callbacks */
/* These are only usable on the server side of the connection */
@@ -179,16 +178,27 @@ enum nxmsg_e
/* Server-to-Client Message Structures **************************************/
-/* The generic message structure. All messages begin with this form. Also, messages
- * that have no data other than the msgid event use this structure. This includes:
- * NX_CLIMSG_CONNECTED and NX_CLIMSG_DISCONNECTED.
- */
+/* The generic message structure. All messages begin with this form. */
struct nxclimsg_s
{
uint32 msgid; /* Any of nxclimsg_e */
};
+/* The server is now connected */
+
+struct nxclimsg_connected_s
+{
+ uint32 msgid; /* NX_CLIMSG_REDRAW_CONNECTED */
+};
+
+/* The server is now disconnected */
+
+struct nxclimsg_disconnected_s
+{
+ uint32 msgid; /* NX_CLIMSG_REDRAW_DISCONNECTED */
+};
+
/* This message is received when a requested window has been opened. If wnd is NULL
* then errorcode is the errno value that provides the explanation of the error.
*/
@@ -254,9 +264,7 @@ struct nxsvrmsg_s /* Generic server message */
struct nxsvrmsg_openwindow_s
{
uint32 msgid; /* NX_SVRMSG_OPENWINDOW */
- FAR struct nxfe_conn_s *conn; /* The specific connection sending the message */
FAR struct nxbe_window_s *wnd; /* The pre-allocated window structure */
- FAR const struct nx_callback_s *cb; /* Event handling callbacks */
};
/* This message informs the server that client wishes to close a window */
@@ -442,8 +450,7 @@ EXTERN void nxmu_semtake(sem_t *sem);
* Create a new window.
*
* Input Parameters:
- * conn - The client containing connection information [IN]
- * svr - The server state structure [IN]
+ * be - The back-end status structure
* wnd - The pre-allocated window structure to be ininitilized [IN/OUT]
*
* Return:
@@ -451,10 +458,8 @@ EXTERN void nxmu_semtake(sem_t *sem);
*
****************************************************************************/
-EXTERN void nxmu_openwindow(FAR struct nxfe_conn_s *conn,
- FAR struct nxbe_state_s *be,
- FAR struct nxbe_window_s *wnd,
- FAR const struct nx_callback_s *cb);
+EXTERN void nxmu_openwindow(FAR struct nxbe_state_s *be,
+ FAR struct nxbe_window_s *wnd);
/****************************************************************************
* Name: nxmu_requestbkgd
@@ -565,7 +570,7 @@ EXTERN nxmu_mousein(FAR struct nxfe_state_s *fe,
****************************************************************************/
#ifdef CONFIG_NX_KBD
-EXTERN void nxmu_kbdin(FAR struct nxs_server_s *svr, ubyte nch, ubyte *ch);
+EXTERN void nxmu_kbdin(FAR struct nxfe_state_s *fe, ubyte nch, ubyte *ch);
#endif
#undef EXTERN
diff --git a/nuttx/graphics/nxmu/nxmu_openwindow.c b/nuttx/graphics/nxmu/nxmu_openwindow.c
index 13a69d466..a458bc676 100644
--- a/nuttx/graphics/nxmu/nxmu_openwindow.c
+++ b/nuttx/graphics/nxmu/nxmu_openwindow.c
@@ -74,29 +74,23 @@
* Create a new window.
*
* Input Parameters:
- * conn - The client containing connection information [IN]
- * be - The server state structure [IN]
+ * be - The back-end status structure
* wnd - The pre-allocated window structure to be ininitilized [IN/OUT]
- * cb - Callbacks used to process window events
*
* Return:
* None
*
****************************************************************************/
-void nxmu_openwindow(FAR struct nxfe_conn_s *conn,
- FAR struct nxbe_state_s *be,
- FAR struct nxbe_window_s *wnd,
- FAR const struct nx_callback_s *cb)
+void nxmu_openwindow(FAR struct nxbe_state_s *be, FAR struct nxbe_window_s *wnd)
{
/* The window structure was allocated in nx_openwindow and all fields have
- * been set to zero (except sem... see below). We need only initialize the
- * the non zero fields and insert the new window.
+ * been set to zero cb and conn which were initialized on the client side.
+ * On the server side, we need only initialize a few more the non zero fields
+ * and insert the new window at the top of the display.
*/
wnd->be = be;
- wnd->conn = conn;
- wnd->cb = cb;
/* Now, insert the new window at the top on the display. topwind is
* never NULL (it may point only at the background window, however)
diff --git a/nuttx/graphics/nxmu/nxmu_server.c b/nuttx/graphics/nxmu/nxmu_server.c
index d9e7eb5a6..1cefed621 100644
--- a/nuttx/graphics/nxmu/nxmu_server.c
+++ b/nuttx/graphics/nxmu/nxmu_server.c
@@ -80,14 +80,14 @@
static inline void nxmu_disconnect(FAR struct nxfe_conn_s *conn)
{
- struct nxclimsg_s outmsg;
- int ret;
+ struct nxclimsg_disconnected_s outmsg;
+ int ret;
/* Send the handshake message back to the client */
outmsg.msgid = NX_CLIMSG_DISCONNECTED;
- ret = mq_send(conn->swrmq, &outmsg, sizeof(struct nxclimsg_s), NX_CLIMSG_PRIO);
+ ret = mq_send(conn->swrmq, &outmsg, sizeof(struct nxclimsg_disconnected_s), NX_CLIMSG_PRIO);
if (ret < 0)
{
gdbg("mq_send failed: %d\n", errno);
@@ -104,9 +104,9 @@ static inline void nxmu_disconnect(FAR struct nxfe_conn_s *conn)
static inline void nxmu_connect(FAR struct nxfe_conn_s *conn)
{
- char mqname[NX_CLIENT_MXNAMELEN];
- struct nxclimsg_s outmsg;
- int ret;
+ char mqname[NX_CLIENT_MXNAMELEN];
+ struct nxclimsg_connected_s outmsg;
+ int ret;
/* Create the client MQ name */
@@ -114,7 +114,6 @@ static inline void nxmu_connect(FAR struct nxfe_conn_s *conn)
/* Open the client MQ -- this should have already been created by the client */
- outmsg.msgid = NX_CLIMSG_CONNECTED;
conn->swrmq = mq_open(mqname, O_WRONLY);
if (conn->swrmq == (mqd_t)-1)
{
@@ -124,7 +123,9 @@ static inline void nxmu_connect(FAR struct nxfe_conn_s *conn)
/* Send the handshake message back to the client */
- ret = mq_send(conn->swrmq, &outmsg, sizeof(struct nxclimsg_s), NX_CLIMSG_PRIO);
+ outmsg.msgid = NX_CLIMSG_CONNECTED;
+
+ ret = mq_send(conn->swrmq, &outmsg, sizeof(struct nxclimsg_connected_s), NX_CLIMSG_PRIO);
if (ret < 0)
{
gdbg("mq_send failed: %d\n", errno);
@@ -376,7 +377,7 @@ int nx_runinstance(FAR const char *mqname, FAR struct fb_vtable_s *fb)
case NX_SVRMSG_OPENWINDOW: /* Create a new window */
{
FAR struct nxsvrmsg_openwindow_s *openmsg = (FAR struct nxsvrmsg_openwindow_s *)buffer;
- nxmu_openwindow(openmsg->conn, &fe.be, openmsg->wnd, openmsg->cb);
+ nxmu_openwindow(&fe.be, openmsg->wnd);
}
break;