Re-factor NX messaging logic in preparation for a new message control feature

git-svn-id: https://nuttx.svn.sourceforge.net/svnroot/nuttx/trunk@4744 7fd9a85b-ad96-42d3-883c-3090e2eb8679
This commit is contained in:
patacongo 2012-05-17 19:32:48 +00:00
parent 19e5ee4c81
commit 7c97dbdf44
29 changed files with 156 additions and 243 deletions

View File

@ -2772,4 +2772,7 @@
* configs/stm3240g-eval/nxwm/defconfig: The default NxWM not uses the STMPE11
touchscreen.
* include/cxx/csched: Added
* graphic/nxmu/nxmu_sendserver.c, nxmu_sendwindow.c, and nxmu_sendclient.c:
Refactor NX messaging logic in preparation for a new message control
feature.

View File

@ -43,6 +43,6 @@ NXAPI_CSRCS = nx_bitmap.c nx_closewindow.c nx_connect.c nx_disconnect.c \
nx_fillcircle.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_semtake.c \
nxmu_server.c
nxmu_requestbkgd.c nxmu_reportposition.c nxmu_sendclient.c \
nxmu_sendserver.c nxmu_sendwindow.c nxmu_semtake.c nxmu_server.c
NX_CSRCS = $(NXAPI_CSRCS) $(NXMU_CSRCS)

View File

@ -1,8 +1,8 @@
/****************************************************************************
* graphics/nxmu/nx_bitmap.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
@ -99,11 +99,10 @@ int nx_bitmap(NXWINDOW hwnd, FAR const struct nxgl_rect_s *dest,
{
FAR struct nxbe_window_s *wnd = (FAR struct nxbe_window_s *)hwnd;
struct nxsvrmsg_bitmap_s outmsg;
int ret;
int i;
#ifdef CONFIG_DEBUG
if (!wnd || !wnd->conn || !dest || !src || !origin)
if (!wnd || !dest || !src || !origin)
{
errno = EINVAL;
return ERROR;
@ -127,10 +126,5 @@ int nx_bitmap(NXWINDOW hwnd, FAR const struct nxgl_rect_s *dest,
/* Forward the fill command to the server */
ret = mq_send(wnd->conn->cwrmq, &outmsg, sizeof(struct nxsvrmsg_bitmap_s), NX_SVRMSG_PRIO);
if (ret < 0)
{
gdbg("mq_send failed: %d\n", errno);
}
return ret;
return nxmu_sendwindow(wnd, &outmsg, sizeof(struct nxsvrmsg_bitmap_s));
}

View File

@ -1,8 +1,8 @@
/****************************************************************************
* graphics/nxmu/nx_closewindow.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
@ -88,20 +88,13 @@
int nx_closewindow(NXWINDOW hwnd)
{
FAR struct nxbe_window_s *wnd = (FAR struct nxbe_window_s *)hwnd;
FAR struct nxfe_conn_s *conn = wnd->conn;
struct nxsvrmsg_closewindow_s outmsg;
int ret;
/* Request destruction of the window by the serer */
/* Request destruction of the window by the server */
outmsg.msgid = NX_SVRMSG_CLOSEWINDOW;
outmsg.wnd = wnd;
ret = mq_send(conn->cwrmq, &outmsg, sizeof(struct nxsvrmsg_closewindow_s), NX_SVRMSG_PRIO);
if (ret < 0)
{
gdbg("mq_send failed: %d\n", errno);
}
return ret;
return nxmu_sendserver(wnd->conn, &outmsg, sizeof(struct nxsvrmsg_closewindow_s));
}

View File

@ -1,8 +1,8 @@
/****************************************************************************
* graphics/nxmu/nx_connect.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
@ -113,7 +113,7 @@ static uint32_t g_nxcid = 1;
NXHANDLE nx_connectinstance(FAR const char *svrmqname)
{
FAR struct nxfe_conn_s *conn;
struct nxsvrmsg_s msg;
struct nxsvrmsg_s outmsg;
char climqname[NX_CLIENT_MXNAMELEN];
struct mq_attr attr;
int ret;
@ -177,13 +177,13 @@ NXHANDLE nx_connectinstance(FAR const char *svrmqname)
/* Inform the server that this client exists */
msg.msgid = NX_SVRMSG_CONNECT;
msg.conn = conn;
outmsg.msgid = NX_SVRMSG_CONNECT;
outmsg.conn = conn;
ret = mq_send(conn->cwrmq, &msg, sizeof(struct nxsvrmsg_s), NX_SVRMSG_PRIO);
ret = nxmu_sendserver(conn, &outmsg, sizeof(struct nxsvrmsg_s));
if (ret < 0)
{
gdbg("mq_send failed: %d\n", errno);
gdbg("nxmu_sendserver failed: %d\n", errno);
goto errout_with_wmq;
}

View File

@ -1,8 +1,8 @@
/****************************************************************************
* graphics/nxmu/nx_disconnect.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
@ -89,20 +89,15 @@
void nx_disconnect(NXHANDLE handle)
{
FAR struct nxfe_conn_s *conn = (FAR struct nxfe_conn_s *)handle;
struct nxsvrmsg_s msg;
int ret;
struct nxsvrmsg_s outmsg;
/* Inform the server that this client no longer exists */
msg.msgid = NX_SVRMSG_DISCONNECT;
msg.conn = conn;
ret = mq_send(conn->cwrmq, &msg, sizeof(struct nxsvrmsg_s), NX_SVRMSG_PRIO);
if (ret < 0)
{
gdbg("mq_send failed: %d\n", errno);
}
outmsg.msgid = NX_SVRMSG_DISCONNECT;
outmsg.conn = conn;
/* We will finish the teardown upon receipt of the DISCONNECTED message */
return nxmu_sendserver(conn, &outmsg, sizeof(struct nxsvrmsg_s));
}

View File

@ -1,8 +1,8 @@
/****************************************************************************
* graphics/nxmu/nx_fill.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
@ -93,10 +93,9 @@ int nx_fill(NXWINDOW hwnd, FAR const struct nxgl_rect_s *rect,
{
FAR struct nxbe_window_s *wnd = (FAR struct nxbe_window_s *)hwnd;
struct nxsvrmsg_fill_s outmsg;
int ret;
#ifdef CONFIG_DEBUG
if (!wnd || !wnd->conn || !rect || !color)
if (!wnd || !rect || !color)
{
errno = EINVAL;
return ERROR;
@ -113,10 +112,5 @@ int nx_fill(NXWINDOW hwnd, FAR const struct nxgl_rect_s *rect,
/* Forward the fill command to the server */
ret = mq_send(wnd->conn->cwrmq, &outmsg, sizeof(struct nxsvrmsg_fill_s), NX_SVRMSG_PRIO);
if (ret < 0)
{
gdbg("mq_send failed: %d\n", errno);
}
return ret;
return nxmu_sendwindow(wnd, &outmsg, sizeof(struct nxsvrmsg_fill_s));
}

View File

@ -94,14 +94,13 @@ int nx_filltrapezoid(NXWINDOW hwnd, FAR const struct nxgl_rect_s *clip,
nxgl_mxpixel_t color[CONFIG_NX_NPLANES])
{
FAR struct nxbe_window_s *wnd = (FAR struct nxbe_window_s *)hwnd;
struct nxsvrmsg_filltrapezoid_s outmsg;
int ret;
struct nxsvrmsg_filltrapezoid_s outmsg;
int i;
/* Some debug-only sanity checks */
#ifdef CONFIG_DEBUG
if (!wnd || !wnd->conn || !trap || !color)
if (!wnd || !trap || !color)
{
errno = EINVAL;
return ERROR;
@ -139,11 +138,5 @@ int nx_filltrapezoid(NXWINDOW hwnd, FAR const struct nxgl_rect_s *clip,
/* Forward the trapezoid fill command to the server */
ret = mq_send(wnd->conn->cwrmq, &outmsg,
sizeof(struct nxsvrmsg_filltrapezoid_s), NX_SVRMSG_PRIO);
if (ret < 0)
{
gdbg("mq_send failed: %d\n", errno);
}
return ret;
return nxmu_sendwindow(wnd, &outmsg, sizeof(struct nxsvrmsg_filltrapezoid_s));
}

View File

@ -1,8 +1,8 @@
/****************************************************************************
* graphics/nxmu/nx_getposition.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
@ -87,9 +87,8 @@
int nx_getposition(NXWINDOW hwnd)
{
FAR struct nxbe_window_s *wnd = (FAR struct nxbe_window_s *)hwnd;
FAR struct nxbe_window_s *wnd = (FAR struct nxbe_window_s *)hwnd;
struct nxsvrmsg_getposition_s outmsg;
int ret;
#ifdef CONFIG_DEBUG
if (!wnd)
@ -111,12 +110,5 @@ int nx_getposition(NXWINDOW hwnd)
outmsg.msgid = NX_SVRMSG_GETPOSITION;
outmsg.wnd = wnd;
ret = mq_send(wnd->conn->cwrmq, &outmsg, sizeof(struct nxsvrmsg_getposition_s), NX_SVRMSG_PRIO);
if (ret < 0)
{
gdbg("mq_send failed: %d\n", errno);
return ERROR;
}
return OK;
return nxmu_sendwindow(wnd, &outmsg, sizeof(struct nxsvrmsg_getposition_s));
}

View File

@ -1,7 +1,7 @@
/****************************************************************************
* graphics/nxmu/nx_getrectangle.c
*
* Copyright (C) 2011 Gregory Nutt. All rights reserved.
* Copyright (C) 2011-2012 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -98,7 +98,6 @@ int nx_getrectangle(NXWINDOW hwnd, FAR const struct nxgl_rect_s *rect,
{
FAR struct nxbe_window_s *wnd = (FAR struct nxbe_window_s *)hwnd;
struct nxsvrmsg_getrectangle_s outmsg;
int ret;
#ifdef CONFIG_DEBUG
if (!hwnd || !rect || !dest)
@ -121,10 +120,5 @@ int nx_getrectangle(NXWINDOW hwnd, FAR const struct nxgl_rect_s *rect,
/* Forward the fill command to the server */
ret = mq_send(wnd->conn->cwrmq, &outmsg, sizeof(struct nxsvrmsg_getrectangle_s), NX_SVRMSG_PRIO);
if (ret < 0)
{
gdbg("mq_send failed: %d\n", errno);
}
return ret;
return nxmu_sendwindow(wnd, &outmsg, sizeof(struct nxsvrmsg_getrectangle_s));
}

View File

@ -1,8 +1,8 @@
/****************************************************************************
* graphics/nxmu/nx_kbdchin.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
@ -85,8 +85,7 @@
int nx_kbdchin(NXHANDLE handle, uint8_t ch)
{
FAR struct nxfe_conn_s *conn = (FAR struct nxfe_conn_s *)handle;
struct nxsvrmsg_kbdin_s outmsg;
int ret;
struct nxsvrmsg_kbdin_s outmsg;
/* Inform the server of the new keypad data */
@ -94,12 +93,7 @@ int nx_kbdchin(NXHANDLE handle, uint8_t ch)
outmsg.nch = 1;
outmsg.ch[0] = ch;
ret = mq_send(conn->cwrmq, &outmsg, sizeof(struct nxsvrmsg_kbdin_s), NX_SVRMSG_PRIO);
if (ret < 0)
{
gdbg("mq_send failed: %d\n", errno);
}
return ret;
return nxmu_sendserver(conn, &outmsg, sizeof(struct nxsvrmsg_kbdin_s));
}
#endif /* CONFIG_NX_KBD */

View File

@ -1,8 +1,8 @@
/****************************************************************************
* graphics/nxmu/nx_kbdin.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
@ -85,7 +85,7 @@
int nx_kbdin(NXHANDLE handle, uint8_t nch, FAR const uint8_t *ch)
{
FAR struct nxfe_conn_s *conn = (FAR struct nxfe_conn_s *)handle;
FAR struct nxfe_conn_s *conn = (FAR struct nxfe_conn_s *)handle;
FAR struct nxsvrmsg_kbdin_s *outmsg;
int size;
int ret;
@ -113,11 +113,7 @@ int nx_kbdin(NXHANDLE handle, uint8_t nch, FAR const uint8_t *ch)
outmsg->ch[i] = ch[i];
}
ret = mq_send(conn->cwrmq, outmsg, size, NX_SVRMSG_PRIO);
if (ret < 0)
{
gdbg("mq_send failed: %d\n", errno);
}
ret = nxmu_sendserver(conn, &outmsg, size);
free(outmsg);
return ret;

View File

@ -1,8 +1,8 @@
/****************************************************************************
* graphics/nxmu/nx_lower.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
@ -86,19 +86,13 @@
int nx_lower(NXWINDOW hwnd)
{
FAR struct nxbe_window_s *wnd = (FAR struct nxbe_window_s *)hwnd;
struct nxsvrmsg_lower_s outmsg;
int ret;
struct nxsvrmsg_lower_s outmsg;
/* Send the RAISE message */
outmsg.msgid = NX_SVRMSG_LOWER;
outmsg.wnd = wnd;
ret = mq_send(wnd->conn->cwrmq, &outmsg, sizeof(struct nxsvrmsg_lower_s), NX_SVRMSG_PRIO);
if (ret < 0)
{
gdbg("mq_send failed: %d\n", errno);
}
return ret;
return nxmu_sendwindow(wnd, &outmsg, sizeof(struct nxsvrmsg_lower_s));
}

View File

@ -1,8 +1,8 @@
/****************************************************************************
* graphics/nxmu/nx_mousein.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
@ -86,7 +86,6 @@ int nx_mousein(NXHANDLE handle, nxgl_coord_t x, nxgl_coord_t y, uint8_t buttons)
{
FAR struct nxfe_conn_s *conn = (FAR struct nxfe_conn_s *)handle;
struct nxsvrmsg_mousein_s outmsg;
int ret;
/* Inform the server that this client no longer exists */
@ -95,12 +94,7 @@ int nx_mousein(NXHANDLE handle, nxgl_coord_t x, nxgl_coord_t y, uint8_t buttons)
outmsg.pt.y = y;
outmsg.buttons = buttons;
ret = mq_send(conn->cwrmq, &outmsg, sizeof(struct nxsvrmsg_mousein_s), NX_SVRMSG_PRIO);
if (ret < 0)
{
gdbg("mq_send failed: %d\n", errno);
}
return ret;
return nxmu_sendserver(conn, &outmsg, sizeof(struct nxsvrmsg_mousein_s));
}
#endif /* CONFIG_NX_MOUSE */

View File

@ -89,11 +89,10 @@ int nx_move(NXWINDOW hwnd, FAR const struct nxgl_rect_s *rect,
FAR const struct nxgl_point_s *offset)
{
FAR struct nxbe_window_s *wnd = (FAR struct nxbe_window_s *)hwnd;
struct nxsvrmsg_move_s outmsg;
int ret;
struct nxsvrmsg_move_s outmsg;
#ifdef CONFIG_DEBUG
if (!wnd || !wnd->conn)
if (!wnd)
{
errno = EINVAL;
return ERROR;
@ -111,10 +110,5 @@ int nx_move(NXWINDOW hwnd, FAR const struct nxgl_rect_s *rect,
/* Forward the fill command to the server */
ret = mq_send(wnd->conn->cwrmq, &outmsg, sizeof(struct nxsvrmsg_move_s), NX_SVRMSG_PRIO);
if (ret < 0)
{
gdbg("mq_send failed: %d\n", errno);
}
return ret;
return nxmu_sendwindow(wnd, &outmsg, sizeof(struct nxsvrmsg_move_s));
}

View File

@ -1,8 +1,8 @@
/****************************************************************************
* graphics/nxmu/nx_raise.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
@ -87,18 +87,12 @@ int nx_raise(NXWINDOW hwnd)
{
FAR struct nxbe_window_s *wnd = (FAR struct nxbe_window_s *)hwnd;
struct nxsvrmsg_raise_s outmsg;
int ret;
/* Send the RAISE message */
outmsg.msgid = NX_SVRMSG_RAISE;
outmsg.wnd = wnd;
ret = mq_send(wnd->conn->cwrmq, &outmsg, sizeof(struct nxsvrmsg_raise_s), NX_SVRMSG_PRIO);
if (ret < 0)
{
gdbg("mq_send failed: %d\n", errno);
}
return ret;
return nxmu_sendwindow(wnd, &outmsg, sizeof(struct nxsvrmsg_raise_s));
}

View File

@ -88,7 +88,6 @@ int nx_releasebkgd(NXWINDOW hwnd)
{
FAR struct nxbe_window_s *wnd = (FAR struct nxbe_window_s *)hwnd;
struct nxsvrmsg_releasebkgd_s outmsg;
int ret;
#ifdef CONFIG_DEBUG
if (!wnd)
@ -101,12 +100,6 @@ int nx_releasebkgd(NXWINDOW hwnd)
/* Request access to the background window from the server */
outmsg.msgid = NX_SVRMSG_RELEASEBKGD;
ret = mq_send(wnd->conn->cwrmq, &outmsg, sizeof(struct nxsvrmsg_releasebkgd_s), NX_SVRMSG_PRIO);
if (ret < 0)
{
gdbg("mq_send failed: %d\n", errno);
return ERROR;
}
return OK;
return nxmu_sendserver(wnd->conn, &outmsg, sizeof(struct nxsvrmsg_releasebkgd_s));
}

View File

@ -1,8 +1,8 @@
/****************************************************************************
* graphics/nxmu/nx_requestbkgd.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
@ -115,7 +115,6 @@ int nx_requestbkgd(NXHANDLE handle, FAR const struct nx_callback_s *cb,
{
FAR struct nxfe_conn_s *conn = (FAR struct nxfe_conn_s *)handle;
struct nxsvrmsg_requestbkgd_s outmsg;
int ret;
#ifdef CONFIG_DEBUG
if (!conn || !cb)
@ -132,12 +131,6 @@ int nx_requestbkgd(NXHANDLE handle, FAR const struct nx_callback_s *cb,
outmsg.cb = cb;
outmsg.arg = arg;
ret = mq_send(conn->cwrmq, &outmsg, sizeof(struct nxsvrmsg_requestbkgd_s), NX_SVRMSG_PRIO);
if (ret < 0)
{
gdbg("mq_send failed: %d\n", errno);
return ERROR;
}
return OK;
return nxmu_sendserver(conn, &outmsg, sizeof(struct nxsvrmsg_requestbkgd_s));
}

View File

@ -1,8 +1,8 @@
/****************************************************************************
* graphics/nxmu/nx_setbgcolor.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
@ -89,7 +89,6 @@ int nx_setbgcolor(NXHANDLE handle,
{
FAR struct nxfe_conn_s *conn = (FAR struct nxfe_conn_s *)handle;
struct nxsvrmsg_setbgcolor_s outmsg;
int ret;
#ifdef CONFIG_DEBUG
if (!conn)
@ -106,10 +105,5 @@ int nx_setbgcolor(NXHANDLE handle,
/* Forward the fill command to the server */
ret = mq_send(conn->cwrmq, &outmsg, sizeof(struct nxsvrmsg_setbgcolor_s), NX_SVRMSG_PRIO);
if (ret < 0)
{
gdbg("mq_send failed: %d\n", errno);
}
return ret;
return nxmu_sendserver(conn, &outmsg, sizeof(struct nxsvrmsg_setbgcolor_s));
}

View File

@ -1,7 +1,7 @@
/****************************************************************************
* graphics/nxmu/nx_setpixel.c
*
* Copyright (C) 2011 Gregory Nutt. All rights reserved.
* Copyright (C) 2011-2012 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -94,10 +94,9 @@ int nx_setpixel(NXWINDOW hwnd, FAR const struct nxgl_point_s *pos,
{
FAR struct nxbe_window_s *wnd = (FAR struct nxbe_window_s *)hwnd;
struct nxsvrmsg_setpixel_s outmsg;
int ret;
#ifdef CONFIG_DEBUG
if (!wnd || !wnd->conn || !pos || !color)
if (!wnd || !pos || !color)
{
set_errno(EINVAL);
return ERROR;
@ -115,10 +114,5 @@ int nx_setpixel(NXWINDOW hwnd, FAR const struct nxgl_point_s *pos,
/* Forward the fill command to the server */
ret = mq_send(wnd->conn->cwrmq, &outmsg, sizeof(struct nxsvrmsg_setpixel_s), NX_SVRMSG_PRIO);
if (ret < 0)
{
gdbg("mq_send failed: %d\n", errno);
}
return ret;
return nxmu_sendwindow(wnd, &outmsg, sizeof(struct nxsvrmsg_setpixel_s));
}

View File

@ -1,8 +1,8 @@
/****************************************************************************
* graphics/nxmu/nx_setposition.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
@ -86,9 +86,8 @@
int nx_setposition(NXWINDOW hwnd, FAR const struct nxgl_point_s *pos)
{
FAR struct nxbe_window_s *wnd = (FAR struct nxbe_window_s *)hwnd;
FAR struct nxbe_window_s *wnd = (FAR struct nxbe_window_s *)hwnd;
struct nxsvrmsg_setposition_s outmsg;
int ret;
#ifdef CONFIG_DEBUG
if (!wnd || !pos)
@ -105,12 +104,5 @@ int nx_setposition(NXWINDOW hwnd, FAR const struct nxgl_point_s *pos)
outmsg.pos.x = pos->x;
outmsg.pos.y = pos->y;
ret = mq_send(wnd->conn->cwrmq, &outmsg, sizeof(struct nxsvrmsg_setposition_s), NX_SVRMSG_PRIO);
if (ret < 0)
{
gdbg("mq_send failed: %d\n", errno);
return ERROR;
}
return OK;
return nxmu_sendwindow(wnd, &outmsg, sizeof(struct nxsvrmsg_setposition_s));
}

View File

@ -1,8 +1,8 @@
/****************************************************************************
* graphics/nxmu/nx_setsize.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
@ -86,9 +86,8 @@
int nx_setsize(NXWINDOW hwnd, FAR const struct nxgl_size_s *size)
{
FAR struct nxbe_window_s *wnd = (FAR struct nxbe_window_s *)hwnd;
FAR struct nxbe_window_s *wnd = (FAR struct nxbe_window_s *)hwnd;
struct nxsvrmsg_setsize_s outmsg;
int ret;
#ifdef CONFIG_DEBUG
if (!wnd || !size)
@ -105,12 +104,5 @@ int nx_setsize(NXWINDOW hwnd, FAR const struct nxgl_size_s *size)
outmsg.size.w = size->w;
outmsg.size.h = size->h;
ret = mq_send(wnd->conn->cwrmq, &outmsg, sizeof(struct nxsvrmsg_setsize_s), NX_SVRMSG_PRIO);
if (ret < 0)
{
gdbg("mq_send failed: %d\n", errno);
return ERROR;
}
return OK;
return nxmu_sendwindow(wnd, &outmsg, sizeof(struct nxsvrmsg_setsize_s));
}

View File

@ -1,7 +1,7 @@
/****************************************************************************
* graphics/nxmu/nxfe.h
*
* Copyright (C) 2008-2011 Gregory Nutt. All rights reserved.
* Copyright (C) 2008-2012 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -502,6 +502,64 @@ EXTERN int nxfe_constructwindow(NXHANDLE handle,
EXTERN void nxmu_semtake(sem_t *sem);
/****************************************************************************
* 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
*
****************************************************************************/
EXTERN int nxmu_sendserver(FAR struct nxfe_conn_s *conn,
FAR const void *msg, size_t msglen);
/****************************************************************************
* 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
*
****************************************************************************/
EXTERN int nxmu_sendwindow(FAR struct nxbe_window_s *wnd, FAR const void *msg,
size_t msglen);
/****************************************************************************
* 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
*
****************************************************************************/
EXTERN int nxmu_sendclient(FAR struct nxfe_conn_s *conn,
FAR const void *msg, size_t msglen);
/****************************************************************************
* Name: nxmu_openwindow
*

View File

@ -1,8 +1,8 @@
/****************************************************************************
* graphics/nxmu/nx_openwindow.c
*
* Copyright (C) 2008, 2011 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
* Copyright (C) 2008, 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
@ -103,7 +103,6 @@ int nxfe_constructwindow(NXHANDLE handle, FAR struct nxbe_window_s *wnd,
{
FAR struct nxfe_conn_s *conn = (FAR struct nxfe_conn_s *)handle;
struct nxsvrmsg_openwindow_s outmsg;
int ret;
#ifdef CONFIG_DEBUG
if (!wnd)
@ -133,14 +132,6 @@ int nxfe_constructwindow(NXHANDLE handle, FAR struct nxbe_window_s *wnd,
outmsg.msgid = NX_SVRMSG_OPENWINDOW;
outmsg.wnd = wnd;
ret = mq_send(conn->cwrmq, &outmsg, sizeof(struct nxsvrmsg_openwindow_s), NX_SVRMSG_PRIO);
if (ret < 0)
{
gdbg("mq_send failed: %d\n", errno);
free(wnd);
return ERROR;
}
return OK;
return nxmu_sendserver(conn, &outmsg, sizeof(struct nxsvrmsg_openwindow_s));
}

View File

@ -1,8 +1,8 @@
/****************************************************************************
* graphics/nxmu/nxmu_kbdin.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
@ -87,7 +87,6 @@ void nxmu_kbdin(FAR struct nxfe_state_s *fe, uint8_t nch, FAR uint8_t *ch)
{
FAR struct nxclimsg_kbdin_s *outmsg;
int size;
int ret;
int i;
/* Allocate a bigger message to account for the variable amount of
@ -109,11 +108,7 @@ void nxmu_kbdin(FAR struct nxfe_state_s *fe, uint8_t nch, FAR uint8_t *ch)
outmsg->ch[i] = ch[i];
}
ret = mq_send(fe->be.topwnd->conn->swrmq, outmsg, size, NX_SVRMSG_PRIO);
if (ret < 0)
{
gdbg("mq_send failed: %d\n", errno);
}
(void)nxmu_sendclient(fe->be.topwnd->conn, outmsg, size);
free(outmsg);
}
}

View File

@ -111,7 +111,6 @@ void nxmu_mouseinit(int x, int y)
int nxmu_mousereport(struct nxbe_window_s *wnd)
{
struct nxclimsg_mousein_s outmsg;
int ret;
/* Does this window support mouse callbacks? */
@ -130,13 +129,7 @@ int nxmu_mousereport(struct nxbe_window_s *wnd)
outmsg.buttons = g_mbutton;
nxgl_vectsubtract(&outmsg.pos, &g_mpos, &wnd->bounds.pt1);
ret = mq_send(wnd->conn->swrmq, &outmsg,
sizeof(struct nxclimsg_mousein_s), NX_SVRMSG_PRIO);
if (ret < 0)
{
gdbg("mq_send failed: %d\n", errno);
}
return ret;
return nxmu_sendclient(wnd->conn, &outmsg, sizeof(struct nxclimsg_mousein_s));
}
}

View File

@ -1,8 +1,8 @@
/****************************************************************************
* graphics/nxmu/nxmu_redrawreq.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
@ -81,18 +81,13 @@
void nxfe_redrawreq(FAR struct nxbe_window_s *wnd, FAR const struct nxgl_rect_s *rect)
{
struct nxclimsg_redraw_s outmsg;
int ret;
outmsg.msgid = NX_CLIMSG_REDRAW;
outmsg.wnd = wnd;
outmsg.more = false;
nxgl_rectoffset(&outmsg.rect, rect, -wnd->bounds.pt1.x, -wnd->bounds.pt1.y);
ret = mq_send(wnd->conn->swrmq, &outmsg, sizeof(struct nxclimsg_redraw_s), NX_CLIMSG_PRIO);
if (ret < 0)
{
gdbg("mq_send failed: %d\n", errno);
}
(void)nxmu_sendclient(wnd->conn, &outmsg, sizeof(struct nxclimsg_redraw_s));
}

View File

@ -1,8 +1,8 @@
/****************************************************************************
* graphics/nxmu/nxmu_reportposition.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
@ -100,9 +100,9 @@ void nxfe_reportposition(FAR struct nxbe_window_s *wnd)
/* And provide this to the client */
ret = mq_send(wnd->conn->swrmq, &outmsg, sizeof(struct nxclimsg_newposition_s), NX_SVRMSG_PRIO);
ret = nxmu_sendclient(wnd->conn, &outmsg, sizeof(struct nxclimsg_newposition_s));
if (ret < 0)
{
gdbg("mq_send failed: %d\n", errno);
gdbg("nxmu_sendclient failed: %d\n", errno);
}
}

View File

@ -84,10 +84,10 @@ static inline void nxmu_disconnect(FAR struct nxfe_conn_s *conn)
outmsg.msgid = NX_CLIMSG_DISCONNECTED;
ret = mq_send(conn->swrmq, &outmsg, sizeof(struct nxclimsg_disconnected_s), NX_CLIMSG_PRIO);
ret = nxmu_sendclient(conn, &outmsg, sizeof(struct nxclimsg_disconnected_s));
if (ret < 0)
{
gdbg("mq_send failed: %d\n", errno);
gdbg("nxmu_sendclient failed: %d\n", errno);
}
/* Close the outgoing client message queue */
@ -121,11 +121,10 @@ static inline void nxmu_connect(FAR struct nxfe_conn_s *conn)
/* Send the handshake message back to the client */
outmsg.msgid = NX_CLIMSG_CONNECTED;
ret = mq_send(conn->swrmq, &outmsg, sizeof(struct nxclimsg_connected_s), NX_CLIMSG_PRIO);
ret = nxmu_sendclient(conn, &outmsg, sizeof(struct nxclimsg_connected_s));
if (ret < 0)
{
gdbg("mq_send failed: %d\n", errno);
gdbg("nxmu_sendclient failed: %d\n", errno);
}
}