Using wrong(invalid) callback structure

git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@1357 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
patacongo 2008-11-29 20:26:18 +00:00
parent a2740a9c1e
commit 94c66e2480
8 changed files with 91 additions and 67 deletions

View file

@ -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

View file

@ -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
*

View file

@ -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)

View file

@ -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

View file

@ -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)

View file

@ -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;

View file

@ -85,7 +85,7 @@
*
****************************************************************************/
void nx_releasebkgd(NXWINDOW hwnd)
int nx_releasebkgd(NXWINDOW hwnd)
{
FAR struct nxfe_state_s *fe = (FAR struct nxfe_state_s *)hwnd;
FAR struct nxbe_state_s *be = &fe->be;

View file

@ -227,10 +227,15 @@ EXTERN int nx_runinstance(FAR const char *mqname, FAR struct fb_vtable_s *fb);
* connection is normally needed per thread as each connection can host
* multiple windows.
*
* NOTE that multiple instances of the NX server may run at the same time,
* each with different message queue names. nx_connect() is simply
* a macro that can be used when only one server instance is required. In
* that case, a default server name is used.
* NOTES:
* - This function returns before the connection is fully instantiated.
* it is necessary to wait for the connection event before using the
* returned handle.
* - Multiple instances of the NX server may run at the same time,
* each with different message queue names.
* - nx_connect() is simply a macro that can be used when only one
* server instance is required. In that case, a default server name
* is used.
*
* Multiple user mode only!
*
@ -357,6 +362,9 @@ EXTERN int nx_eventhandler(NXHANDLE handle);
* 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
*