summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--nuttx/examples/nx/nx_internal.h6
-rw-r--r--nuttx/graphics/nxmu/Make.defs7
-rw-r--r--nuttx/graphics/nxmu/nx_openwindow.c24
-rw-r--r--nuttx/graphics/nxmu/nxfe.h33
-rw-r--r--nuttx/graphics/nxmu/nxmu_constructwindow.c147
-rw-r--r--nuttx/graphics/nxsu/Make.defs2
-rw-r--r--nuttx/graphics/nxsu/nx_openwindow.c38
-rw-r--r--nuttx/graphics/nxsu/nxfe.h33
-rw-r--r--nuttx/graphics/nxsu/nxsu_constructwindow.c151
9 files changed, 391 insertions, 50 deletions
diff --git a/nuttx/examples/nx/nx_internal.h b/nuttx/examples/nx/nx_internal.h
index 40bf62059..d41bbf89f 100644
--- a/nuttx/examples/nx/nx_internal.h
+++ b/nuttx/examples/nx/nx_internal.h
@@ -59,7 +59,7 @@
#ifndef CONFIG_EXAMPLES_NX_BGCOLOR
# if CONFIG_SIM_FBBPP == 24 || CONFIG_SIM_FBBPP == 32
-# define CONFIG_EXAMPLES_NX_BGCOLOR 0x00602020
+# define CONFIG_EXAMPLES_NX_BGCOLOR 0x007b68ee
# elif CONFIG_SIM_FBBPP = 16
# define CONFIG_EXAMPLES_NX_BGCOLOR 0x3088
# else
@@ -69,7 +69,7 @@
#ifndef CONFIG_EXAMPLES_NX_COLOR1
# if CONFIG_SIM_FBBPP == 24 || CONFIG_SIM_FBBPP == 32
-# define CONFIG_EXAMPLES_NX_COLOR1 0x00606020
+# define CONFIG_EXAMPLES_NX_COLOR1 0x00e6e6fa
# elif CONFIG_SIM_FBBPP = 16
# define CONFIG_EXAMPLES_NX_COLOR1 0x30c8
# else
@@ -79,7 +79,7 @@
#ifndef CONFIG_EXAMPLES_NX_COLOR2
# if CONFIG_SIM_FBBPP == 24 || CONFIG_SIM_FBBPP == 32
-# define CONFIG_EXAMPLES_NX_COLOR2 0x00606060
+# define CONFIG_EXAMPLES_NX_COLOR2 0x00dcdcdc
# elif CONFIG_SIM_FBBPP = 16
# define CONFIG_EXAMPLES_NX_COLOR2 0x30cc
# else
diff --git a/nuttx/graphics/nxmu/Make.defs b/nuttx/graphics/nxmu/Make.defs
index d7d808671..64d5fc724 100644
--- a/nuttx/graphics/nxmu/Make.defs
+++ b/nuttx/graphics/nxmu/Make.defs
@@ -40,7 +40,8 @@ NXAPI_CSRCS = nx_bitmap.c nx_closewindow.c nx_connect.c nx_disconnect.c \
nx_mousein.c nx_move.c nx_openwindow.c nx_raise.c \
nx_releasebkgd.c nx_requestbkgd.c nx_setsize.c \
nx_setbgcolor.c nx_setposition.c
-NXMU_CSRCS = 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_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
NX_CSRCS = $(NXAPI_CSRCS) $(NXMU_CSRCS)
diff --git a/nuttx/graphics/nxmu/nx_openwindow.c b/nuttx/graphics/nxmu/nx_openwindow.c
index 8a834d4ba..8878ffceb 100644
--- a/nuttx/graphics/nxmu/nx_openwindow.c
+++ b/nuttx/graphics/nxmu/nx_openwindow.c
@@ -80,6 +80,7 @@
* Input Parameters:
* handle - The handle returned by nx_connect
* cb - Callbacks used to process windo events
+ * arg - User provided value that will be returned with NX callbacks.
*
* Return:
* Success: A non-NULL handle used with subsequent NX accesses
@@ -87,11 +88,10 @@
*
****************************************************************************/
-NXWINDOW nx_openwindow(NXHANDLE handle, FAR const struct nx_callback_s *cb)
+NXWINDOW nx_openwindow(NXHANDLE handle, FAR const struct nx_callback_s *cb,
+ FAR void *arg)
{
- FAR struct nxfe_conn_s *conn = (FAR struct nxfe_conn_s *)handle;
FAR struct nxbe_window_s *wnd;
- struct nxsvrmsg_openwindow_s outmsg;
int ret;
#ifdef CONFIG_DEBUG
@@ -111,23 +111,13 @@ NXWINDOW nx_openwindow(NXHANDLE handle, FAR const struct nx_callback_s *cb)
return NULL;
}
- /* Setup only the connection structure. We'll need this to communicate with
- * the server. The server will set everything else up.
- */
-
- wnd->conn = conn;
- wnd->cb = cb;
-
- /* Request initialization the new window from the server */
+ /* Then let nxfe_constructwindow do the rest */
- outmsg.msgid = NX_SVRMSG_OPENWINDOW;
- outmsg.wnd = wnd;
-
- ret = mq_send(conn->cwrmq, &outmsg, sizeof(struct nxsvrmsg_openwindow_s), NX_SVRMSG_PRIO);
+ ret = nxfe_constructwindow(handle, wnd, cb, arg);
if (ret < 0)
{
- gdbg("mq_send failed: %d\n", errno);
- free(wnd);
+ /* An error occurred, the window has been freed */
+
return NULL;
}
diff --git a/nuttx/graphics/nxmu/nxfe.h b/nuttx/graphics/nxmu/nxfe.h
index 50cf50b09..b8786dc63 100644
--- a/nuttx/graphics/nxmu/nxfe.h
+++ b/nuttx/graphics/nxmu/nxfe.h
@@ -428,6 +428,39 @@ extern "C" {
****************************************************************************/
/****************************************************************************
+ * Name: nxfe_constructwindow
+ *
+ * Description:
+ * This function is the same a nx_openwindow EXCEPT that the client provides
+ * the window structure instance. nx_constructwindow will initialize the
+ * the pre-allocated window structure for use by NX. This function is
+ * provided in addition to nx_open window in order to support a kind of
+ * inheritance: The caller's window structure may include extensions that
+ * are not visible to NX.
+ *
+ * NOTE: wnd must have been allocated using malloc() (or related allocators)
+ * Once provided to nxfe_constructwindow() that memory is owned and managed
+ * by NX. On certain error conditions or when the window is closed, NX will
+ * free() the the window.
+ *
+ * Input Parameters:
+ * handle - The handle returned by nx_connect
+ * wnd - The pre-allocated window structure.
+ * cb - Callbacks used to process window events
+ * arg - User provided value that will be returned with NX callbacks.
+ *
+ * Return:
+ * OK on success; ERROR on failure with errno set appropriately. In the
+ * case of ERROR, NX will have dealloated the pre-allocated window.
+ *
+ ****************************************************************************/
+
+EXTERN int nxfe_constructwindow(NXHANDLE handle,
+ FAR struct nxbe_window_s *wnd,
+ FAR const struct nx_callback_s *cb,
+ FAR void *arg);
+
+/****************************************************************************
* Name: nxmu_semtake
*
* Description:
diff --git a/nuttx/graphics/nxmu/nxmu_constructwindow.c b/nuttx/graphics/nxmu/nxmu_constructwindow.c
new file mode 100644
index 000000000..0923696df
--- /dev/null
+++ b/nuttx/graphics/nxmu/nxmu_constructwindow.c
@@ -0,0 +1,147 @@
+/****************************************************************************
+ * graphics/nxmu/nx_openwindow.c
+ *
+ * Copyright (C) 2008 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
+ *
+ * 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 <nuttx/config.h>
+
+#include <sys/types.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <debug.h>
+
+#include <nuttx/nx.h>
+#include "nxfe.h"
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Types
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+/****************************************************************************
+ * Public Data
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: nxfe_constructwindow
+ *
+ * Description:
+ * This function is the same a nx_openwindow EXCEPT that the client provides
+ * the window structure instance. nx_constructwindow will initialize the
+ * the pre-allocated window structure for use by NX. This function is
+ * provided in addition to nx_open window in order to support a kind of
+ * inheritance: The caller's window structure may include extensions that
+ * are not visible to NX.
+ *
+ * NOTE: wnd must have been allocated using malloc() (or related allocators)
+ * Once provided to nxfe_constructwindow() that memory is owned and managed
+ * by NX. On certain error conditions or when the window is closed, NX will
+ * free() the the window.
+ *
+ * Input Parameters:
+ * handle - The handle returned by nx_connect
+ * wnd - The pre-allocated window structure.
+ * cb - Callbacks used to process window events
+ * arg - User provided value that will be returned with NX callbacks.
+ *
+ * Return:
+ * OK on success; ERROR on failure with errno set appropriately. In the
+ * case of ERROR, NX will have dealloated the pre-allocated window.
+ *
+ ****************************************************************************/
+
+int nxfe_constructwindow(NXHANDLE handle, FAR struct nxbe_window_s *wnd,
+ FAR const struct nx_callback_s *cb, FAR void *arg)
+{
+ FAR struct nxfe_conn_s *conn = (FAR struct nxfe_conn_s *)handle;
+ struct nxsvrmsg_openwindow_s outmsg;
+ int ret;
+
+#ifdef CONFIG_DEBUG
+ if (!wnd)
+ {
+ errno = EINVAL;
+ return ERROR;
+ }
+
+ if (!conn || !cb)
+ {
+ free(wnd);
+ errno = EINVAL;
+ return ERROR;
+ }
+#endif
+
+ /* Setup only the connection structure, callbacks and client private data
+ * reference. The server will set everything else up.
+ */
+
+ wnd->conn = conn;
+ wnd->cb = cb;
+ wnd->arg = arg;
+
+ /* Request initialization the new window from the server */
+
+ 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;
+}
+
diff --git a/nuttx/graphics/nxsu/Make.defs b/nuttx/graphics/nxsu/Make.defs
index 5a4c74bb3..af525bea9 100644
--- a/nuttx/graphics/nxsu/Make.defs
+++ b/nuttx/graphics/nxsu/Make.defs
@@ -39,5 +39,5 @@ NXAPI_CSRCS = nx_bitmap.c nx_close.c nx_closewindow.c nx_fill.c \
nx_kbdin.c nx_lower.c nx_mousein.c nx_move.c nx_open.c \
nx_openwindow.c nx_raise.c nx_releasebkgd.c nx_requestbkgd.c \
nx_setsize.c nx_setbgcolor.c nx_setposition.c
-NXSU_CSRCS = nxsu_redrawreq.c nxsu_reportposition.c
+NXSU_CSRCS = nxsu_constructwindow.c nxsu_redrawreq.c nxsu_reportposition.c
NX_CSRCS = $(NXAPI_CSRCS) $(NXSU_CSRCS)
diff --git a/nuttx/graphics/nxsu/nx_openwindow.c b/nuttx/graphics/nxsu/nx_openwindow.c
index 005d907fd..2d73feaef 100644
--- a/nuttx/graphics/nxsu/nx_openwindow.c
+++ b/nuttx/graphics/nxsu/nx_openwindow.c
@@ -80,6 +80,7 @@
* Input Parameters:
* handle - The handle returned by nx_connect
* cb - Callbacks used to process windo events
+ * arg - User provided value that will be returned with NX callbacks.
*
* Return:
* Success: A non-NULL handle used with subsequent NX accesses
@@ -87,14 +88,14 @@
*
****************************************************************************/
-NXWINDOW nx_openwindow(NXHANDLE handle, FAR const struct nx_callback_s *cb)
+NXWINDOW nx_openwindow(NXHANDLE handle, FAR const struct nx_callback_s *cb,
+ FAR void *arg)
{
- FAR struct nxfe_state_s *fe = (FAR struct nxfe_state_s *)handle;
- FAR struct nxbe_state_s *be = &fe->be;
FAR struct nxbe_window_s *wnd;
+ int ret;
#ifdef CONFIG_DEBUG
- if (!fe || !cb)
+ if (!handle || !cb)
{
errno = EINVAL;
return NULL;
@@ -110,30 +111,15 @@ NXWINDOW nx_openwindow(NXHANDLE handle, FAR const struct nx_callback_s *cb)
return NULL;
}
- /* Initialize the window structure */
+ /* Then let nxfe_constructwindow do the rest */
- wnd->be = be;
- wnd->cb = cb;
-
- /* Insert the new window at the top on the display. topwind is
- * never NULL (it may point only at the background window, however)
- */
-
- wnd->above = NULL;
- wnd->below = be->topwnd;
-
- be->topwnd->above = wnd;
- be->topwnd = wnd;
-
- /* Report the initialize size/position of the window */
-
- nxfe_reportposition((NXWINDOW)wnd);
-
- /* Provide the initial mouse settings */
+ ret = nxfe_constructwindow(handle, wnd, cb, arg);
+ if (ret < 0)
+ {
+ /* An error occurred, the window has been freed */
-#ifdef CONFIG_NX_MOUSE
- nxsu_mousereport(wnd);
-#endif
+ return NULL;
+ }
/* Return the initialized window reference */
diff --git a/nuttx/graphics/nxsu/nxfe.h b/nuttx/graphics/nxsu/nxfe.h
index f0cc076a7..7fd65f2f3 100644
--- a/nuttx/graphics/nxsu/nxfe.h
+++ b/nuttx/graphics/nxsu/nxfe.h
@@ -95,6 +95,39 @@ EXTERN const struct nx_callback_s g_bkgdcb;
****************************************************************************/
/****************************************************************************
+ * Name: nxfe_constructwindow
+ *
+ * Description:
+ * This function is the same a nx_openwindow EXCEPT that the client provides
+ * the window structure instance. nx_constructwindow will initialize the
+ * the pre-allocated window structure for use by NX. This function is
+ * provided in addition to nx_open window in order to support a kind of
+ * inheritance: The caller's window structure may include extensions that
+ * are not visible to NX.
+ *
+ * NOTE: wnd must have been allocated using malloc() (or related allocators)
+ * Once provided to nxfe_constructwindow() that memory is owned and managed
+ * by NX. On certain error conditions or when the window is closed, NX will
+ * free() the the window.
+ *
+ * Input Parameters:
+ * handle - The handle returned by nx_connect
+ * wnd - The pre-allocated window structure.
+ * cb - Callbacks used to process window events
+ * arg - User provided value that will be returned with NX callbacks.
+ *
+ * Return:
+ * OK on success; ERROR on failure with errno set appropriately. In the
+ * case of ERROR, NX will have dealloated the pre-allocated window.
+ *
+ ****************************************************************************/
+
+EXTERN int nxfe_constructwindow(NXHANDLE handle,
+ FAR struct nxbe_window_s *wnd,
+ FAR const struct nx_callback_s *cb,
+ FAR void *arg);
+
+/****************************************************************************
* Name: nxfe_redrawreq
*
* Descripton:
diff --git a/nuttx/graphics/nxsu/nxsu_constructwindow.c b/nuttx/graphics/nxsu/nxsu_constructwindow.c
new file mode 100644
index 000000000..e41071b26
--- /dev/null
+++ b/nuttx/graphics/nxsu/nxsu_constructwindow.c
@@ -0,0 +1,151 @@
+/****************************************************************************
+ * graphics/nxsu/nx_openwindow.c
+ *
+ * Copyright (C) 2008 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
+ *
+ * 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 <nuttx/config.h>
+
+#include <sys/types.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <debug.h>
+
+#include <nuttx/nx.h>
+#include "nxfe.h"
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Types
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+/****************************************************************************
+ * Public Data
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: nxfe_constructwindow
+ *
+ * Description:
+ * This function is the same a nx_openwindow EXCEPT that the client provides
+ * the window structure instance. nx_constructwindow will initialize the
+ * the pre-allocated window structure for use by NX. This function is
+ * provided in addition to nx_open window in order to support a kind of
+ * inheritance: The caller's window structure may include extensions that
+ * are not visible to NX.
+ *
+ * NOTE: wnd must have been allocated using malloc() (or related allocators)
+ * Once provided to nxfe_constructwindow() that memory is owned and managed
+ * by NX. On certain error conditions or when the window is closed, NX will
+ * free() the the window.
+ *
+ * Input Parameters:
+ * handle - The handle returned by nx_connect
+ * wnd - The pre-allocated window structure.
+ * cb - Callbacks used to process window events
+ * arg - User provided value that will be returned with NX callbacks.
+ *
+ * Return:
+ * OK on success; ERROR on failure with errno set appropriately. In the
+ * case of ERROR, NX will have dealloated the pre-allocated window.
+ *
+ ****************************************************************************/
+
+int nxfe_constructwindow(NXHANDLE handle, FAR struct nxbe_window_s *wnd,
+ FAR const struct nx_callback_s *cb, FAR void *arg)
+{
+ FAR struct nxfe_state_s *fe = (FAR struct nxfe_state_s *)handle;
+ FAR struct nxbe_state_s *be = &fe->be;
+
+#ifdef CONFIG_DEBUG
+ if (!wnd)
+ {
+ errno = EINVAL;
+ return ERROR;
+ }
+
+ if (!fe || !cb)
+ {
+ free(wnd);
+ errno = EINVAL;
+ return ERROR;
+ }
+#endif
+
+ /* Initialize the window structure */
+
+ wnd->be = be;
+ wnd->cb = cb;
+ wnd->arg = arg;
+
+ /* Insert the new window at the top on the display. topwind is
+ * never NULL (it may point only at the background window, however)
+ */
+
+ wnd->above = NULL;
+ wnd->below = be->topwnd;
+
+ be->topwnd->above = wnd;
+ be->topwnd = wnd;
+
+ /* Report the initialize size/position of the window */
+
+ nxfe_reportposition((NXWINDOW)wnd);
+
+ /* Provide the initial mouse settings */
+
+#ifdef CONFIG_NX_MOUSE
+ nxsu_mousereport(wnd);
+#endif
+
+ return OK;
+}
+