summaryrefslogtreecommitdiff
path: root/nuttx/graphics/nxmu
diff options
context:
space:
mode:
Diffstat (limited to 'nuttx/graphics/nxmu')
-rw-r--r--nuttx/graphics/nxmu/Make.defs9
-rw-r--r--nuttx/graphics/nxmu/nx_closewindow.c1
-rw-r--r--nuttx/graphics/nxmu/nx_connect.c10
-rw-r--r--nuttx/graphics/nxmu/nx_eventhandler.c19
-rw-r--r--nuttx/graphics/nxmu/nx_fill.c10
-rw-r--r--nuttx/graphics/nxmu/nx_openwindow.c13
-rw-r--r--nuttx/graphics/nxmu/nx_setbgcolor.c9
-rw-r--r--nuttx/graphics/nxmu/nxfe.h9
-rw-r--r--nuttx/graphics/nxmu/nxmu_openwindow.c9
-rw-r--r--nuttx/graphics/nxmu/nxmu_reportposition.c9
-rw-r--r--nuttx/graphics/nxmu/nxmu_server.c14
11 files changed, 71 insertions, 41 deletions
diff --git a/nuttx/graphics/nxmu/Make.defs b/nuttx/graphics/nxmu/Make.defs
index 0fb5e2c70..29fc13d64 100644
--- a/nuttx/graphics/nxmu/Make.defs
+++ b/nuttx/graphics/nxmu/Make.defs
@@ -34,10 +34,11 @@
############################################################################
NX_ASRCS =
-NXAPI_CSRCS = nx_bitmap.c nx_connect.c nx_disconnect.c nx_eventhandler.c \
- nx_fill.c nx_filltrapezoid.c nx_getposition.c nx_kbdchin.c \
- nx_kbdin.c nx_lower.c nx_mousein.c nx_move.c nx_openwindow.c \
- nx_raise.c nx_setsize.c nx_setbgcolor.c nx_setposition.c
+NXAPI_CSRCS = nx_bitmap.c nx_closewindow.c nx_connect.c nx_disconnect.c \
+ nx_eventhandler.c nx_fill.c nx_filltrapezoid.c \
+ nx_getposition.c nx_kbdchin.c nx_kbdin.c nx_lower.c \
+ nx_mousein.c nx_move.c nx_openwindow.c nx_raise.c \
+ nx_setsize.c nx_setbgcolor.c nx_setposition.c
NXMU_CSRCS = nxmu_server.c nxmu_openwindow.c nxmu_reportposition.c nxmu_kbdin.c \
nxmu_mouse.c nxmu_redrawreq.c nxmu_semtake.c
NX_CSRCS = $(NXAPI_CSRCS) $(NXMU_CSRCS)
diff --git a/nuttx/graphics/nxmu/nx_closewindow.c b/nuttx/graphics/nxmu/nx_closewindow.c
index 0eab0170c..efda4643c 100644
--- a/nuttx/graphics/nxmu/nx_closewindow.c
+++ b/nuttx/graphics/nxmu/nx_closewindow.c
@@ -89,6 +89,7 @@
int nx_closewindow(NXWINDOW hwnd)
{
FAR struct nxbe_window_s *wnd = (FAR struct nxbe_window_s *)hwnd;
+ FAR struct nxfe_conn_s *conn = wnd->conn;
struct nxsvrmsg_closewindow_s outmsg;
int ret;
diff --git a/nuttx/graphics/nxmu/nx_connect.c b/nuttx/graphics/nxmu/nx_connect.c
index 9e29f736b..401d20d92 100644
--- a/nuttx/graphics/nxmu/nx_connect.c
+++ b/nuttx/graphics/nxmu/nx_connect.c
@@ -99,7 +99,6 @@ static uint32 g_nxcid = 1;
*
* Input Parameters:
* svrmqname - The name for the server incoming message queue
- * cb - Callbacks used to process received NX server messages
*
* Return:
* Success: A non-NULL handle used with subsequent NX accesses
@@ -107,8 +106,7 @@ static uint32 g_nxcid = 1;
*
****************************************************************************/
-NXHANDLE nx_connectionstance(FAR const char *svrmqname,
- FAR const struct nx_callback_s *cb)
+NXHANDLE nx_connectionstance(FAR const char *svrmqname)
{
FAR struct nxfe_conn_s *conn;
struct nxsvrmsg_s msg;
@@ -119,7 +117,7 @@ NXHANDLE nx_connectionstance(FAR const char *svrmqname,
/* Sanity checking */
#ifdef CONFIG_DEBUG
- if (!svrmqname || !cb)
+ if (!svrmqname)
{
errno = EINVAL;
return NULL;
@@ -135,10 +133,6 @@ NXHANDLE nx_connectionstance(FAR const char *svrmqname,
goto errout;
}
- /* Save the callback vtable */
-
- conn->cb = cb;
-
/* Create the client MQ name */
nxmu_semtake(&g_nxlibsem);
diff --git a/nuttx/graphics/nxmu/nx_eventhandler.c b/nuttx/graphics/nxmu/nx_eventhandler.c
index f89565b01..cd1a1a7a1 100644
--- a/nuttx/graphics/nxmu/nx_eventhandler.c
+++ b/nuttx/graphics/nxmu/nx_eventhandler.c
@@ -128,6 +128,7 @@ int nx_eventhandler(NXHANDLE handle)
{
FAR struct nxfe_conn_s *conn = (FAR struct nxfe_conn_s *)handle;
struct nxsvrmsg_s *msg;
+ struct nxbe_window_s *wnd;
ubyte buffer[NX_MXCLIMSGLEN];
int nbytes;
@@ -182,7 +183,9 @@ int nx_eventhandler(NXHANDLE handle)
if (conn->cb->redraw)
{
FAR struct nxclimsg_redraw_s *redraw = (FAR struct nxclimsg_redraw_s *)buffer;
- conn->cb->redraw((NXWINDOW)redraw->wnd, &redraw->rect, redraw->more);
+ wnd = redraw->wnd;
+ DEBUGASSERT(wnd);
+ wnd->cb->redraw((NXWINDOW)wnd, &redraw->rect, redraw->more);
}
break;
@@ -190,7 +193,9 @@ int nx_eventhandler(NXHANDLE handle)
if (conn->cb->position)
{
FAR struct nxclimsg_newposition_s *postn = (FAR struct nxclimsg_newposition_s *)buffer;
- conn->cb->position((NXWINDOW)postn->wnd, &postn->size, &postn->pos);
+ wnd = postn->wnd;
+ DEBUGASSERT(wnd);
+ wnd->cb->position((NXWINDOW)wnd, &postn->size, &postn->pos, &postn->bounds);
}
break;
@@ -199,7 +204,9 @@ int nx_eventhandler(NXHANDLE handle)
if (conn->cb->mousein)
{
FAR struct nxclimsg_mousein_s *mouse = (FAR struct nxclimsg_mousein_s *)buffer;
- conn->cb->mousein((NXWINDOW)mouse->wnd, &mouse->pos, mouse->buttons);
+ wnd = mouse->wnd;
+ DEBUGASSERT(wnd);
+ wnd->cb->mousein((NXWINDOW)wnd, &mouse->pos, mouse->buttons);
}
break;
#endif
@@ -209,13 +216,15 @@ int nx_eventhandler(NXHANDLE handle)
if (conn->cb->kbdin)
{
FAR struct nxclimsg_kbdin_s *kbd = (FAR struct nxclimsg_kbdin_s *)buffer;
- conn->cb->kbdin((NXWINDOW)kbd->wnd, kbd->nch, kbd->ch);
+ wnd = kbd->wnd;
+ DEBUGASSERT(wnd);
+ wnd->cb->kbdin((NXWINDOW)wnd, kbd->nch, kbd->ch);
}
break;
#endif
default:
- gdbg("Unrecogized message opcode: %d\n", (FAR struct nxsvrmsg_s *)buffer->msgid);
+ gdbg("Unrecognized message opcode: %d\n", ((FAR struct nxsvrmsg_s *)buffer)->msgid);
break;
}
diff --git a/nuttx/graphics/nxmu/nx_fill.c b/nuttx/graphics/nxmu/nx_fill.c
index 79a71ce8b..b92aef537 100644
--- a/nuttx/graphics/nxmu/nx_fill.c
+++ b/nuttx/graphics/nxmu/nx_fill.c
@@ -44,6 +44,7 @@
#include <errno.h>
#include <debug.h>
+#include <nuttx/nxglib.h>
#include <nuttx/nx.h>
#include "nxfe.h"
@@ -88,13 +89,12 @@
*
****************************************************************************/
-int nx_fill(NXWINDOW hwnd, FAR struct nxgl_rect_s *rect,
+int nx_fill(NXWINDOW hwnd, FAR const struct nxgl_rect_s *rect,
nxgl_mxpixel_t color[CONFIG_NX_NPLANES])
{
FAR struct nxbe_window_s *wnd = (FAR struct nxbe_window_s *)hwnd;
struct nxsvrmsg_fill_s outmsg;
int ret;
- int i;
#ifdef CONFIG_DEBUG
if (!wnd || !wnd->conn || !rect || !color)
@@ -110,11 +110,7 @@ int nx_fill(NXWINDOW hwnd, FAR struct nxgl_rect_s *rect,
outmsg.wnd = wnd;
nxgl_rectcopy(&outmsg.rect, rect);
-
- for (i = 0; i < CONFIG_NX_NPLANES; i++)
- {
- outmsg.color[i] = color[i];
- }
+ nxgl_colorcopy(outmsg.color, color);
/* Forward the fill command to the server */
diff --git a/nuttx/graphics/nxmu/nx_openwindow.c b/nuttx/graphics/nxmu/nx_openwindow.c
index 927f5b8fd..03fa9786b 100644
--- a/nuttx/graphics/nxmu/nx_openwindow.c
+++ b/nuttx/graphics/nxmu/nx_openwindow.c
@@ -79,7 +79,7 @@
*
* Input Parameters:
* handle - The handle returned by nx_connect
- * wnd - Location to return the handle of the new window
+ * cb - Callbacks used to process windo events
*
* Return:
* Success: A non-NULL handle used with subsequent NX accesses
@@ -87,13 +87,21 @@
*
****************************************************************************/
-NXWINDOW nx_openwindow(NXHANDLE handle)
+NXWINDOW nx_openwindow(NXHANDLE handle, FAR const struct nx_callback_s *cb)
{
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
+ if (!conn || !cb)
+ {
+ errno = EINVAL;
+ return NULL;
+ }
+#endif
+
/* Pre-allocate the window structure */
wnd = (FAR struct nxbe_window_s *)zalloc(sizeof(struct nxbe_window_s));
@@ -108,6 +116,7 @@ NXWINDOW nx_openwindow(NXHANDLE handle)
outmsg.msgid = NX_SVRMSG_OPENWINDOW;
outmsg.conn = conn;
outmsg.wnd = wnd;
+ outmsg.cb = cb;
ret = mq_send(conn->cwrmq, &outmsg, sizeof(struct nxsvrmsg_openwindow_s), NX_SVRMSG_PRIO);
if (ret < 0)
diff --git a/nuttx/graphics/nxmu/nx_setbgcolor.c b/nuttx/graphics/nxmu/nx_setbgcolor.c
index 57e3b9445..302c20549 100644
--- a/nuttx/graphics/nxmu/nx_setbgcolor.c
+++ b/nuttx/graphics/nxmu/nx_setbgcolor.c
@@ -91,7 +91,6 @@ int nx_setbgcolor(NXHANDLE handle,
FAR struct nxfe_conn_s *conn = (FAR struct nxfe_conn_s *)handle;
struct nxsvrmsg_setbgcolor_s outmsg;
int ret;
- int i;
#ifdef CONFIG_DEBUG
if (!conn)
@@ -103,12 +102,8 @@ int nx_setbgcolor(NXHANDLE handle,
/* Format the fill command */
- outmsg.msgid = NX_SVRMSG_SETBGCOLOR;
-
- for (i = 0; i < CONFIG_NX_NPLANES; i++)
- {
- outmsg.color[i] = color[i];
- }
+ outmsg.msgid = NX_SVRMSG_SETBGCOLOR;
+ nxgl_colorcopy(outmsg.color, color);
/* Forward the fill command to the server */
diff --git a/nuttx/graphics/nxmu/nxfe.h b/nuttx/graphics/nxmu/nxfe.h
index 8aa14af3c..65aa8cfec 100644
--- a/nuttx/graphics/nxmu/nxfe.h
+++ b/nuttx/graphics/nxmu/nxfe.h
@@ -57,6 +57,10 @@
/* Configuration ************************************************************/
+#ifdef CONFIG_DISABLE_MQUEUE
+# error "Message queues are disabled(CONFIG_DISABLE_MQUEUE)"
+#endif
+
#ifndef CONFIG_NX_MXSERVERMSGS
# define CONFIG_NX_MXSERVERMSGS 32 /* Number of pending messages in server MQ */
#endif
@@ -203,6 +207,7 @@ struct nxclimsg_newposition_s
FAR struct nxbe_window_s *wnd; /* The window whose position/size has changed */
FAR struct nxgl_rect_s size; /* The current window size */
FAR struct nxgl_point_s pos; /* The current window position */
+ FAR struct nxgl_rect_s bounds; /* Size of screen */
};
/* This message reports a new mouse event to a particular window */
@@ -249,6 +254,7 @@ struct nxsvrmsg_openwindow_s
uint32 msgid; /* NX_SVRMSG_OPENWINDOW */
FAR struct nxfe_conn_s *conn; /* The specific connection sending the message */
FAR struct nxbe_window_s *wnd; /* The pre-allocated window structure */
+ FAR const struct nx_callback_s *cb; /* Event handling callbacks */
};
/* This message informs the server that client wishes to close a window */
@@ -429,7 +435,8 @@ EXTERN void nxmu_semtake(sem_t *sem);
EXTERN void nxmu_openwindow(FAR struct nxfe_conn_s *conn,
FAR struct nxbe_state_s *be,
- FAR struct nxbe_window_s *wnd);
+ FAR struct nxbe_window_s *wnd,
+ FAR const struct nx_callback_s *cb);
/****************************************************************************
* Name: nxfe_reportposition
diff --git a/nuttx/graphics/nxmu/nxmu_openwindow.c b/nuttx/graphics/nxmu/nxmu_openwindow.c
index 508ab6ad8..159651793 100644
--- a/nuttx/graphics/nxmu/nxmu_openwindow.c
+++ b/nuttx/graphics/nxmu/nxmu_openwindow.c
@@ -77,15 +77,17 @@
* conn - The client containing connection information [IN]
* be - The server state structure [IN]
* wnd - The pre-allocated window structure to be ininitilized [IN/OUT]
+ * cb - Callbacks used to process window events
*
* Return:
* None
*
****************************************************************************/
-void nxsmu_openwindow(FAR struct nxfe_conn_s *conn,
- FAR struct nxbe_state_s *be,
- FAR struct nxbe_window_s *wnd)
+void nxmu_openwindow(FAR struct nxfe_conn_s *conn,
+ FAR struct nxbe_state_s *be,
+ FAR struct nxbe_window_s *wnd,
+ FAR const struct nx_callback_s *cb)
{
/* The window structure was allocated in nx_openwindow and all fields have
* been set to zero (except sem... see below). We need only initialize the
@@ -94,6 +96,7 @@ void nxsmu_openwindow(FAR struct nxfe_conn_s *conn,
wnd->be = be;
wnd->conn = conn;
+ wnd->cb = cb;
/* Now, insert the new window at the top on the display. topwind is
* never NULL (it may point only at the background window, however)
diff --git a/nuttx/graphics/nxmu/nxmu_reportposition.c b/nuttx/graphics/nxmu/nxmu_reportposition.c
index 64006a6d3..ed72ca52f 100644
--- a/nuttx/graphics/nxmu/nxmu_reportposition.c
+++ b/nuttx/graphics/nxmu/nxmu_reportposition.c
@@ -43,6 +43,7 @@
#include <errno.h>
#include <debug.h>
+#include <nuttx/nxglib.h>
#include <nuttx/nx.h>
#include "nxfe.h"
@@ -90,10 +91,16 @@ void nxfe_reportposition(FAR struct nxbe_window_s *wnd)
outmsg.pos.x = wnd->origin.x;
outmsg.pos.y = wnd->origin.y;
- /* Convert the frame rectangle to a window-relative rectangle */
+ /* Convert the window bounding box to a window-relative rectangle */
nxgl_rectoffset(&outmsg.size, &wnd->bounds, -wnd->origin.x, -wnd->origin.y);
+ /* Provide the background window bounding box which is the screen limits
+ * It must always have (0,0) as its origin
+ */
+
+ nxgl_rectcopy(&outmsg.bounds, &wnd->be->bkgd.bounds);
+
/* And provide this to the client */
ret = mq_send(wnd->conn->swrmq, &outmsg, sizeof(struct nxclimsg_newposition_s), NX_SVRMSG_PRIO);
diff --git a/nuttx/graphics/nxmu/nxmu_server.c b/nuttx/graphics/nxmu/nxmu_server.c
index e1fc000e1..9d778a185 100644
--- a/nuttx/graphics/nxmu/nxmu_server.c
+++ b/nuttx/graphics/nxmu/nxmu_server.c
@@ -378,7 +378,7 @@ int nx_runinstance(FAR const char *mqname, FAR struct fb_vtable_s *fb)
case NX_SVRMSG_OPENWINDOW: /* Create a new window */
{
FAR struct nxsvrmsg_openwindow_s *openmsg = (FAR struct nxsvrmsg_openwindow_s *)buffer;
- nxmu_openwindow(openmsg->conn, &fe.be, openmsg->wnd);
+ nxmu_openwindow(openmsg->conn, &fe.be, openmsg->wnd, openmsg->cb);
}
break;
@@ -454,6 +454,7 @@ int nx_runinstance(FAR const char *mqname, FAR struct fb_vtable_s *fb)
case NX_SVRMSG_SETBGCOLOR: /* Set the color of the background */
{
FAR struct nxsvrmsg_setbgcolor_s *bgcolormsg = (FAR struct nxsvrmsg_setbgcolor_s *)buffer;
+ nxgl_colorcopy(fe.be.bgcolor, bgcolormsg->color);
nxbe_fill(&fe.be.bkgd, &fe.be.bkgd.bounds, bgcolormsg->color);
}
break;
@@ -478,8 +479,15 @@ int nx_runinstance(FAR const char *mqname, FAR struct fb_vtable_s *fb)
/* Messages sent to the backgound window ***************************/
case NX_CLIMSG_REDRAW: /* Re-draw the background window */
- nxbe_redraw(&fe.be, &fe.be.bkgd, &fe.be.bkgd.bounds);
- break;
+ {
+ FAR struct nxclimsg_redraw_s *redraw = (FAR struct nxclimsg_redraw_s *)buffer;
+ DEBUGASSERT(redraw->wnd == &fe.be.bkgd);
+ gvdbg("Re-draw background rect={(%d,%d),(%d,%d)}\n",
+ redraw->rect.pt1.x, redraw->rect.pt1.y,
+ redraw->rect.pt2.x, redraw->rect.pt2.y);
+ nxbe_fill(&fe.be.bkgd, &redraw->rect, fe.be.bgcolor);
+ }
+ break;
case NX_CLIMSG_MOUSEIN: /* Ignored */
case NX_CLIMSG_KBDIN: