From 7c97dbdf4411e96682a56267b4c095574dfe604d Mon Sep 17 00:00:00 2001 From: patacongo Date: Thu, 17 May 2012 19:32:48 +0000 Subject: 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 --- nuttx/graphics/nxmu/Make.defs | 4 +- nuttx/graphics/nxmu/nx_bitmap.c | 14 ++----- nuttx/graphics/nxmu/nx_closewindow.c | 15 ++------ nuttx/graphics/nxmu/nx_connect.c | 14 +++---- nuttx/graphics/nxmu/nx_disconnect.c | 19 ++++------ nuttx/graphics/nxmu/nx_fill.c | 14 ++----- nuttx/graphics/nxmu/nx_filltrapezoid.c | 13 ++----- nuttx/graphics/nxmu/nx_getposition.c | 16 ++------ nuttx/graphics/nxmu/nx_getrectangle.c | 10 +---- nuttx/graphics/nxmu/nx_kbdchin.c | 14 ++----- nuttx/graphics/nxmu/nx_kbdin.c | 12 ++---- nuttx/graphics/nxmu/nx_lower.c | 14 ++----- nuttx/graphics/nxmu/nx_mousein.c | 12 ++---- nuttx/graphics/nxmu/nx_move.c | 12 ++---- nuttx/graphics/nxmu/nx_raise.c | 12 ++---- nuttx/graphics/nxmu/nx_releasebkgd.c | 9 +---- nuttx/graphics/nxmu/nx_requestbkgd.c | 13 ++----- nuttx/graphics/nxmu/nx_setbgcolor.c | 12 ++---- nuttx/graphics/nxmu/nx_setpixel.c | 12 ++---- nuttx/graphics/nxmu/nx_setposition.c | 16 ++------ nuttx/graphics/nxmu/nx_setsize.c | 16 ++------ nuttx/graphics/nxmu/nxfe.h | 60 +++++++++++++++++++++++++++++- nuttx/graphics/nxmu/nxmu_constructwindow.c | 15 ++------ nuttx/graphics/nxmu/nxmu_kbdin.c | 11 ++---- nuttx/graphics/nxmu/nxmu_mouse.c | 9 +---- nuttx/graphics/nxmu/nxmu_redrawreq.c | 11 ++---- nuttx/graphics/nxmu/nxmu_reportposition.c | 8 ++-- nuttx/graphics/nxmu/nxmu_server.c | 9 ++--- 28 files changed, 153 insertions(+), 243 deletions(-) (limited to 'nuttx/graphics') diff --git a/nuttx/graphics/nxmu/Make.defs b/nuttx/graphics/nxmu/Make.defs index 6b4295290..b1370640c 100644 --- a/nuttx/graphics/nxmu/Make.defs +++ b/nuttx/graphics/nxmu/Make.defs @@ -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) diff --git a/nuttx/graphics/nxmu/nx_bitmap.c b/nuttx/graphics/nxmu/nx_bitmap.c index 6e16b2c34..a86eda96a 100644 --- a/nuttx/graphics/nxmu/nx_bitmap.c +++ b/nuttx/graphics/nxmu/nx_bitmap.c @@ -1,8 +1,8 @@ /**************************************************************************** * graphics/nxmu/nx_bitmap.c * - * Copyright (C) 2008-2009, 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt + * Copyright (C) 2008-2009, 2011-2012 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt * * 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)); } diff --git a/nuttx/graphics/nxmu/nx_closewindow.c b/nuttx/graphics/nxmu/nx_closewindow.c index 22583f41b..f9722fcd2 100644 --- a/nuttx/graphics/nxmu/nx_closewindow.c +++ b/nuttx/graphics/nxmu/nx_closewindow.c @@ -1,8 +1,8 @@ /**************************************************************************** * graphics/nxmu/nx_closewindow.c * - * Copyright (C) 2008-2009, 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt + * Copyright (C) 2008-2009, 2011-2012 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt * * 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)); } diff --git a/nuttx/graphics/nxmu/nx_connect.c b/nuttx/graphics/nxmu/nx_connect.c index e872f3505..4d91b54d5 100644 --- a/nuttx/graphics/nxmu/nx_connect.c +++ b/nuttx/graphics/nxmu/nx_connect.c @@ -1,8 +1,8 @@ /**************************************************************************** * graphics/nxmu/nx_connect.c * - * Copyright (C) 2008-2009, 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt + * Copyright (C) 2008-2009, 2011-2012 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt * * 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; } diff --git a/nuttx/graphics/nxmu/nx_disconnect.c b/nuttx/graphics/nxmu/nx_disconnect.c index f4711b005..bbbf05251 100644 --- a/nuttx/graphics/nxmu/nx_disconnect.c +++ b/nuttx/graphics/nxmu/nx_disconnect.c @@ -1,8 +1,8 @@ /**************************************************************************** * graphics/nxmu/nx_disconnect.c * - * Copyright (C) 2008-2009, 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt + * Copyright (C) 2008-2009, 2011-2012 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt * * 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)); } diff --git a/nuttx/graphics/nxmu/nx_fill.c b/nuttx/graphics/nxmu/nx_fill.c index 1b75cd974..969acdace 100644 --- a/nuttx/graphics/nxmu/nx_fill.c +++ b/nuttx/graphics/nxmu/nx_fill.c @@ -1,8 +1,8 @@ /**************************************************************************** * graphics/nxmu/nx_fill.c * - * Copyright (C) 2008-2009, 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt + * Copyright (C) 2008-2009, 2011-2012 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt * * 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)); } diff --git a/nuttx/graphics/nxmu/nx_filltrapezoid.c b/nuttx/graphics/nxmu/nx_filltrapezoid.c index f0a55fc62..bf289179e 100644 --- a/nuttx/graphics/nxmu/nx_filltrapezoid.c +++ b/nuttx/graphics/nxmu/nx_filltrapezoid.c @@ -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)); } diff --git a/nuttx/graphics/nxmu/nx_getposition.c b/nuttx/graphics/nxmu/nx_getposition.c index d53ddf14b..06ad2c6aa 100644 --- a/nuttx/graphics/nxmu/nx_getposition.c +++ b/nuttx/graphics/nxmu/nx_getposition.c @@ -1,8 +1,8 @@ /**************************************************************************** * graphics/nxmu/nx_getposition.c * - * Copyright (C) 2008-2009, 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt + * Copyright (C) 2008-2009, 2011-2012 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt * * 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)); } diff --git a/nuttx/graphics/nxmu/nx_getrectangle.c b/nuttx/graphics/nxmu/nx_getrectangle.c index 85393f7d2..f32065129 100644 --- a/nuttx/graphics/nxmu/nx_getrectangle.c +++ b/nuttx/graphics/nxmu/nx_getrectangle.c @@ -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 * * 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)); } diff --git a/nuttx/graphics/nxmu/nx_kbdchin.c b/nuttx/graphics/nxmu/nx_kbdchin.c index 9393e1253..6c7019f51 100644 --- a/nuttx/graphics/nxmu/nx_kbdchin.c +++ b/nuttx/graphics/nxmu/nx_kbdchin.c @@ -1,8 +1,8 @@ /**************************************************************************** * graphics/nxmu/nx_kbdchin.c * - * Copyright (C) 2008-2009, 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt + * Copyright (C) 2008-2009, 2011-2012 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt * * 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 */ diff --git a/nuttx/graphics/nxmu/nx_kbdin.c b/nuttx/graphics/nxmu/nx_kbdin.c index c265f86c1..ac044bec7 100644 --- a/nuttx/graphics/nxmu/nx_kbdin.c +++ b/nuttx/graphics/nxmu/nx_kbdin.c @@ -1,8 +1,8 @@ /**************************************************************************** * graphics/nxmu/nx_kbdin.c * - * Copyright (C) 2008-2009, 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt + * Copyright (C) 2008-2009, 2011-2012 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt * * 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; diff --git a/nuttx/graphics/nxmu/nx_lower.c b/nuttx/graphics/nxmu/nx_lower.c index 6ff57c782..c9505ca49 100644 --- a/nuttx/graphics/nxmu/nx_lower.c +++ b/nuttx/graphics/nxmu/nx_lower.c @@ -1,8 +1,8 @@ /**************************************************************************** * graphics/nxmu/nx_lower.c * - * Copyright (C) 2008-2009, 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt + * Copyright (C) 2008-2009, 2011-2012 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt * * 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)); } diff --git a/nuttx/graphics/nxmu/nx_mousein.c b/nuttx/graphics/nxmu/nx_mousein.c index 10d32afbb..e84278539 100644 --- a/nuttx/graphics/nxmu/nx_mousein.c +++ b/nuttx/graphics/nxmu/nx_mousein.c @@ -1,8 +1,8 @@ /**************************************************************************** * graphics/nxmu/nx_mousein.c * - * Copyright (C) 2008-2009, 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt + * Copyright (C) 2008-2009, 2011-2012 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt * * 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 */ diff --git a/nuttx/graphics/nxmu/nx_move.c b/nuttx/graphics/nxmu/nx_move.c index 3f4a00e2f..c8d4d3dfd 100644 --- a/nuttx/graphics/nxmu/nx_move.c +++ b/nuttx/graphics/nxmu/nx_move.c @@ -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)); } diff --git a/nuttx/graphics/nxmu/nx_raise.c b/nuttx/graphics/nxmu/nx_raise.c index 78508d749..4f51810f1 100644 --- a/nuttx/graphics/nxmu/nx_raise.c +++ b/nuttx/graphics/nxmu/nx_raise.c @@ -1,8 +1,8 @@ /**************************************************************************** * graphics/nxmu/nx_raise.c * - * Copyright (C) 2008-2009, 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt + * Copyright (C) 2008-2009, 2011-2012 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt * * 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)); } diff --git a/nuttx/graphics/nxmu/nx_releasebkgd.c b/nuttx/graphics/nxmu/nx_releasebkgd.c index 99815b1e7..972585663 100644 --- a/nuttx/graphics/nxmu/nx_releasebkgd.c +++ b/nuttx/graphics/nxmu/nx_releasebkgd.c @@ -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)); } diff --git a/nuttx/graphics/nxmu/nx_requestbkgd.c b/nuttx/graphics/nxmu/nx_requestbkgd.c index e6367a4f7..c8f71ab2a 100644 --- a/nuttx/graphics/nxmu/nx_requestbkgd.c +++ b/nuttx/graphics/nxmu/nx_requestbkgd.c @@ -1,8 +1,8 @@ /**************************************************************************** * graphics/nxmu/nx_requestbkgd.c * - * Copyright (C) 2008-2009, 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt + * Copyright (C) 2008-2009, 2011-2012 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt * * 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)); } diff --git a/nuttx/graphics/nxmu/nx_setbgcolor.c b/nuttx/graphics/nxmu/nx_setbgcolor.c index c2346fb39..63fca5f55 100644 --- a/nuttx/graphics/nxmu/nx_setbgcolor.c +++ b/nuttx/graphics/nxmu/nx_setbgcolor.c @@ -1,8 +1,8 @@ /**************************************************************************** * graphics/nxmu/nx_setbgcolor.c * - * Copyright (C) 2008-2009, 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt + * Copyright (C) 2008-2009, 2011-2012 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt * * 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)); } diff --git a/nuttx/graphics/nxmu/nx_setpixel.c b/nuttx/graphics/nxmu/nx_setpixel.c index 35617646e..57fc12cc6 100644 --- a/nuttx/graphics/nxmu/nx_setpixel.c +++ b/nuttx/graphics/nxmu/nx_setpixel.c @@ -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 * * 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)); } diff --git a/nuttx/graphics/nxmu/nx_setposition.c b/nuttx/graphics/nxmu/nx_setposition.c index 1e59c10e2..75b33757a 100644 --- a/nuttx/graphics/nxmu/nx_setposition.c +++ b/nuttx/graphics/nxmu/nx_setposition.c @@ -1,8 +1,8 @@ /**************************************************************************** * graphics/nxmu/nx_setposition.c * - * Copyright (C) 2008-2009, 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt + * Copyright (C) 2008-2009, 2011-2012 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt * * 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)); } diff --git a/nuttx/graphics/nxmu/nx_setsize.c b/nuttx/graphics/nxmu/nx_setsize.c index 5655e61a2..5f538bccc 100644 --- a/nuttx/graphics/nxmu/nx_setsize.c +++ b/nuttx/graphics/nxmu/nx_setsize.c @@ -1,8 +1,8 @@ /**************************************************************************** * graphics/nxmu/nx_setsize.c * - * Copyright (C) 2008-2009, 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt + * Copyright (C) 2008-2009, 2011-2012 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt * * 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)); } diff --git a/nuttx/graphics/nxmu/nxfe.h b/nuttx/graphics/nxmu/nxfe.h index b2f906f16..2b87b2a40 100644 --- a/nuttx/graphics/nxmu/nxfe.h +++ b/nuttx/graphics/nxmu/nxfe.h @@ -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 * * 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 * diff --git a/nuttx/graphics/nxmu/nxmu_constructwindow.c b/nuttx/graphics/nxmu/nxmu_constructwindow.c index 86df90e28..e5f6dcc9a 100644 --- a/nuttx/graphics/nxmu/nxmu_constructwindow.c +++ b/nuttx/graphics/nxmu/nxmu_constructwindow.c @@ -1,8 +1,8 @@ /**************************************************************************** * graphics/nxmu/nx_openwindow.c * - * Copyright (C) 2008, 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt + * Copyright (C) 2008, 2011-2012 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt * * 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)); } diff --git a/nuttx/graphics/nxmu/nxmu_kbdin.c b/nuttx/graphics/nxmu/nxmu_kbdin.c index 334d525c0..2c658009b 100644 --- a/nuttx/graphics/nxmu/nxmu_kbdin.c +++ b/nuttx/graphics/nxmu/nxmu_kbdin.c @@ -1,8 +1,8 @@ /**************************************************************************** * graphics/nxmu/nxmu_kbdin.c * - * Copyright (C) 2008-2009, 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt + * Copyright (C) 2008-2009, 2011-2012 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt * * 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); } } diff --git a/nuttx/graphics/nxmu/nxmu_mouse.c b/nuttx/graphics/nxmu/nxmu_mouse.c index 1ae31bec2..3ebe062d2 100644 --- a/nuttx/graphics/nxmu/nxmu_mouse.c +++ b/nuttx/graphics/nxmu/nxmu_mouse.c @@ -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)); } } diff --git a/nuttx/graphics/nxmu/nxmu_redrawreq.c b/nuttx/graphics/nxmu/nxmu_redrawreq.c index e4f0f7b9e..32ca477a2 100644 --- a/nuttx/graphics/nxmu/nxmu_redrawreq.c +++ b/nuttx/graphics/nxmu/nxmu_redrawreq.c @@ -1,8 +1,8 @@ /**************************************************************************** * graphics/nxmu/nxmu_redrawreq.c * - * Copyright (C) 2008-2009, 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt + * Copyright (C) 2008-2009, 2011-2012 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt * * 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)); } diff --git a/nuttx/graphics/nxmu/nxmu_reportposition.c b/nuttx/graphics/nxmu/nxmu_reportposition.c index 904198b22..f9b5f9daf 100644 --- a/nuttx/graphics/nxmu/nxmu_reportposition.c +++ b/nuttx/graphics/nxmu/nxmu_reportposition.c @@ -1,8 +1,8 @@ /**************************************************************************** * graphics/nxmu/nxmu_reportposition.c * - * Copyright (C) 2008-2009, 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt + * Copyright (C) 2008-2009, 2011-2012 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt * * 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); } } diff --git a/nuttx/graphics/nxmu/nxmu_server.c b/nuttx/graphics/nxmu/nxmu_server.c index fbd03464f..6b6009e80 100644 --- a/nuttx/graphics/nxmu/nxmu_server.c +++ b/nuttx/graphics/nxmu/nxmu_server.c @@ -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); } } -- cgit v1.2.3