Decoupling NX user interfaces to support NX kernel build (phase 1)

This commit is contained in:
Gregory Nutt
2013-12-27 13:18:20 -06:00
parent 64bb8b3341
commit 2507017695
24 changed files with 909 additions and 668 deletions
+55 -115
View File
@@ -1,7 +1,7 @@
/****************************************************************************
* graphics/nxbe/nxbe.h
*
* Copyright (C) 2008-2011 Gregory Nutt. All rights reserved.
* Copyright (C) 2008-2011, 2013 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@@ -47,22 +47,12 @@
#include <nuttx/nx/nx.h>
#include <nuttx/nx/nxglib.h>
#include <nuttx/nx/nxbe.h>
/****************************************************************************
* Pre-Processor Definitions
****************************************************************************/
/* Configuration ************************************************************/
#ifndef CONFIG_NX_NPLANES
# define CONFIG_NX_NPLANES 1 /* Max number of color planes supported */
#endif
#ifndef CONFIG_NX_NCOLORS
# define CONFIG_NX_NCOLORS 256
#endif
/* NXBE Definitions *********************************************************/
/* These are the values for the clipping order provided to nx_clipper */
#define NX_CLIPORDER_TLRB (0) /* Top-left-right-bottom */
@@ -71,14 +61,6 @@
#define NX_CLIPORDER_BRLT (3) /* Bottom-right-left-top */
#define NX_CLIPORDER_DEFAULT NX_CLIPORDER_TLRB
/* Window flags and helper macros */
#define NXBE_WINDOW_BLOCKED (1 << 0) /* The window is blocked and will not
* receive further input. */
#define NXBE_ISBLOCKED(wnd) (((wnd)->flags & NXBE_WINDOW_BLOCKED) != 0)
#define NXBE_SETBLOCKED(wnd) do { (wnd)->flags |= NXBE_WINDOW_BLOCKED; } while (0)
/****************************************************************************
* Public Types
****************************************************************************/
@@ -137,46 +119,6 @@ struct nxbe_clipops_s
FAR const struct nxgl_rect_s *rect);
};
/* Windows ******************************************************************/
/* This structure represents one window. */
struct nxbe_state_s;
struct nxfe_conn_s;
struct nxbe_window_s
{
/* State information */
FAR struct nxbe_state_s *be; /* The back-end state structure */
#ifdef CONFIG_NX_MULTIUSER
FAR struct nxfe_conn_s *conn; /* Connection to the window client */
#endif
FAR const struct nx_callback_s *cb; /* Event handling callbacks */
/* The following links provide the window's vertical position using a
* singly linked list.
*/
FAR struct nxbe_window_s *above; /* The window "above" this window */
FAR struct nxbe_window_s *below; /* The window "below this one */
/* Window geometry. The window is described by a rectangle in the
* absolute screen coordinate system (0,0)->(xres,yres)
*/
struct nxgl_rect_s bounds; /* The bounding rectangle of window */
/* Window flags (see the NXBE_* bit definitions above) */
#ifdef CONFIG_NX_MULTIUSER /* Currently used only in multi-user mode */
uint8_t flags;
#endif
/* Client state information this is provide in window callbacks */
FAR void *arg;
};
/* Back-end state ***********************************************************/
/* This structure describes the overall back-end window state */
@@ -228,12 +170,12 @@ extern "C" {
* Name: nxbe_colormap
*
* Description:
* Set the harware color map to the palette expected by NX
* Set the hardware color map to the palette expected by NX
*
****************************************************************************/
#ifdef CONFIG_FB_CMAP
EXTERN int nxbe_colormap(FAR NX_DRIVERTYPE *dev);
int nxbe_colormap(FAR NX_DRIVERTYPE *dev);
#endif
/****************************************************************************
@@ -245,8 +187,7 @@ EXTERN int nxbe_colormap(FAR NX_DRIVERTYPE *dev);
*
****************************************************************************/
EXTERN int nxbe_configure(FAR NX_DRIVERTYPE *dev,
FAR struct nxbe_state_s *be);
int nxbe_configure(FAR NX_DRIVERTYPE *dev, FAR struct nxbe_state_s *be);
/****************************************************************************
* Name: nxbe_closewindow
@@ -262,7 +203,7 @@ EXTERN int nxbe_configure(FAR NX_DRIVERTYPE *dev,
*
****************************************************************************/
EXTERN void nxbe_closewindow(struct nxbe_window_s *wnd);
void nxbe_closewindow(struct nxbe_window_s *wnd);
/****************************************************************************
* Name: nxbe_setposition
@@ -273,8 +214,8 @@ EXTERN void nxbe_closewindow(struct nxbe_window_s *wnd);
*
****************************************************************************/
EXTERN void nxbe_setposition(FAR struct nxbe_window_s *wnd,
FAR const struct nxgl_point_s *pos);
void nxbe_setposition(FAR struct nxbe_window_s *wnd,
FAR const struct nxgl_point_s *pos);
/****************************************************************************
* Name: nxbe_setsize
@@ -285,8 +226,8 @@ EXTERN void nxbe_setposition(FAR struct nxbe_window_s *wnd,
*
****************************************************************************/
EXTERN void nxbe_setsize(FAR struct nxbe_window_s *wnd,
FAR const struct nxgl_size_s *size);
void nxbe_setsize(FAR struct nxbe_window_s *wnd,
FAR const struct nxgl_size_s *size);
/****************************************************************************
* Name: nxbe_raise
@@ -296,7 +237,7 @@ EXTERN void nxbe_setsize(FAR struct nxbe_window_s *wnd,
*
****************************************************************************/
EXTERN void nxbe_raise(FAR struct nxbe_window_s *wnd);
void nxbe_raise(FAR struct nxbe_window_s *wnd);
/****************************************************************************
* Name: nxbe_lower
@@ -306,7 +247,7 @@ EXTERN void nxbe_raise(FAR struct nxbe_window_s *wnd);
*
****************************************************************************/
EXTERN void nxbe_lower(FAR struct nxbe_window_s *wnd);
void nxbe_lower(FAR struct nxbe_window_s *wnd);
/****************************************************************************
* Name: nxbe_setpixel
@@ -325,9 +266,9 @@ EXTERN void nxbe_lower(FAR struct nxbe_window_s *wnd);
*
****************************************************************************/
EXTERN void nxbe_setpixel(FAR struct nxbe_window_s *wnd,
FAR const struct nxgl_point_s *pos,
nxgl_mxpixel_t color[CONFIG_NX_NPLANES]);
void nxbe_setpixel(FAR struct nxbe_window_s *wnd,
FAR const struct nxgl_point_s *pos,
nxgl_mxpixel_t color[CONFIG_NX_NPLANES]);
/****************************************************************************
* Name: nxbe_fill
@@ -345,9 +286,9 @@ EXTERN void nxbe_setpixel(FAR struct nxbe_window_s *wnd,
*
****************************************************************************/
EXTERN void nxbe_fill(FAR struct nxbe_window_s *wnd,
FAR const struct nxgl_rect_s *rect,
nxgl_mxpixel_t color[CONFIG_NX_NPLANES]);
void nxbe_fill(FAR struct nxbe_window_s *wnd,
FAR const struct nxgl_rect_s *rect,
nxgl_mxpixel_t color[CONFIG_NX_NPLANES]);
/****************************************************************************
* Name: nxbe_filltrapezoid
@@ -366,10 +307,10 @@ EXTERN void nxbe_fill(FAR struct nxbe_window_s *wnd,
*
****************************************************************************/
EXTERN void nxbe_filltrapezoid(FAR struct nxbe_window_s *wnd,
FAR const struct nxgl_rect_s *clip,
FAR const struct nxgl_trapezoid_s *trap,
nxgl_mxpixel_t color[CONFIG_NX_NPLANES]);
void nxbe_filltrapezoid(FAR struct nxbe_window_s *wnd,
FAR const struct nxgl_rect_s *clip,
FAR const struct nxgl_trapezoid_s *trap,
nxgl_mxpixel_t color[CONFIG_NX_NPLANES]);
/****************************************************************************
* Name: nxbe_getrectangle
@@ -392,10 +333,10 @@ EXTERN void nxbe_filltrapezoid(FAR struct nxbe_window_s *wnd,
*
****************************************************************************/
EXTERN void nxbe_getrectangle(FAR struct nxbe_window_s *wnd,
FAR const struct nxgl_rect_s *rect,
unsigned int plane,
FAR uint8_t *dest, unsigned int deststride);
void nxbe_getrectangle(FAR struct nxbe_window_s *wnd,
FAR const struct nxgl_rect_s *rect,
unsigned int plane,
FAR uint8_t *dest, unsigned int deststride);
/****************************************************************************
* Name: nxbe_move
@@ -413,9 +354,9 @@ EXTERN void nxbe_getrectangle(FAR struct nxbe_window_s *wnd,
*
****************************************************************************/
EXTERN void nxbe_move(FAR struct nxbe_window_s *wnd,
FAR const struct nxgl_rect_s *rect,
FAR const struct nxgl_point_s *offset);
void nxbe_move(FAR struct nxbe_window_s *wnd,
FAR const struct nxgl_rect_s *rect,
FAR const struct nxgl_point_s *offset);
/****************************************************************************
* Name: nxbe_bitmap
@@ -439,29 +380,29 @@ EXTERN void nxbe_move(FAR struct nxbe_window_s *wnd,
*
****************************************************************************/
EXTERN void nxbe_bitmap(FAR struct nxbe_window_s *wnd,
FAR const struct nxgl_rect_s *dest,
FAR const void *src[CONFIG_NX_NPLANES],
FAR const struct nxgl_point_s *origin,
unsigned int stride);
void nxbe_bitmap(FAR struct nxbe_window_s *wnd,
FAR const struct nxgl_rect_s *dest,
FAR const void *src[CONFIG_NX_NPLANES],
FAR const struct nxgl_point_s *origin,
unsigned int stride);
/****************************************************************************
* Name: nxbe_redraw
*
* Descripton:
* Description:
* Re-draw the visible portions of the rectangular region for the
* specified window
*
****************************************************************************/
EXTERN void nxbe_redraw(FAR struct nxbe_state_s *be,
FAR struct nxbe_window_s *wnd,
FAR const struct nxgl_rect_s *rect);
void nxbe_redraw(FAR struct nxbe_state_s *be,
FAR struct nxbe_window_s *wnd,
FAR const struct nxgl_rect_s *rect);
/****************************************************************************
* Name: nxbe_redrawbelow
*
* Descripton:
* Description:
* Re-draw the visible portions of the rectangular region for all windows
* below (and including) the specified window. This function is called
* whenever a window is closed, moved, lowered or re-sized in order to
@@ -469,28 +410,28 @@ EXTERN void nxbe_redraw(FAR struct nxbe_state_s *be,
*
****************************************************************************/
EXTERN void nxbe_redrawbelow(FAR struct nxbe_state_s *be,
FAR struct nxbe_window_s *wnd,
FAR const struct nxgl_rect_s *rect);
void nxbe_redrawbelow(FAR struct nxbe_state_s *be,
FAR struct nxbe_window_s *wnd,
FAR const struct nxgl_rect_s *rect);
/****************************************************************************
* Name: nxbe_visible
*
* Descripton:
* Description:
* Return true if the point, pt, in window wnd is visible. pt is in
* absolute screen coordinates
*
****************************************************************************/
EXTERN bool nxbe_visible(FAR struct nxbe_window_s *wnd,
FAR const struct nxgl_point_s *pos);
bool nxbe_visible(FAR struct nxbe_window_s *wnd,
FAR const struct nxgl_point_s *pos);
/****************************************************************************
* Name: nxbe_clipper
*
* Descripton:
* Description:
* Perform flexible clipping operations. Callbacks are executed for
* each oscured and visible portions of the window.
* each obscured and visible portions of the window.
*
* Input Parameters:
* wnd - The window to be clipped.
@@ -507,22 +448,22 @@ EXTERN bool nxbe_visible(FAR struct nxbe_window_s *wnd,
*
****************************************************************************/
EXTERN void nxbe_clipper(FAR struct nxbe_window_s *wnd,
FAR const struct nxgl_rect_s *dest, uint8_t order,
FAR struct nxbe_clipops_s *cops,
FAR struct nxbe_plane_s *plane);
void nxbe_clipper(FAR struct nxbe_window_s *wnd,
FAR const struct nxgl_rect_s *dest, uint8_t order,
FAR struct nxbe_clipops_s *cops,
FAR struct nxbe_plane_s *plane);
/****************************************************************************
* Name: nxbe_clipnull
*
* Descripton:
* Description:
* The do-nothing clipping callback function
*
****************************************************************************/
EXTERN void nxbe_clipnull(FAR struct nxbe_clipops_s *cops,
FAR struct nxbe_plane_s *plane,
FAR const struct nxgl_rect_s *rect);
void nxbe_clipnull(FAR struct nxbe_clipops_s *cops,
FAR struct nxbe_plane_s *plane,
FAR const struct nxgl_rect_s *rect);
#undef EXTERN
#if defined(__cplusplus)
@@ -530,4 +471,3 @@ EXTERN void nxbe_clipnull(FAR struct nxbe_clipops_s *cops,
#endif
#endif /* __GRAPHICS_NXBE_NXBE_H */
+14 -14
View File
@@ -1,7 +1,7 @@
############################################################################
# graphics/nxmu/Make.defs
#
# Copyright (C) 2008, 2011-2012 Gregory Nutt. All rights reserved.
# Copyright (C) 2008, 2011-2013 Gregory Nutt. All rights reserved.
# Author: Gregory Nutt <gnutt@nuttx.org>
#
# Redistribution and use in source and binary forms, with or without
@@ -33,16 +33,16 @@
#
############################################################################
NX_ASRCS =
NXAPI_CSRCS = nx_bitmap.c nx_closewindow.c nx_connect.c nx_disconnect.c \
nx_eventhandler.c nx_eventnotify.c nx_fill.c nx_filltrapezoid.c \
nx_getposition.c nx_getrectangle.c nx_kbdchin.c nx_kbdin.c nx_lower.c \
nx_mousein.c nx_move.c nx_openwindow.c nx_raise.c \
nx_releasebkgd.c nx_requestbkgd.c nx_setpixel.c nx_setsize.c \
nx_setbgcolor.c nx_setposition.c nx_drawcircle.c nx_drawline.c \
nx_fillcircle.c nx_block.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_sendclient.c \
nxmu_sendserver.c nxmu_sendwindow.c nxmu_semtake.c nxmu_server.c
NX_CSRCS = $(NXAPI_CSRCS) $(NXMU_CSRCS)
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
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
NX_CSRCS = $(NXAPI_CSRCS) $(NXMU_CSRCS)
-148
View File
@@ -1,148 +0,0 @@
/****************************************************************************
* graphics/nxmu/nx_block.c
*
* Copyright (C) 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
* 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 <errno.h>
#include <debug.h>
#include <nuttx/nx/nx.h>
#include "nxbe.h"
#include "nxfe.h"
/****************************************************************************
* Pre-Processor Definitions
****************************************************************************/
/****************************************************************************
* Private Types
****************************************************************************/
/****************************************************************************
* Private Data
****************************************************************************/
/****************************************************************************
* Public Data
****************************************************************************/
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: nx_block
*
* Description:
* This is callback will do to things: (1) any queue a 'blocked' callback
* to the window and then (2) block any further window messaging.
*
* The 'blocked' callback is the response from nx_block (or nxtk_block).
* Those blocking interfaces are used to assure that no further messages are
* are directed to the window. Receipt of the blocked callback signifies
* that (1) there are no further pending callbacks and (2) that the
* window is now 'defunct' and will receive no further callbacks.
*
* This callback supports coordinated destruction of a window in multi-
* user mode. In multi-use mode, the client window logic must stay
* intact until all of the queued callbacks are processed. Then the
* window may be safely closed. Closing the window prior with pending
* callbacks can lead to bad behavior when the callback is executed.
*
* Multiple user mode only!
*
* Input Parameters:
* wnd - The window to be blocked
* arg - An argument that will accompany the block messages (This is arg2
* in the blocked callback).
*
* Return:
* OK on success; ERROR on failure with errno set appropriately
*
****************************************************************************/
int nx_block(NXWINDOW hwnd, FAR void *arg)
{
FAR struct nxbe_window_s *wnd = (FAR struct nxbe_window_s *)hwnd;
struct nxsvrmsg_blocked_s outmsg;
int ret = OK;
#ifdef CONFIG_DEBUG
if (!hwnd)
{
set_errno(EINVAL);
return ERROR;
}
#endif
/* Ignore additional attempts to block messages (no errors reported) */
if (!NXBE_ISBLOCKED(wnd))
{
/* Mark the window as blocked. This will stop all messages to the window
* (EXCEPT the NX_SVRMSG_BLOCKED). Blocking the messages before sending the
* blocked message is awkward but assures that no other messages sneak into
* the message queue before we can set the blocked state.
*/
NXBE_SETBLOCKED(wnd);
/* Send the message inicating that the window is blocked (and because of
* queue also that there are no additional queue messages for the window)
*/
outmsg.msgid = NX_SVRMSG_BLOCKED;
outmsg.wnd = wnd;
outmsg.arg = arg;
/* Send the window message via nxmu_sendserver (vs. nxmu_sendwindow) so
* that it will not be blocked.
*/
ret = nxmu_sendserver(wnd->conn, &outmsg, sizeof(struct nxsvrmsg_blocked_s));
}
return ret;
}
-100
View File
@@ -1,100 +0,0 @@
/****************************************************************************
* graphics/nxmu/nx_closewindow.c
*
* 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
* 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 <stdlib.h>
#include <errno.h>
#include <debug.h>
#include <nuttx/nx/nx.h>
#include "nxfe.h"
/****************************************************************************
* Pre-Processor Definitions
****************************************************************************/
/****************************************************************************
* Private Types
****************************************************************************/
/****************************************************************************
* Private Data
****************************************************************************/
/****************************************************************************
* Public Data
****************************************************************************/
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: nx_closewindow
*
* Description:
* Destroy a window created by nx_openwindow.
*
* Input Parameters:
* wnd - The window to be destroyed
*
* Return:
* OK on success; ERROR on failure with errno set appropriately
*
****************************************************************************/
int nx_closewindow(NXWINDOW hwnd)
{
FAR struct nxbe_window_s *wnd = (FAR struct nxbe_window_s *)hwnd;
struct nxsvrmsg_closewindow_s outmsg;
/* Request destruction of the window by the server */
outmsg.msgid = NX_SVRMSG_CLOSEWINDOW;
outmsg.wnd = wnd;
return nxmu_sendserver(wnd->conn, &outmsg, sizeof(struct nxsvrmsg_closewindow_s));
}
-222
View File
@@ -1,222 +0,0 @@
/****************************************************************************
* graphics/nxmu/nx_connect.c
*
* Copyright (C) 2008-2009, 2011-2013 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
* 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 <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <mqueue.h>
#include <errno.h>
#include <debug.h>
#include <nuttx/kmalloc.h>
#include <nuttx/nx/nx.h>
#include "nxfe.h"
/****************************************************************************
* Pre-Processor Definitions
****************************************************************************/
/****************************************************************************
* Private Types
****************************************************************************/
/****************************************************************************
* Private Data
****************************************************************************/
/* Each client is assigned a unique ID using the g_nxcid counter. That
* counter increments as each new counter is created and is* protected for
* thread safefy with g_nxlibsem. Note that these are the only global values
* in the NX implementation. This is because the client ID must be unique
* even across all server instances.
*
* NOTE: that client ID 0 is reserved for the server(s) themselves
*/
static sem_t g_nxlibsem = { 1 };
static uint32_t g_nxcid = 1;
/****************************************************************************
* Public Data
****************************************************************************/
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: nx_connectinstance
*
* Description:
* Open a connection from a client to the NX server. One one client
* connection is normally needed per thread as each connection can host
* multiple windows.
*
* NOTES:
* - This function returns before the connection is fully instantiated.
* it is necessary to wait for the connection event before using the
* returned handle.
* - Multiple instances of the NX server may run at the same time,
* each with different message queue names.
*
* Input Parameters:
* svrmqname - The name for the server incoming message queue
*
* Return:
* Success: A non-NULL handle used with subsequent NX accesses
* Failure: NULL is returned and errno is set appropriately
*
****************************************************************************/
NXHANDLE nx_connectinstance(FAR const char *svrmqname)
{
FAR struct nxfe_conn_s *conn;
struct nxsvrmsg_s outmsg;
char climqname[NX_CLIENT_MXNAMELEN];
struct mq_attr attr;
int ret;
/* Sanity checking */
#ifdef CONFIG_DEBUG
if (!svrmqname)
{
errno = EINVAL;
return NULL;
}
#endif
/* Allocate the NX client structure */
conn = (FAR struct nxfe_conn_s *)kzalloc(sizeof(struct nxfe_conn_s));
if (!conn)
{
errno = ENOMEM;
goto errout;
}
/* Create the client MQ name */
nxmu_semtake(&g_nxlibsem);
conn->cid = g_nxcid++;
nxmu_semgive(&g_nxlibsem);
sprintf(climqname, NX_CLIENT_MQNAMEFMT, conn->cid);
/* Open the client MQ for reading */
attr.mq_maxmsg = CONFIG_NX_MXCLIENTMSGS;
attr.mq_msgsize = NX_MXCLIMSGLEN;
attr.mq_flags = 0;
#ifdef CONFIG_NX_BLOCKING
conn->crdmq = mq_open(climqname, O_RDONLY|O_CREAT, 0666, &attr);
#else
conn->crdmq = mq_open(climqname, O_RDONLY|O_CREAT|O_NONBLOCK, 0666, &attr);
#endif
if (conn->crdmq == (mqd_t)-1)
{
gdbg("mq_open(%s) failed: %d\n", climqname, errno);
goto errout_with_conn;
}
/* Open the server MQ for writing */
attr.mq_maxmsg = CONFIG_NX_MXSERVERMSGS;
attr.mq_msgsize = NX_MXSVRMSGLEN;
attr.mq_flags = 0;
conn->cwrmq = mq_open(svrmqname, O_WRONLY|O_CREAT, 0666, &attr);
if (conn->cwrmq == (mqd_t)-1)
{
gdbg("mq_open(%s) failed: %d\n", svrmqname, errno);
goto errout_with_rmq;
}
/* Inform the server that this client exists */
outmsg.msgid = NX_SVRMSG_CONNECT;
outmsg.conn = conn;
ret = nxmu_sendserver(conn, &outmsg, sizeof(struct nxsvrmsg_s));
if (ret < 0)
{
gdbg("nxmu_sendserver failed: %d\n", errno);
goto errout_with_wmq;
}
#if 0
/* Now read until we get a response to this message. The server will
* respond with either (1) NX_CLIMSG_CONNECTED, in which case the state
* will change to NX_CLISTATE_CONNECTED, or (2) NX_CLIMSG_DISCONNECTED
* in which case, nx_message will fail with errno = EHOSTDOWN.
*/
do
{
ret = nx_eventhandler((NXHANDLE)conn);
if (ret < 0)
{
gdbg("nx_message failed: %d\n", errno);
goto errout_with_wmq;
}
usleep(300000);
}
while (conn->state != NX_CLISTATE_CONNECTED);
#endif
return (NXHANDLE)conn;
errout_with_wmq:
mq_close(conn->cwrmq);
errout_with_rmq:
mq_close(conn->crdmq);
errout_with_conn:
kfree(conn);
errout:
return NULL;
}
-108
View File
@@ -1,108 +0,0 @@
/****************************************************************************
* graphics/nxmu/nx_disconnect.c
*
* 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
* 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 <mqueue.h>
#include <errno.h>
#include <debug.h>
#include <nuttx/nx/nx.h>
#include "nxfe.h"
/****************************************************************************
* Pre-Processor Definitions
****************************************************************************/
/****************************************************************************
* Private Types
****************************************************************************/
/****************************************************************************
* Private Data
****************************************************************************/
/****************************************************************************
* Public Data
****************************************************************************/
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: nx_disconnect
*
* Description:
* Disconnect a client from the NX server and/or free resources reserved
* by nx_connect/nx_connectinstance.
*
* Input Parameters:
* handle - the handle returned by nx_connect
*
* Return:
* OK on success; ERROR on failure with the errno set appropriately.
* NOTE that handle will no long be valid upon return.
*
****************************************************************************/
void nx_disconnect(NXHANDLE handle)
{
FAR struct nxfe_conn_s *conn = (FAR struct nxfe_conn_s *)handle;
struct nxsvrmsg_s outmsg;
int ret;
/* Inform the server that this client no longer exists */
outmsg.msgid = NX_SVRMSG_DISCONNECT;
outmsg.conn = conn;
/* We will finish the teardown upon receipt of the DISCONNECTED message */
ret = nxmu_sendserver(conn, &outmsg, sizeof(struct nxsvrmsg_s));
if (ret < 0)
{
gdbg("ERROR: nxmu_sendserver() returned %d\n", ret);
}
}
-99
View File
@@ -1,99 +0,0 @@
/****************************************************************************
* graphics/nxmu/nx_kbdchin.c
*
* 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
* 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 <stdint.h>
#include <errno.h>
#include <debug.h>
#include <nuttx/nx/nx.h>
#include "nxfe.h"
#ifdef CONFIG_NX_KBD
/****************************************************************************
* Pre-Processor Definitions
****************************************************************************/
/****************************************************************************
* Private Types
****************************************************************************/
/****************************************************************************
* Private Data
****************************************************************************/
/****************************************************************************
* Public Data
****************************************************************************/
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: nx_kbdchin
*
* Description:
* Used by a thread or interrupt handler that manages some kind of keypad
* hardware to report text information to the NX server. That text
* data will be routed by the NX server to the appropriate window client.
*
****************************************************************************/
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;
/* Inform the server of the new keypad data */
outmsg.msgid = NX_SVRMSG_KBDIN;
outmsg.nch = 1;
outmsg.ch[0] = ch;
return nxmu_sendserver(conn, &outmsg, sizeof(struct nxsvrmsg_kbdin_s));
}
#endif /* CONFIG_NX_KBD */
-124
View File
@@ -1,124 +0,0 @@
/****************************************************************************
* graphics/nxmu/nx_kbdin.c
*
* Copyright (C) 2008-2009, 2011-2013 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
* 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 <stdint.h>
#include <stdlib.h>
#include <errno.h>
#include <debug.h>
#include <nuttx/kmalloc.h>
#include <nuttx/nx/nx.h>
#include "nxfe.h"
#ifdef CONFIG_NX_KBD
/****************************************************************************
* Pre-Processor Definitions
****************************************************************************/
/****************************************************************************
* Private Types
****************************************************************************/
/****************************************************************************
* Private Data
****************************************************************************/
/****************************************************************************
* Public Data
****************************************************************************/
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: nx_kbdin
*
* Description:
* Used by a thread or interrupt handler that manages some kind of keypad
* hardware to report text information to the NX server. That text
* data will be routed by the NX server to the appropriate window client.
*
****************************************************************************/
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 nxsvrmsg_kbdin_s *outmsg;
int size;
int ret;
int i;
/* Allocate a bigger message to account for the variable amount of character
* data.
*/
size = sizeof(struct nxsvrmsg_kbdin_s) + nch - 1;
outmsg = (FAR struct nxsvrmsg_kbdin_s *)kmalloc(size);
if (!outmsg)
{
errno = ENOMEM;
return ERROR;
}
/* Inform the server of the new keypad data */
outmsg->msgid = NX_SVRMSG_KBDIN;
outmsg->nch = nch;
for (i = 0; i < nch; i++)
{
outmsg->ch[i] = ch[i];
}
ret = nxmu_sendserver(conn, outmsg, size);
kfree(outmsg);
return ret;
}
#endif /* CONFIG_NX_KBD */
-100
View File
@@ -1,100 +0,0 @@
/****************************************************************************
* graphics/nxmu/nx_mousein.c
*
* 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
* 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 <stdint.h>
#include <errno.h>
#include <debug.h>
#include <nuttx/nx/nx.h>
#include "nxfe.h"
#ifdef CONFIG_NX_MOUSE
/****************************************************************************
* Pre-Processor Definitions
****************************************************************************/
/****************************************************************************
* Private Types
****************************************************************************/
/****************************************************************************
* Private Data
****************************************************************************/
/****************************************************************************
* Public Data
****************************************************************************/
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: nx_mousein
*
* Description:
* Used by a thread or interrupt handler that manages some kind of pointing
* hardware to report new positional data to the NX server. That positional
* data will be routed by the NX server to the appropriate window client.
*
****************************************************************************/
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;
/* Inform the server that this client no longer exists */
outmsg.msgid = NX_SVRMSG_MOUSEIN;
outmsg.pt.x = x;
outmsg.pt.y = y;
outmsg.buttons = buttons;
return nxmu_sendserver(conn, &outmsg, sizeof(struct nxsvrmsg_mousein_s));
}
#endif /* CONFIG_NX_MOUSE */
-105
View File
@@ -1,105 +0,0 @@
/****************************************************************************
* graphics/nxmu/nx_releasebkgd.c
*
* 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
* 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 <errno.h>
#include <debug.h>
#include <nuttx/nx/nx.h>
#include "nxfe.h"
/****************************************************************************
* Pre-Processor Definitions
****************************************************************************/
/****************************************************************************
* Private Types
****************************************************************************/
/****************************************************************************
* Private Data
****************************************************************************/
/****************************************************************************
* Public Data
****************************************************************************/
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: nx_releasebkgd
*
* Description:
* Release the background window previously acquired using nx_openbgwindow
* and return control of the background to NX.
*
* Input Parameters:
* hwnd - The handle returned (indirectly) by nx_requestbkgd
*
* Return:
* OK on success; ERROR on failure with errno set appropriately
*
****************************************************************************/
int nx_releasebkgd(NXWINDOW hwnd)
{
FAR struct nxbe_window_s *wnd = (FAR struct nxbe_window_s *)hwnd;
struct nxsvrmsg_releasebkgd_s outmsg;
#ifdef CONFIG_DEBUG
if (!wnd)
{
errno = EINVAL;
return ERROR;
}
#endif
/* Request access to the background window from the server */
outmsg.msgid = NX_SVRMSG_RELEASEBKGD;
return nxmu_sendserver(wnd->conn, &outmsg, sizeof(struct nxsvrmsg_releasebkgd_s));
}
-136
View File
@@ -1,136 +0,0 @@
/****************************************************************************
* graphics/nxmu/nx_requestbkgd.c
*
* 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
* 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 <errno.h>
#include <debug.h>
#include <nuttx/nx/nx.h>
#include "nxfe.h"
/****************************************************************************
* Pre-Processor Definitions
****************************************************************************/
/****************************************************************************
* Private Types
****************************************************************************/
/****************************************************************************
* Private Data
****************************************************************************/
/****************************************************************************
* Public Data
****************************************************************************/
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: nx_requestbkgd
*
* Description:
* NX normally controls a separate window called the background window.
* It repaints the window as necessary using only a solid color fill. The
* background window always represents the entire screen and is always
* below other windows. It is useful for an application to control the
* background window in the following conditions:
*
* - If you want to implement a windowless solution. The single screen
* can be used to creat a truly simple graphic environment. In this
* case, you should probably also de-select CONFIG_NX_MULTIUSER as well.
* - When you want more on the background than a solid color. For
* example, if you want an image in the background, or animations in the
* background, or live video, etc.
*
* This API only requests the handle of the background window. That
* handle will be returned asynchronously in a subsequent position and
* redraw callbacks.
*
*
* Cautions:
* - The following should never be called using the background window.
* They are guaranteed to cause severe crashes:
*
* nx_setposition, nx_setsize, nx_raise, nx_lower.
*
* - Neither nx_opengbwindow or nx_closebgwindow should be called more than
* once. Multiple instances of the background window are not supported.
*
* Input Parameters:
* handle - The handle returned by nx_connect
* cb - Callbacks to use for processing background window events
* arg - User provided argument (see nx_openwindow, nx_constructwindow)
*
* Return:
* OK: Success; ERROR of failure with errno set appropriately.
*
****************************************************************************/
int nx_requestbkgd(NXHANDLE handle, FAR const struct nx_callback_s *cb,
FAR void *arg)
{
FAR struct nxfe_conn_s *conn = (FAR struct nxfe_conn_s *)handle;
struct nxsvrmsg_requestbkgd_s outmsg;
#ifdef CONFIG_DEBUG
if (!conn || !cb)
{
errno = EINVAL;
return ERROR;
}
#endif
/* Request access to the background window from the server */
outmsg.msgid = NX_SVRMSG_REQUESTBKGD;
outmsg.conn = conn;
outmsg.cb = cb;
outmsg.arg = arg;
return nxmu_sendserver(conn, &outmsg, sizeof(struct nxsvrmsg_requestbkgd_s));
}
-109
View File
@@ -1,109 +0,0 @@
/****************************************************************************
* graphics/nxmu/nx_setbgcolor.c
*
* 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
* 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 <errno.h>
#include <debug.h>
#include <nuttx/nx/nx.h>
#include "nxfe.h"
/****************************************************************************
* Pre-Processor Definitions
****************************************************************************/
/****************************************************************************
* Private Types
****************************************************************************/
/****************************************************************************
* Private Data
****************************************************************************/
/****************************************************************************
* Public Data
****************************************************************************/
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: nx_setbgcolor
*
* Description:
* Set the color of the background
*
* Input Parameters:
* handle - The connection handle
* color - The color to use in the background
*
* Return:
* OK on success; ERROR on failure with errno set appropriately
*
****************************************************************************/
int nx_setbgcolor(NXHANDLE handle,
nxgl_mxpixel_t color[CONFIG_NX_NPLANES])
{
FAR struct nxfe_conn_s *conn = (FAR struct nxfe_conn_s *)handle;
struct nxsvrmsg_setbgcolor_s outmsg;
#ifdef CONFIG_DEBUG
if (!conn)
{
errno = EINVAL;
return ERROR;
}
#endif
/* Format the fill command */
outmsg.msgid = NX_SVRMSG_SETBGCOLOR;
nxgl_colorcopy(outmsg.color, color);
/* Forward the fill command to the server */
return nxmu_sendserver(conn, &outmsg, sizeof(struct nxsvrmsg_setbgcolor_s));
}
+31 -470
View File
File diff suppressed because it is too large Load Diff
-139
View File
@@ -1,139 +0,0 @@
/****************************************************************************
* graphics/nxmu/nx_openwindow.c
*
* 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
* 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 <stdlib.h>
#include <errno.h>
#include <debug.h>
#include <nuttx/kmalloc.h>
#include <nuttx/nx/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 kmalloc() (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 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;
#ifdef CONFIG_DEBUG
if (!wnd)
{
errno = EINVAL;
return ERROR;
}
if (!conn || !cb)
{
kfree(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;
return nxmu_sendserver(conn, &outmsg, sizeof(struct nxsvrmsg_openwindow_s));
}
-112
View File
@@ -1,112 +0,0 @@
/****************************************************************************
* graphics/nxmu/nxmu_sendserver.c
*
* Copyright (C) 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
* 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 <mqueue.h>
#include <errno.h>
#include <debug.h>
#include "nxfe.h"
/****************************************************************************
* Pre-Processor Definitions
****************************************************************************/
/****************************************************************************
* Private Types
****************************************************************************/
/****************************************************************************
* Private Data
****************************************************************************/
/****************************************************************************
* Public Data
****************************************************************************/
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* 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
*
****************************************************************************/
int nxmu_sendserver(FAR struct nxfe_conn_s *conn, FAR const void *msg,
size_t msglen)
{
int ret;
/* Sanity checking */
#ifdef CONFIG_DEBUG
if (!conn || !conn->cwrmq)
{
set_errno(EINVAL);
return ERROR;
}
#endif
/* Send the message to the server */
ret = mq_send(conn->cwrmq, msg, msglen, NX_SVRMSG_PRIO);
if (ret < 0)
{
gdbg("mq_send failed: %d\n", errno);
}
return ret;
}
+1 -1
View File
@@ -73,7 +73,7 @@
* Name: nxmu_sendwindow
*
* Description:
* Send a message to the server detined for a specific window at
* Send a message to the server destined for a specific window at
* NX_SVRMSG_PRIO priority
*
* Input Parameters: