diff options
Diffstat (limited to 'nuttx/graphics')
25 files changed, 175 insertions, 186 deletions
diff --git a/nuttx/graphics/nxbe/nxbe.h b/nuttx/graphics/nxbe/nxbe.h index 077d8214e..393a06075 100644 --- a/nuttx/graphics/nxbe/nxbe.h +++ b/nuttx/graphics/nxbe/nxbe.h @@ -125,21 +125,22 @@ struct nxbe_window_s { /* State information */ - FAR struct nxbe_state_s *be; /* The back-end state structure */ + 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 */ + 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 */ + FAR struct nxbe_window_s *above; /* The window "above" this window */ + FAR struct nxbe_window_s *below; /* The window "below this one */ - struct nxgl_rect_s bounds; /* The bounding rectangle of window */ - struct nxgl_point_s origin; /* The position of the top-left corner of the window */ + struct nxgl_rect_s bounds; /* The bounding rectangle of window */ + struct nxgl_point_s origin; /* The position of the top-left corner of the window */ }; /* Back-end state ***********************************************************/ @@ -153,6 +154,13 @@ struct nxbe_state_s FAR struct nxbe_window_s *topwnd; /* The window at the top of the display */ struct nxbe_window_s bkgd; /* The background window is always at the bottom */ + /* At present, only a solid colored background is supported for refills. The + * following provides the background color. It would be nice to support + * background bitmap images as well. + */ + + nxgl_mxpixel_t bgcolor[CONFIG_NX_NPLANES]; + /* vinfo describes the video controller and plane[n].pinfo describes color * plane 'n' supported by the video controller. Most common color models * fit in one plane, but this array provides future support for hardware diff --git a/nuttx/graphics/nxglib/Make.defs b/nuttx/graphics/nxglib/Make.defs index 9502256cc..b2e0acd1f 100644 --- a/nuttx/graphics/nxglib/Make.defs +++ b/nuttx/graphics/nxglib/Make.defs @@ -56,8 +56,9 @@ RECT_CSRCS = nxglib_rectcopy.c nxglib_rectoffset.c nxglib_vectoradd.c \ nxglib_rectoverlap.c nxglib_nullrect.c TRAP_CSRCS = nxglib_runoffset.c nxglib_runcopy.c \ nxglib_trapoffset.c nxglib_trapcopy.c +COLOR_CSRCS = nxglib_colorcopy.c NXGLIB_CSRCS = nxglib_rgb2yuv.c nxglib_yuv2rgb.c \ $(RFILL1_CSRCS) $(RFILL2_CSRCS) $(TFILL1_CSRCS) $(TFILL2_CSRCS) \ $(RMOVE1_CSRCS) $(RMOVE2_CSRCS) $(RCOPY1_CSRCS) $(RCOPY2_CSRCS) \ - $(RECT_CSRCS) $(TRAP_CSRCS) + $(RECT_CSRCS) $(TRAP_CSRCS) $(COLOR_CSRCS) diff --git a/nuttx/graphics/nxsu/nxsu_mouse.c b/nuttx/graphics/nxglib/nxglib_colorcopy.c index 5650c8dd2..a466640b3 100644 --- a/nuttx/graphics/nxsu/nxsu_mouse.c +++ b/nuttx/graphics/nxglib/nxglib_colorcopy.c @@ -1,5 +1,5 @@ /**************************************************************************** - * graphics/nxmu/nxmu__mouse.c + * graphics/nxglib/nxsglib_colorcopy.c * * Copyright (C) 2008 Gregory Nutt. All rights reserved. * Author: Gregory Nutt <spudmonkey@racsa.co.cr> @@ -40,13 +40,8 @@ #include <nuttx/config.h> #include <sys/types.h> -#include <errno.h> -#include <debug.h> - -#include <nuttx/nx.h> -#include "nxfe.h" - -#ifdef CONFIG_NX_MOUSE +#include <nuttx/fb.h> +#include <nuttx/nxglib.h> /**************************************************************************** * Pre-Processor Definitions @@ -60,10 +55,6 @@ * Private Data ****************************************************************************/ -static struct nxgl_point_s g_mpos; -static struct nxgl_rect_s g_mrange; -static struct g_mbutton; - /**************************************************************************** * Public Data ****************************************************************************/ @@ -77,102 +68,22 @@ static struct g_mbutton; ****************************************************************************/ /**************************************************************************** - * Name: nxmu_mouseinit + * Name: nxgl_colorcopy * * Description: - * Initialize with the mouse in the center of the display + * This is essentially memcpy for colors. This does very little for us + * other than hide all of the conditional compilation for planar colors + * in one place. * ****************************************************************************/ -void nxmu_mouseinit(int x, int y) +void nxgl_colorcopy(nxgl_mxpixel_t dest[CONFIG_NX_NPLANES], + const nxgl_mxpixel_t src[CONFIG_NX_NPLANES]) { - g_mrange.x = x; - g_mrange.y = y; - g_mpos.x = x / 2; - g_mpos.y = y / 2; - g_mbutton = 0; -} + int i; -/**************************************************************************** - * Name: nxmu_mousereport - * - * Description: - * Report mouse position info to the specified window - * - ****************************************************************************/ - -void nxmu_mousereport(struct nxbe_window_s *wnd) -{ - struct nxclimsg_mousein_s outmsg; - int ret; - - outmsg.msgid = NX_CLIMSG_MOUSEIN; - outmsg.wnd = wnd; - outmsg.pos.x = g_mpos.x; - outmsg.pos.y = g_mpos.y; - outmsg.buttons = g_mbutton; - - ret = mq_send(wnd->conn->swrmq, outmsg, sizeof(struct nxclimsg_mousein_s), NX_SVRMSG_PRIO); - if (ret < 0) + for (i = 0; i < CONFIG_NX_NPLANES; i++) { - gdbg("mq_send failed: %d\n", errno); + dest[i] = src[i]; } } - -/**************************************************************************** - * Name: nxmu_mousein - * - * Description: - * New positional data has been received from the thread or interrupt - * handler that manages some kind of pointing hardware. Route that - * positional data to the appropriate window client. - * - ****************************************************************************/ - -void nxmu_mousein(FAR struct nxfe_state_s *fe, - FAR const struct nxgl_point_s *pos, int button) -{ - struct nxbe_window_s *wnd; - x_coord_t x = pos->x; - x_coord_t y = pos->y; - - /* Clip x and y to within the bounding rectangle */ - - if (x < 0) - { - x = 0; - } - else if (x >= g_mbound.x) - { - x = g_mbound.x - 1; - } - - if (y < 0) - { - y = 0; - } - else if (y >= g_mbound.y) - { - y = g_mbound.y - 1; - } - - /* Look any change in values */ - - if (x != g_mpos.x || y != g_mpos.y || button != g_mbutton) - { - /* Update the mouse value */ - - g_mpos.x = x; - g_mpos.y = y; - b_mbutton = button; - - /* Pick the window to receive the mouse event */ - - for (wnd = fe->be.topwnd; wnd; wnd = wnd->below) - { - nxmu_mousereport(wnd); - } - } -} - -#endif /* CONFIG_NX_MOUSE */ 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: diff --git a/nuttx/graphics/nxsu/Make.defs b/nuttx/graphics/nxsu/Make.defs index 3750b6f7b..b238251c3 100644 --- a/nuttx/graphics/nxsu/Make.defs +++ b/nuttx/graphics/nxsu/Make.defs @@ -38,5 +38,5 @@ NXAPI_CSRCS = nx_bitmap.c nx_close.c nx_closewindow.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_open.c nx_openwindow.c \ nx_raise.c nx_setsize.c nx_setbgcolor.c nx_setposition.c -NXSU_CSRCS = nxsu_mouse.c nxsu_redrawreq.c nxsu_reportposition.c +NXSU_CSRCS = nxsu_redrawreq.c nxsu_reportposition.c NX_CSRCS = $(NXAPI_CSRCS) $(NXSU_CSRCS) diff --git a/nuttx/graphics/nxsu/nx_fill.c b/nuttx/graphics/nxsu/nx_fill.c index 14319f630..b9102d136 100644 --- a/nuttx/graphics/nxsu/nx_fill.c +++ b/nuttx/graphics/nxsu/nx_fill.c @@ -88,7 +88,7 @@ * ****************************************************************************/ -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]) { #ifdef CONFIG_DEBUG diff --git a/nuttx/graphics/nxsu/nx_kbdchin.c b/nuttx/graphics/nxsu/nx_kbdchin.c index 8ce7a8ca2..37a357b42 100644 --- a/nuttx/graphics/nxsu/nx_kbdchin.c +++ b/nuttx/graphics/nxsu/nx_kbdchin.c @@ -87,11 +87,13 @@ int nx_kbdchin(NXHANDLE handle, ubyte ch) FAR struct nxfe_state_s *fe = (FAR struct nxfe_state_s *)handle; FAR struct nxbe_window_s *wnd = fe->be.topwnd; - /* Give the keypad event only to the top child */ + /* Give the keypad event only to the top window (unless the top window + * is the background window). + */ - if (fe->be.cb->kbdin) + if (wnd->cb->kbdin) { - fe->be.cb->kbdin(wnd, 1, &ch); + wnd->kbdin(wnd, 1, &ch); } } diff --git a/nuttx/graphics/nxsu/nx_kbdin.c b/nuttx/graphics/nxsu/nx_kbdin.c index cc9e53c0e..c6f65eabb 100644 --- a/nuttx/graphics/nxsu/nx_kbdin.c +++ b/nuttx/graphics/nxsu/nx_kbdin.c @@ -86,11 +86,13 @@ int int nx_kbdin(NXHANDLE handle, ubyte nch const char *ch) FAR struct nxfe_state_s *fe = (FAR struct nxfe_state_s *)handle; FAR struct nxbe_window_s *wnd = fe->be.topwnd; - /* Give the keypad event only to the top child */ + /* Give the keypad event only to the top window (unless the top child + * is the background window). + */ - if (fe->be.cb->kbdin) + if (wnd->cb->kbdin) { - fe->be.cb->kbdin(wnd, kbd->nch, kbd->ch); + wnd->cb->kbdin(wnd, kbd->nch, kbd->ch); } } diff --git a/nuttx/graphics/nxsu/nx_mousein.c b/nuttx/graphics/nxsu/nx_mousein.c index 30f53175e..256d59da1 100644 --- a/nuttx/graphics/nxsu/nx_mousein.c +++ b/nuttx/graphics/nxsu/nx_mousein.c @@ -105,9 +105,9 @@ void nxsu_mousereport(struct nxbe_window_s *wnd) { /* Give the keypad event only to the top child */ - if (fe->be.cb->mousein) + if (win->cb->mousein) { - fe->be.cb->mousein(wnd, &g_mpos, g_mbutton); + win->cb->mousein((NXWINDOW)wnd, &g_mpos, g_mbutton); } } diff --git a/nuttx/graphics/nxsu/nx_open.c b/nuttx/graphics/nxsu/nx_open.c index a28d385ae..2ebe94d4a 100644 --- a/nuttx/graphics/nxsu/nx_open.c +++ b/nuttx/graphics/nxsu/nx_open.c @@ -57,9 +57,27 @@ ****************************************************************************/ /**************************************************************************** + * Private Function Prototypes + ****************************************************************************/ + +static void nxsu_bkgdredraw(NXWINDOW hwnd, + FAR const struct nxgl_rect_s *rect, boolean more); + +/**************************************************************************** * Private Data ****************************************************************************/ +static const struct nx_callback_s g_bkgdcb = +{ + nxsu_bkgdredraw, /* redraw */ + NULL /* position */ +#ifdef CONFIG_NX_MOUSE + , NULL /* mousein */ +#endif +#ifdef CONFIG_NX_KBD + , NULL /* my kbdin */ +#endif +}; /**************************************************************************** * Public Data ****************************************************************************/ @@ -69,6 +87,21 @@ ****************************************************************************/ /**************************************************************************** + * Name: nxsu_bkgdredraw + ****************************************************************************/ + +static void nxsu_bkgdredraw(NXWINDOW hwnd, + FAR const struct nxgl_rect_s *rect, boolean more) +{ + FAR struct nxbe_window_s *wnd = (FAR struct nxbe_window_s *)hwnd; + FAR struct nxbe_state_s *be = wnd->be; + + gvdbg("BG redraw rect={(%d,%d),(%d,%d)}\n", + rect->pt1.x, rect->pt1.y, rect->pt2.x, rect->pt2.y); + nxbe_fill(wnd, &wnd->bounds, be->bgcolor); +} + +/**************************************************************************** * Name: nxsu_setup ****************************************************************************/ @@ -97,9 +130,11 @@ static inline int nxsu_setup(FAR struct fb_vtable_s *fb, } #endif - /* Initialize the non-NULL elements of the background window */ + /* Initialize the non-NULL elements of the back-end structure window */ + /* Initialize the background window */ fe->be.bkgd.be = &fe->be; + fe->be.bkgd.cb = &g_bkgdcb; fe->be.bkgd.bounds.pt2.x = fe->be.vinfo.xres; fe->be.bkgd.bounds.pt2.y = fe->be.vinfo.yres; @@ -133,7 +168,6 @@ static inline int nxsu_setup(FAR struct fb_vtable_s *fb, * * Input Parameters: * fb - Vtable "object" of the framebuffer "driver" to use - * cb - Callbacks used to process received NX server messages * * Return: * Success: A non-NULL handle used with subsequent NX accesses @@ -141,7 +175,7 @@ static inline int nxsu_setup(FAR struct fb_vtable_s *fb, * ****************************************************************************/ -NXHANDLE nx_open(FAR struct fb_vtable_s *fb, FAR const struct nx_callback_s *cb) +NXHANDLE nx_open(FAR struct fb_vtable_s *fb) { FAR struct nxfe_state_s *fe; int ret; @@ -149,7 +183,7 @@ NXHANDLE nx_open(FAR struct fb_vtable_s *fb, FAR const struct nx_callback_s *cb) /* Sanity checking */ #ifdef CONFIG_DEBUG - if (!cb) + if (!fb) { errno = EINVAL; return NULL; @@ -165,10 +199,6 @@ NXHANDLE nx_open(FAR struct fb_vtable_s *fb, FAR const struct nx_callback_s *cb) return NULL; } - /* Save the callback vtable */ - - fe->cb = cb; - /* Initialize and configure the server */ ret = nxsu_setup(fb, fe); @@ -177,6 +207,9 @@ NXHANDLE nx_open(FAR struct fb_vtable_s *fb, FAR const struct nx_callback_s *cb) return NULL; /* nxsu_setup sets errno */ } + /* Fill the initial background window */ + + nxbe_fill(&fe->be.bkgd, &fe->be.bkgd.bounds, fe->be.bgcolor); return (NXHANDLE)fe; } diff --git a/nuttx/graphics/nxsu/nx_openwindow.c b/nuttx/graphics/nxsu/nx_openwindow.c index ef205c2ba..005d907fd 100644 --- a/nuttx/graphics/nxsu/nx_openwindow.c +++ b/nuttx/graphics/nxsu/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,14 +87,14 @@ * ****************************************************************************/ -NXWINDOW nx_openwindow(NXHANDLE handle) +NXWINDOW nx_openwindow(NXHANDLE handle, FAR const struct nx_callback_s *cb) { 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; #ifdef CONFIG_DEBUG - if (!fe) + if (!fe || !cb) { errno = EINVAL; return NULL; @@ -113,6 +113,7 @@ NXWINDOW nx_openwindow(NXHANDLE handle) /* Initialize the window structure */ 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) @@ -124,6 +125,10 @@ NXWINDOW nx_openwindow(NXHANDLE handle) 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 diff --git a/nuttx/graphics/nxsu/nx_setbgcolor.c b/nuttx/graphics/nxsu/nx_setbgcolor.c index ce0be2f47..4bc02be10 100644 --- a/nuttx/graphics/nxsu/nx_setbgcolor.c +++ b/nuttx/graphics/nxsu/nx_setbgcolor.c @@ -98,6 +98,7 @@ int nx_setbgcolor(NXHANDLE handle, } #endif + nxgl_colorcopy(fe->be.bgcolor, color); nxbe_fill(&fe->be.bkgd, &fe->be.bkgd.bounds, color); return OK; } diff --git a/nuttx/graphics/nxsu/nxfe.h b/nuttx/graphics/nxsu/nxfe.h index 5ea01b129..f4e4cdfd0 100644 --- a/nuttx/graphics/nxsu/nxfe.h +++ b/nuttx/graphics/nxsu/nxfe.h @@ -61,7 +61,10 @@ /* Server state structure ***************************************************/ -/* This the the server 'front-end' state structure */ +/* This the the server 'front-end' state structure. It is really the same + * as the back-end state, but we wrap the back-end state so that we can add + * things to the structure in the future + */ struct nxfe_state_s { @@ -71,10 +74,6 @@ struct nxfe_state_s */ struct nxbe_state_s be; - - /* Event handling callbacks */ - - FAR const struct nx_callback_s *cb; /* Message handling callbacks */ }; /**************************************************************************** diff --git a/nuttx/graphics/nxsu/nxsu_redrawreq.c b/nuttx/graphics/nxsu/nxsu_redrawreq.c index 796b329c7..b7623f426 100644 --- a/nuttx/graphics/nxsu/nxsu_redrawreq.c +++ b/nuttx/graphics/nxsu/nxsu_redrawreq.c @@ -80,18 +80,16 @@ void nxfe_redrawreq(FAR struct nxbe_window_s *wnd, FAR const struct nxgl_rect_s *rect) { - FAR struct nxbe_state_s *be = wnd->be; - FAR struct nxfe_state_s *fe = (FAR struct nxfe_state_s *)be; - struct nxgl_rect_s relrect; + struct nxgl_rect_s relrect; #ifdef CONFIG_DEBUG - if (wnd) + if (!wnd) { return; } #endif - if (fe->cb->redraw) + if (wnd->cb->redraw) { /* Convert the frame rectangle to a window-relative rectangle */ @@ -99,7 +97,7 @@ void nxfe_redrawreq(FAR struct nxbe_window_s *wnd, FAR const struct nxgl_rect_s /* And request the redraw */ - fe->cb->redraw((NXWINDOW)wnd, &relrect, FALSE); + wnd->cb->redraw((NXWINDOW)wnd, &relrect, FALSE); } } diff --git a/nuttx/graphics/nxsu/nxsu_reportposition.c b/nuttx/graphics/nxsu/nxsu_reportposition.c index 97dddee4a..7c7bad751 100644 --- a/nuttx/graphics/nxsu/nxsu_reportposition.c +++ b/nuttx/graphics/nxsu/nxsu_reportposition.c @@ -80,8 +80,7 @@ void nxfe_reportposition(FAR struct nxbe_window_s *wnd) { - FAR struct nxbe_state_s *be = wnd->be; - FAR struct nxfe_state_s *fe = (FAR struct nxfe_state_s *)be; + FAR struct nxbe_state_s *be = wnd->be; struct nxgl_rect_s rect; #ifdef CONFIG_DEBUG @@ -95,14 +94,14 @@ void nxfe_reportposition(FAR struct nxbe_window_s *wnd) * with the way things are done in multiple user mode. */ - if (fe->cb->position) + if (wnd->cb->position) { /* Convert the frame rectangle to a window-relative rectangle */ nxgl_rectoffset(&rect, &wnd->bounds, -wnd->origin.x, -wnd->origin.y); - /* And pride this to the client */ + /* And provide this to the client */ - fe->cb->position(wnd, &rect, &wnd->origin); + wnd->cb->position(wnd, &rect, &wnd->origin, &be->bkgd.bounds); } } |