From 425d0cccafae9c094fb0a0e2ed17506ae6ccfcea Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Fri, 27 Dec 2013 14:30:13 -0600 Subject: [PATCH] Decoupling NX user interfaces to support NX kernel build (phase 2) --- graphics/nxmu/Make.defs | 9 +- graphics/nxmu/nxfe.h | 3 - graphics/nxmu/nxmu_sendclientwindow.c | 113 +++++++++++++ graphics/nxmu/nxmu_sendwindow.c | 158 ------------------ include/nuttx/nx/nxmu.h | 4 + libc/nx/Make.defs | 11 +- .../nx_bitmap.c => libc/nx/lib_nx_bitmap.c | 11 +- .../nxmu/nx_fill.c => libc/nx/lib_nx_fill.c | 10 +- .../nx/lib_nx_filltrapezoid.c | 10 +- .../nx/lib_nx_getposition.c | 9 +- .../nx/lib_nx_getrectangle.c | 8 +- .../nxmu/nx_lower.c => libc/nx/lib_nx_lower.c | 7 +- .../nxmu/nx_move.c => libc/nx/lib_nx_move.c | 9 +- .../nx/lib_nx_openwindow.c | 15 +- .../nxmu/nx_raise.c => libc/nx/lib_nx_raise.c | 7 +- .../nx/lib_nx_setpixel.c | 8 +- .../nx/lib_nx_setposition.c | 9 +- .../nx_setsize.c => libc/nx/lib_nx_setsize.c | 9 +- .../nx/lib_nxmu_semtake.c | 4 +- libc/nx/lib_nxmu_sendwindow.c | 115 +++++++++++++ 20 files changed, 304 insertions(+), 225 deletions(-) create mode 100644 graphics/nxmu/nxmu_sendclientwindow.c delete mode 100644 graphics/nxmu/nxmu_sendwindow.c rename graphics/nxmu/nx_bitmap.c => libc/nx/lib_nx_bitmap.c (96%) rename graphics/nxmu/nx_fill.c => libc/nx/lib_nx_fill.c (96%) rename graphics/nxmu/nx_filltrapezoid.c => libc/nx/lib_nx_filltrapezoid.c (96%) rename graphics/nxmu/nx_getposition.c => libc/nx/lib_nx_getposition.c (96%) rename graphics/nxmu/nx_getrectangle.c => libc/nx/lib_nx_getrectangle.c (97%) rename graphics/nxmu/nx_lower.c => libc/nx/lib_nx_lower.c (96%) rename graphics/nxmu/nx_move.c => libc/nx/lib_nx_move.c (95%) rename graphics/nxmu/nx_openwindow.c => libc/nx/lib_nx_openwindow.c (93%) rename graphics/nxmu/nx_raise.c => libc/nx/lib_nx_raise.c (96%) rename graphics/nxmu/nx_setpixel.c => libc/nx/lib_nx_setpixel.c (96%) rename graphics/nxmu/nx_setposition.c => libc/nx/lib_nx_setposition.c (95%) rename graphics/nxmu/nx_setsize.c => libc/nx/lib_nx_setsize.c (95%) rename graphics/nxmu/nxmu_semtake.c => libc/nx/lib_nxmu_semtake.c (97%) create mode 100644 libc/nx/lib_nxmu_sendwindow.c diff --git a/graphics/nxmu/Make.defs b/graphics/nxmu/Make.defs index 8c75ad6e12..666caeb45a 100644 --- a/graphics/nxmu/Make.defs +++ b/graphics/nxmu/Make.defs @@ -35,14 +35,11 @@ NX_ASRCS = -NXAPI_CSRCS = nx_bitmap.c nx_eventhandler.c nx_eventnotify.c nx_fill.c -NXAPI_CSRCS += nx_filltrapezoid.c nx_getposition.c nx_getrectangle.c -NXAPI_CSRCS += nx_lower.c nx_move.c nx_openwindow.c nx_raise.c -NXAPI_CSRCS += nx_setpixel.c nx_setsize.c nx_setposition.c nx_drawcircle.c -NXAPI_CSRCS += nx_drawline.c nx_fillcircle.c +NXAPI_CSRCS = nx_eventhandler.c nx_eventnotify.c +NXAPI_CSRCS += nx_drawcircle.c nx_drawline.c nx_fillcircle.c NXMU_CSRCS = nxmu_kbdin.c nxmu_mouse.c nxmu_openwindow.c nxmu_redrawreq.c NXMU_CSRCS += nxmu_releasebkgd.c nxmu_requestbkgd.c nxmu_reportposition.c -NXMU_CSRCS += nxmu_sendclient.c nxmu_sendwindow.c nxmu_semtake.c nxmu_server.c +NXMU_CSRCS += nxmu_sendclient.c nxmu_sendclientwindow.c nxmu_server.c NX_CSRCS = $(NXAPI_CSRCS) $(NXMU_CSRCS) diff --git a/graphics/nxmu/nxfe.h b/graphics/nxmu/nxfe.h index a455f478d0..34d680b2a1 100644 --- a/graphics/nxmu/nxfe.h +++ b/graphics/nxmu/nxfe.h @@ -55,9 +55,6 @@ /**************************************************************************** * Pre-Processor Definitions ****************************************************************************/ -/* Handy macros */ - -#define nxmu_semgive(sem) sem_post(sem) /* To match nxmu_semtake() */ /**************************************************************************** * Public Types diff --git a/graphics/nxmu/nxmu_sendclientwindow.c b/graphics/nxmu/nxmu_sendclientwindow.c new file mode 100644 index 0000000000..655d815c9d --- /dev/null +++ b/graphics/nxmu/nxmu_sendclientwindow.c @@ -0,0 +1,113 @@ +/**************************************************************************** + * graphics/nxmu/nxmu_sendclientwindow.c + * + * Copyright (C) 2012-2013 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 + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include +#include + +#include "nxfe.h" + +/**************************************************************************** + * Pre-Processor Definitions + ****************************************************************************/ + +/**************************************************************************** + * Private Types + ****************************************************************************/ + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: nxmu_sendclientwindow + * + * Description: + * Send a message to the client at NX_CLIMSG_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 + * + ****************************************************************************/ + +int nxmu_sendclientwindow(FAR struct nxbe_window_s *wnd, FAR const void *msg, + size_t msglen) +{ + int ret = OK; + + /* Sanity checking */ + +#ifdef CONFIG_DEBUG + if (!wnd || !wnd->conn) + { + set_errno(EINVAL); + return ERROR; + } +#endif + + /* Ignore messages destined to a blocked window (no errors reported) */ + + if (!NXBE_ISBLOCKED(wnd)) + { + /* Send the message to the server */ + + ret = nxmu_sendclient(wnd->conn, msg, msglen); + } + + return ret; +} diff --git a/graphics/nxmu/nxmu_sendwindow.c b/graphics/nxmu/nxmu_sendwindow.c deleted file mode 100644 index 57fdd6b776..0000000000 --- a/graphics/nxmu/nxmu_sendwindow.c +++ /dev/null @@ -1,158 +0,0 @@ -/**************************************************************************** - * graphics/nxmu/nxmu_sendserver.c - * - * Copyright (C) 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 - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name NuttX nor the names of its contributors may be - * used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include - -#include -#include -#include - -#include "nxfe.h" - -/**************************************************************************** - * Pre-Processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Types - ****************************************************************************/ - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/**************************************************************************** - * Public Data - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: nxmu_sendwindow - * - * Description: - * Send a message to the server destined 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 - * - ****************************************************************************/ - -int nxmu_sendwindow(FAR struct nxbe_window_s *wnd, FAR const void *msg, - size_t msglen) -{ - int ret = OK; - - /* Sanity checking */ - -#ifdef CONFIG_DEBUG - if (!wnd || !wnd->conn) - { - errno = EINVAL; - return ERROR; - } -#endif - - /* Ignore messages destined to a blocked window (no errors reported) */ - - if (!NXBE_ISBLOCKED(wnd)) - { - /* Send the message to the server */ - - ret = nxmu_sendserver(wnd->conn, msg, msglen); - } - - return ret; -} - -/**************************************************************************** - * Name: nxmu_sendclientwindow - * - * Description: - * Send a message to the client at NX_CLIMSG_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 - * - ****************************************************************************/ - -int nxmu_sendclientwindow(FAR struct nxbe_window_s *wnd, FAR const void *msg, - size_t msglen) -{ - int ret = OK; - - /* Sanity checking */ - -#ifdef CONFIG_DEBUG - if (!wnd || !wnd->conn) - { - errno = EINVAL; - return ERROR; - } -#endif - - /* Ignore messages destined to a blocked window (no errors reported) */ - - if (!NXBE_ISBLOCKED(wnd)) - { - /* Send the message to the server */ - - ret = nxmu_sendclient(wnd->conn, msg, msglen); - } - - return ret; -} - diff --git a/include/nuttx/nx/nxmu.h b/include/nuttx/nx/nxmu.h index 55c33c6128..a6a7ac1459 100644 --- a/include/nuttx/nx/nxmu.h +++ b/include/nuttx/nx/nxmu.h @@ -83,6 +83,10 @@ #define NX_CLIMSG_PRIO 42 #define NX_SVRMSG_PRIO 42 +/* Handy macros */ + +#define nxmu_semgive(sem) sem_post(sem) /* To match nxmu_semtake() */ + /**************************************************************************** * Public Types ****************************************************************************/ diff --git a/libc/nx/Make.defs b/libc/nx/Make.defs index 57f97f65a6..8ac8adb481 100644 --- a/libc/nx/Make.defs +++ b/libc/nx/Make.defs @@ -42,10 +42,15 @@ ifeq ($(CONFIG_NX),y) # build (single use mode cannot be used with the kernel build) ifeq ($(CONFIG_NX_MULTIUSER),y) -CSRCS += lib_nxmu_sendserver.c lib_nx_connect.c lib_nx_disconnect.c lib_nx_block.c +CSRCS += lib_nxmu_sendserver.c lib_nx_connect.c lib_nx_disconnect.c +CSRCS += lib_nxmu_semtake.c lib_nx_block.c CSRCS += lib_nx_kbdchin.c lib_nx_kbdin.c lib_nx_mousein.c -CSRCS += lib_nx_closewindow.c lib_nxmu_constructwindow.c lib_nx_releasebkgd.c -CSRCS += lib_nx_requestbkgd.c lib_nx_setbgcolor.c +CSRCS += lib_nx_releasebkgd.c lib_nx_requestbkgd.c lib_nx_setbgcolor.c + +CSRCS += lib_nxmu_sendwindow.c lib_nx_closewindow.c lib_nxmu_constructwindow.c +CSRCS += lib_nx_bitmap.c lib_nx_fill.c lib_nx_filltrapezoid.c lib_nx_getposition.c +CSRCS += lib_nx_getrectangle.c lib_nx_lower.c lib_nx_move.c lib_nx_openwindow.c +CSRCS += lib_nx_raise.c lib_nx_setpixel.c lib_nx_setposition.c lib_nx_setsize.c endif # Add the nx/ directory to the build diff --git a/graphics/nxmu/nx_bitmap.c b/libc/nx/lib_nx_bitmap.c similarity index 96% rename from graphics/nxmu/nx_bitmap.c rename to libc/nx/lib_nx_bitmap.c index a0bd748b09..fdd0b97173 100644 --- a/graphics/nxmu/nx_bitmap.c +++ b/libc/nx/lib_nx_bitmap.c @@ -1,7 +1,7 @@ /**************************************************************************** - * graphics/nxmu/nx_bitmap.c + * libc/nx/lib_nx_bitmap.c * - * Copyright (C) 2008-2009, 2011-2012 Gregory Nutt. All rights reserved. + * Copyright (C) 2008-2009, 2011-2013 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -43,9 +43,8 @@ #include #include - -#include "nxbe.h" -#include "nxfe.h" +#include +#include /**************************************************************************** * Pre-Processor Definitions @@ -106,7 +105,7 @@ int nx_bitmap(NXWINDOW hwnd, FAR const struct nxgl_rect_s *dest, #ifdef CONFIG_DEBUG if (!wnd || !dest || !src || !origin) { - errno = EINVAL; + set_errno(EINVAL); return ERROR; } #endif diff --git a/graphics/nxmu/nx_fill.c b/libc/nx/lib_nx_fill.c similarity index 96% rename from graphics/nxmu/nx_fill.c rename to libc/nx/lib_nx_fill.c index 969acdace0..bc03076225 100644 --- a/graphics/nxmu/nx_fill.c +++ b/libc/nx/lib_nx_fill.c @@ -1,7 +1,7 @@ /**************************************************************************** - * graphics/nxmu/nx_fill.c + * libc/nx/lib_nx_fill.c * - * Copyright (C) 2008-2009, 2011-2012 Gregory Nutt. All rights reserved. + * Copyright (C) 2008-2009, 2011-2013 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -45,8 +45,8 @@ #include #include - -#include "nxfe.h" +#include +#include /**************************************************************************** * Pre-Processor Definitions @@ -97,7 +97,7 @@ int nx_fill(NXWINDOW hwnd, FAR const struct nxgl_rect_s *rect, #ifdef CONFIG_DEBUG if (!wnd || !rect || !color) { - errno = EINVAL; + set_errno(EINVAL); return ERROR; } #endif diff --git a/graphics/nxmu/nx_filltrapezoid.c b/libc/nx/lib_nx_filltrapezoid.c similarity index 96% rename from graphics/nxmu/nx_filltrapezoid.c rename to libc/nx/lib_nx_filltrapezoid.c index bf289179e0..0d6b826ec2 100644 --- a/graphics/nxmu/nx_filltrapezoid.c +++ b/libc/nx/lib_nx_filltrapezoid.c @@ -1,7 +1,7 @@ /**************************************************************************** - * graphics/nxmu/nx_filltrapezoid.c + * libc/nx/lib_nx_filltrapezoid.c * - * Copyright (C) 2008-2009, 2011-2012 Gregory Nutt. All rights reserved. + * Copyright (C) 2008-2009, 2011-2013 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -45,8 +45,8 @@ #include #include - -#include "nxfe.h" +#include +#include /**************************************************************************** * Pre-Processor Definitions @@ -102,7 +102,7 @@ int nx_filltrapezoid(NXWINDOW hwnd, FAR const struct nxgl_rect_s *clip, #ifdef CONFIG_DEBUG if (!wnd || !trap || !color) { - errno = EINVAL; + set_errno(EINVAL); return ERROR; } #endif diff --git a/graphics/nxmu/nx_getposition.c b/libc/nx/lib_nx_getposition.c similarity index 96% rename from graphics/nxmu/nx_getposition.c rename to libc/nx/lib_nx_getposition.c index 06ad2c6aa0..4a0ae30b95 100644 --- a/graphics/nxmu/nx_getposition.c +++ b/libc/nx/lib_nx_getposition.c @@ -1,7 +1,7 @@ /**************************************************************************** - * graphics/nxmu/nx_getposition.c + * libc/nx/lib_nx_getposition.c * - * Copyright (C) 2008-2009, 2011-2012 Gregory Nutt. All rights reserved. + * Copyright (C) 2008-2009, 2011-2013 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -43,7 +43,8 @@ #include #include -#include "nxfe.h" +#include +#include /**************************************************************************** * Pre-Processor Definitions @@ -93,7 +94,7 @@ int nx_getposition(NXWINDOW hwnd) #ifdef CONFIG_DEBUG if (!wnd) { - errno = EINVAL; + set_errno(EINVAL); return ERROR; } #endif diff --git a/graphics/nxmu/nx_getrectangle.c b/libc/nx/lib_nx_getrectangle.c similarity index 97% rename from graphics/nxmu/nx_getrectangle.c rename to libc/nx/lib_nx_getrectangle.c index fea01fcd27..e815e5a17f 100644 --- a/graphics/nxmu/nx_getrectangle.c +++ b/libc/nx/lib_nx_getrectangle.c @@ -1,7 +1,7 @@ /**************************************************************************** - * graphics/nxmu/nx_getrectangle.c + * libc/nx/lib_nx_getrectangle.c * - * Copyright (C) 2011-2012 Gregory Nutt. All rights reserved. + * Copyright (C) 2011-2013 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -44,8 +44,8 @@ #include #include - -#include "nxfe.h" +#include +#include /**************************************************************************** * Pre-Processor Definitions diff --git a/graphics/nxmu/nx_lower.c b/libc/nx/lib_nx_lower.c similarity index 96% rename from graphics/nxmu/nx_lower.c rename to libc/nx/lib_nx_lower.c index c9505ca49a..64a8b58480 100644 --- a/graphics/nxmu/nx_lower.c +++ b/libc/nx/lib_nx_lower.c @@ -1,7 +1,7 @@ /**************************************************************************** - * graphics/nxmu/nx_lower.c + * libc/nx/lib_nx_lower.c * - * Copyright (C) 2008-2009, 2011-2012 Gregory Nutt. All rights reserved. + * Copyright (C) 2008-2009, 2011-2013 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -43,7 +43,8 @@ #include #include -#include "nxfe.h" +#include +#include /**************************************************************************** * Pre-Processor Definitions diff --git a/graphics/nxmu/nx_move.c b/libc/nx/lib_nx_move.c similarity index 95% rename from graphics/nxmu/nx_move.c rename to libc/nx/lib_nx_move.c index c8d4d3dfde..30ab332591 100644 --- a/graphics/nxmu/nx_move.c +++ b/libc/nx/lib_nx_move.c @@ -1,7 +1,7 @@ /**************************************************************************** - * graphics/nxmu/nx_move.c + * libc/nx/lib_nx_move.c * - * Copyright (C) 2008-2009, 2012 Gregory Nutt. All rights reserved. + * Copyright (C) 2008-2009, 2012-2013 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -43,7 +43,8 @@ #include #include -#include "nxfe.h" +#include +#include /**************************************************************************** * Pre-Processor Definitions @@ -94,7 +95,7 @@ int nx_move(NXWINDOW hwnd, FAR const struct nxgl_rect_s *rect, #ifdef CONFIG_DEBUG if (!wnd) { - errno = EINVAL; + set_errno(EINVAL); return ERROR; } #endif diff --git a/graphics/nxmu/nx_openwindow.c b/libc/nx/lib_nx_openwindow.c similarity index 93% rename from graphics/nxmu/nx_openwindow.c rename to libc/nx/lib_nx_openwindow.c index 2975e365a1..a663b6493e 100644 --- a/graphics/nxmu/nx_openwindow.c +++ b/libc/nx/lib_nx_openwindow.c @@ -1,7 +1,7 @@ /**************************************************************************** - * graphics/nxmu/nx_openwindow.c + * libc/nx/lib_nx_openwindow.c * - * Copyright (C) 2008-2009, 2011-2012 Gregory Nutt. All rights reserved. + * Copyright (C) 2008-2009, 2011-2013 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -43,9 +43,10 @@ #include #include -#include +#include +#include -#include "nxfe.h" +#include "lib_internal.h" /**************************************************************************** * Pre-Processor Definitions @@ -97,17 +98,17 @@ NXWINDOW nx_openwindow(NXHANDLE handle, FAR const struct nx_callback_s *cb, #ifdef CONFIG_DEBUG if (!handle || !cb) { - errno = EINVAL; + set_errno(EINVAL); return NULL; } #endif /* Pre-allocate the window structure */ - wnd = (FAR struct nxbe_window_s *)kzalloc(sizeof(struct nxbe_window_s)); + wnd = (FAR struct nxbe_window_s *)lib_zalloc(sizeof(struct nxbe_window_s)); if (!wnd) { - errno = ENOMEM; + set_errno(ENOMEM); return NULL; } diff --git a/graphics/nxmu/nx_raise.c b/libc/nx/lib_nx_raise.c similarity index 96% rename from graphics/nxmu/nx_raise.c rename to libc/nx/lib_nx_raise.c index 4f51810f19..6f35fc7cd4 100644 --- a/graphics/nxmu/nx_raise.c +++ b/libc/nx/lib_nx_raise.c @@ -1,7 +1,7 @@ /**************************************************************************** - * graphics/nxmu/nx_raise.c + * libc/nx/lib_nx_raise.c * - * Copyright (C) 2008-2009, 2011-2012 Gregory Nutt. All rights reserved. + * Copyright (C) 2008-2009, 2011-2013 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -43,7 +43,8 @@ #include #include -#include "nxfe.h" +#include +#include /**************************************************************************** * Pre-Processor Definitions diff --git a/graphics/nxmu/nx_setpixel.c b/libc/nx/lib_nx_setpixel.c similarity index 96% rename from graphics/nxmu/nx_setpixel.c rename to libc/nx/lib_nx_setpixel.c index 57fc12cc6f..7712f034f9 100644 --- a/graphics/nxmu/nx_setpixel.c +++ b/libc/nx/lib_nx_setpixel.c @@ -1,7 +1,7 @@ /**************************************************************************** - * graphics/nxmu/nx_setpixel.c + * libc/nx/lib_nx_setpixel.c * - * Copyright (C) 2011-2012 Gregory Nutt. All rights reserved. + * Copyright (C) 2011-2013 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -45,8 +45,8 @@ #include #include - -#include "nxfe.h" +#include +#include /**************************************************************************** * Pre-Processor Definitions diff --git a/graphics/nxmu/nx_setposition.c b/libc/nx/lib_nx_setposition.c similarity index 95% rename from graphics/nxmu/nx_setposition.c rename to libc/nx/lib_nx_setposition.c index 75b33757a8..d83da41a74 100644 --- a/graphics/nxmu/nx_setposition.c +++ b/libc/nx/lib_nx_setposition.c @@ -1,7 +1,7 @@ /**************************************************************************** - * graphics/nxmu/nx_setposition.c + * libc/nx/lib_nx_setposition.c * - * Copyright (C) 2008-2009, 2011-2012 Gregory Nutt. All rights reserved. + * Copyright (C) 2008-2009, 2011-2013 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -43,7 +43,8 @@ #include #include -#include "nxfe.h" +#include +#include /**************************************************************************** * Pre-Processor Definitions @@ -92,7 +93,7 @@ int nx_setposition(NXWINDOW hwnd, FAR const struct nxgl_point_s *pos) #ifdef CONFIG_DEBUG if (!wnd || !pos) { - errno = EINVAL; + set_errno(EINVAL); return ERROR; } #endif diff --git a/graphics/nxmu/nx_setsize.c b/libc/nx/lib_nx_setsize.c similarity index 95% rename from graphics/nxmu/nx_setsize.c rename to libc/nx/lib_nx_setsize.c index 5f538bccca..860d5bd1e5 100644 --- a/graphics/nxmu/nx_setsize.c +++ b/libc/nx/lib_nx_setsize.c @@ -1,7 +1,7 @@ /**************************************************************************** - * graphics/nxmu/nx_setsize.c + * libc/nx/lib_nx_setsize.c * - * Copyright (C) 2008-2009, 2011-2012 Gregory Nutt. All rights reserved. + * Copyright (C) 2008-2009, 2011-2013 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -43,7 +43,8 @@ #include #include -#include "nxfe.h" +#include +#include /**************************************************************************** * Pre-Processor Definitions @@ -92,7 +93,7 @@ int nx_setsize(NXWINDOW hwnd, FAR const struct nxgl_size_s *size) #ifdef CONFIG_DEBUG if (!wnd || !size) { - errno = EINVAL; + set_errno(EINVAL); return ERROR; } #endif diff --git a/graphics/nxmu/nxmu_semtake.c b/libc/nx/lib_nxmu_semtake.c similarity index 97% rename from graphics/nxmu/nxmu_semtake.c rename to libc/nx/lib_nxmu_semtake.c index 164a099b87..2d5ad181da 100644 --- a/graphics/nxmu/nxmu_semtake.c +++ b/libc/nx/lib_nxmu_semtake.c @@ -1,7 +1,7 @@ /**************************************************************************** * graphics/nxmu/nxmu_semtake.c * - * Copyright (C) 2008-2009, 2011 Gregory Nutt. All rights reserved. + * Copyright (C) 2008-2009, 2011, 2013 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -44,7 +44,7 @@ #include #include -#include "nxfe.h" +#include /**************************************************************************** * Pre-Processor Definitions diff --git a/libc/nx/lib_nxmu_sendwindow.c b/libc/nx/lib_nxmu_sendwindow.c new file mode 100644 index 0000000000..e7602005c9 --- /dev/null +++ b/libc/nx/lib_nxmu_sendwindow.c @@ -0,0 +1,115 @@ +/**************************************************************************** + * libc/nx/lib_nxmu_sendserver.c + * + * Copyright (C) 2012-2013 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 + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include +#include + +#include +#include + +/**************************************************************************** + * Pre-Processor Definitions + ****************************************************************************/ + +/**************************************************************************** + * Private Types + ****************************************************************************/ + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: nxmu_sendwindow + * + * Description: + * Send a message to the server destined 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 + * + ****************************************************************************/ + +int nxmu_sendwindow(FAR struct nxbe_window_s *wnd, FAR const void *msg, + size_t msglen) +{ + int ret = OK; + + /* Sanity checking */ + +#ifdef CONFIG_DEBUG + if (!wnd || !wnd->conn) + { + set_errno(EINVAL); + return ERROR; + } +#endif + + /* Ignore messages destined to a blocked window (no errors reported) */ + + if (!NXBE_ISBLOCKED(wnd)) + { + /* Send the message to the server */ + + ret = nxmu_sendserver(wnd->conn, msg, msglen); + } + + return ret; +}