summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--nuttx/ChangeLog2
-rw-r--r--nuttx/Documentation/NuttX.html3
-rw-r--r--nuttx/examples/nx/nx_internal.h10
-rw-r--r--nuttx/examples/nx/nx_main.c321
-rw-r--r--nuttx/examples/nx/nx_server.c3
-rw-r--r--nuttx/graphics/nxbe/nxbe.h20
-rw-r--r--nuttx/graphics/nxglib/Make.defs3
-rw-r--r--nuttx/graphics/nxglib/nxglib_colorcopy.c (renamed from nuttx/graphics/nxsu/nxsu_mouse.c)113
-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
-rw-r--r--nuttx/graphics/nxsu/Make.defs2
-rw-r--r--nuttx/graphics/nxsu/nx_fill.c2
-rw-r--r--nuttx/graphics/nxsu/nx_kbdchin.c8
-rw-r--r--nuttx/graphics/nxsu/nx_kbdin.c8
-rw-r--r--nuttx/graphics/nxsu/nx_mousein.c4
-rw-r--r--nuttx/graphics/nxsu/nx_open.c49
-rw-r--r--nuttx/graphics/nxsu/nx_openwindow.c11
-rw-r--r--nuttx/graphics/nxsu/nx_setbgcolor.c1
-rw-r--r--nuttx/graphics/nxsu/nxfe.h9
-rw-r--r--nuttx/graphics/nxsu/nxsu_redrawreq.c10
-rw-r--r--nuttx/graphics/nxsu/nxsu_reportposition.c9
-rw-r--r--nuttx/include/nuttx/nx.h122
-rw-r--r--nuttx/include/nuttx/nxglib.h12
32 files changed, 583 insertions, 251 deletions
diff --git a/nuttx/ChangeLog b/nuttx/ChangeLog
index 12f492a15..bb73136c1 100644
--- a/nuttx/ChangeLog
+++ b/nuttx/ChangeLog
@@ -589,3 +589,5 @@
* Added some rasterizers to the graphics library
0.3.20 2008-xx-xx Gregory Nutt <spudmonkey@racsa.co.cr>
+ * Initial release of a tiny windowing system for NuttX (not well tested at initial check-in)
+
diff --git a/nuttx/Documentation/NuttX.html b/nuttx/Documentation/NuttX.html
index c8aa054e0..0fdedd3db 100644
--- a/nuttx/Documentation/NuttX.html
+++ b/nuttx/Documentation/NuttX.html
@@ -8,7 +8,7 @@
<tr align="center" bgcolor="#e4e4e4">
<td>
<h1><big><font color="#3c34ec"><i>NuttX RTOS</i></font></big></h1>
- <p>Last Updated: November 26, 2008</p>
+ <p>Last Updated: November 28, 2008</p>
</td>
</tr>
</table>
@@ -1205,6 +1205,7 @@ buildroot-0.1.2 2007-11-06 &lt;spudmonkey@racsa.co.cr&gt
<pre><ul>
nuttx-0.3.20 2008-xx-xx Gregory Nutt &lt;spudmonkey@racsa.co.cr&gt;
+ * Initial release of a tiny windowing system for NuttX (not well tested at initial check-in)
pascal-0.1.3 2008-xx-xx Gregory Nutt &lt;spudmonkey@racsa.co.cr&gt;
diff --git a/nuttx/examples/nx/nx_internal.h b/nuttx/examples/nx/nx_internal.h
index 5209490b0..6ae52869b 100644
--- a/nuttx/examples/nx/nx_internal.h
+++ b/nuttx/examples/nx/nx_internal.h
@@ -58,7 +58,15 @@
#endif
#ifndef CONFIG_EXAMPLES_NX_BGCOLOR
-# define CONFIG_EXAMPLES_NX_BGCOLOR 0
+# define CONFIG_EXAMPLES_NX_BGCOLOR ' '
+#endif
+
+#ifndef CONFIG_EXAMPLES_NX_COLOR1
+# define CONFIG_EXAMPLES_NX_COLOR1 '1'
+#endif
+
+#ifndef CONFIG_EXAMPLES_NX_COLOR2
+# define CONFIG_EXAMPLES_NX_COLOR2 '2'
#endif
/* Debug ********************************************************************/
diff --git a/nuttx/examples/nx/nx_main.c b/nuttx/examples/nx/nx_main.c
index efbf747ca..cd91cea2e 100644
--- a/nuttx/examples/nx/nx_main.c
+++ b/nuttx/examples/nx/nx_main.c
@@ -41,6 +41,7 @@
#include <sys/types.h>
#include <stdio.h>
+#include <stdlib.h>
#include <unistd.h>
#include <sched.h>
#include <errno.h>
@@ -59,90 +60,188 @@
* Private Types
****************************************************************************/
+enum exitcode_e
+{
+ NXEXIT_SUCCESS = 0,
+ NXEXIT_TASKCREATE,
+ NXEXIT_FBINITIALIZE,
+ NXEXIT_FBGETVPLANE,
+ NXEXIT_NXOPEN,
+ NXEXIT_NXSETBGCOLOR,
+ NXEXIT_NXOPENWINDOW,
+ NXEXIT_NXSETSIZE,
+ NXEXIT_NXSETPOSITION,
+ NXEXIT_NXCLOSEWINDOW
+};
+
/****************************************************************************
* Private Function Prototypes
****************************************************************************/
-static void my_redraw(NXWINDOW handle, FAR const struct nxgl_rect_s *rect,
- boolean more);
-static void my_position(NXWINDOW handle, FAR const struct nxgl_rect_s *size,
- FAR const struct nxgl_point_s *pos);
+static void nxeg_redraw1(NXWINDOW hwnd, FAR const struct nxgl_rect_s *rect,
+ boolean more);
+static void nxeg_redraw2(NXWINDOW hwnd, FAR const struct nxgl_rect_s *rect,
+ boolean more);
+static void nxeg_position1(NXWINDOW hwnd, FAR const struct nxgl_rect_s *size,
+ FAR const struct nxgl_point_s *pos,
+ FAR const struct nxgl_rect_s *bounds);
+static void nxeg_position2(NXWINDOW hwnd, FAR const struct nxgl_rect_s *size,
+ FAR const struct nxgl_point_s *pos,
+ FAR const struct nxgl_rect_s *bounds);
#ifdef CONFIG_NX_MOUSE
-static void my_mousein(NXWINDOW handle, FAR const struct nxgl_point_s *pos,
- ubyte buttons);
+static void nxeg_mousein1(NXWINDOW hwnd, FAR const struct nxgl_point_s *pos,
+ ubyte buttons);
+static void nxeg_mousein2(NXWINDOW hwnd, FAR const struct nxgl_point_s *pos,
+ ubyte buttons);
#endif
#ifdef CONFIG_NX_KBD
-static void my_kbdin(NXWINDOW handle, ubyte nch, const ubyte *ch);
+static void nxeg_kbdin(NXWINDOW hwnd, ubyte nch, const ubyte *ch);
#endif
/****************************************************************************
* Private Data
****************************************************************************/
-static const struct nx_callback_s g_nxcb =
+static const struct nx_callback_s g_nxcb1 =
+{
+ nxeg_redraw1, /* redraw */
+ nxeg_position1 /* position */
+#ifdef CONFIG_NX_MOUSE
+ , nxeg_mousein1 /* mousein */
+#endif
+#ifdef CONFIG_NX_KBD
+ , nxeg_kbdin1 /* my kbdin */
+#endif
+};
+
+static const struct nx_callback_s g_nxcb2 =
{
- my_redraw, /* redraw */
- my_position /* position */
+ nxeg_redraw2, /* redraw */
+ nxeg_position2 /* position */
#ifdef CONFIG_NX_MOUSE
- , my_mousein /* mousein */
+ , nxeg_mousein2 /* mousein */
#endif
#ifdef CONFIG_NX_KBD
- , my_kbdin /* my kbdin */
+ , nxeg_kbdin2 /* my kbdin */
#endif
};
+static nxgl_coord_t g_xres;
+static nxgl_coord_t g_yres;
+
+static nxgl_mxpixel_t g_color1[CONFIG_NX_NPLANES];
+static nxgl_mxpixel_t g_color2[CONFIG_NX_NPLANES];
+
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
- * Name: my_redraw
+ * Name: nxeg_redraw1
****************************************************************************/
-static void my_redraw(NXWINDOW hwnd, FAR const struct nxgl_rect_s *rect,
- boolean more)
+static void nxeg_redraw1(NXWINDOW hwnd, FAR const struct nxgl_rect_s *rect,
+ boolean more)
{
- message("my_redraw: hwnd=%p rect={(%d,%d),(%d,%d)} more=%s\n",
+ message("nxeg_redraw1: hwnd=%p rect={(%d,%d),(%d,%d)} more=%s\n",
hwnd,
rect->pt1.x, rect->pt1.y, rect->pt2.x, rect->pt2.y,
more ? "TRUE" : "FALSE");
+ nx_fill(hwnd, rect, g_color1);
}
/****************************************************************************
- * Name: my_position
+ * Name: nxeg_redraw2
****************************************************************************/
-static void my_position(NXWINDOW hwnd, FAR const struct nxgl_rect_s *size,
- FAR const struct nxgl_point_s *pos)
+static void nxeg_redraw2(NXWINDOW hwnd, FAR const struct nxgl_rect_s *rect,
+ boolean more)
{
- message("my_position: hwnd=%p size={(%d,%d),(%d,%d)} pos=(%d,%d)\n",
+ message("nxeg_redraw2: hwnd=%p rect={(%d,%d),(%d,%d)} more=%s\n",
+ hwnd,
+ rect->pt1.x, rect->pt1.y, rect->pt2.x, rect->pt2.y,
+ more ? "TRUE" : "FALSE");
+ nx_fill(hwnd, rect, g_color2);
+}
+
+/****************************************************************************
+ * Name: nxeg_position1
+ ****************************************************************************/
+
+static void nxeg_position1(NXWINDOW hwnd, FAR const struct nxgl_rect_s *size,
+ FAR const struct nxgl_point_s *pos,
+ FAR const struct nxgl_rect_s *bounds)
+{
+ /* Report the position */
+
+ message("nxeg_position1: hwnd=%p size={(%d,%d),(%d,%d)} pos=(%d,%d) bounds={(%d,%d),(%d,%d)}\n",
hwnd,
size->pt1.x, size->pt1.y, size->pt2.x, size->pt2.y,
- pos->x, pos->y);
+ pos->x, pos->y,
+ bounds->pt1.x, bounds->pt1.y, bounds->pt2.x, bounds->pt2.y);
+
+ /* Save the window limits */
+
+ g_xres = bounds->pt2.x;
+ g_yres = bounds->pt2.y;
}
/****************************************************************************
- * Name: my_mousein
+ * Name: nxeg_position2
+ ****************************************************************************/
+
+static void nxeg_position2(NXWINDOW hwnd, FAR const struct nxgl_rect_s *size,
+ FAR const struct nxgl_point_s *pos,
+ FAR const struct nxgl_rect_s *bounds)
+{
+ /* Report the position */
+
+ message("nxeg_position2: hwnd=%p size={(%d,%d),(%d,%d)} pos=(%d,%d) bounds={(%d,%d),(%d,%d)}\n",
+ hwnd,
+ size->pt1.x, size->pt1.y, size->pt2.x, size->pt2.y,
+ pos->x, pos->y,
+ bounds->pt1.x, bounds->pt1.y, bounds->pt2.x, bounds->pt2.y);
+
+ /* Save the window limits */
+
+ g_xres = bounds->pt2.x;
+ g_yres = bounds->pt2.y;
+}
+
+/****************************************************************************
+ * Name: nxeg_mousein1
+ ****************************************************************************/
+
+#ifdef CONFIG_NX_MOUSE
+static void nxeg_mousein1(NXWINDOW hwnd, FAR const struct nxgl_point_s *pos,
+ ubyte buttons)
+{
+ message("nxeg_mousein1: hwnd=%p pos=(%d,%d) button=%02x\n",
+ hwnd, pos->x, pos->y, buttons);
+}
+#endif
+
+/****************************************************************************
+ * Name: nxeg_mousein2
****************************************************************************/
#ifdef CONFIG_NX_MOUSE
-static void my_mousein(NXWINDOW hwnd, FAR const struct nxgl_point_s *pos,
- ubyte buttons)
+static void nxeg_mousein2(NXWINDOW hwnd, FAR const struct nxgl_point_s *pos,
+ ubyte buttons)
{
- message("my_mousein: hwnd=%p pos=(%d,%d) button=%02x\n",
+ message("nxeg_mousein2: hwnd=%p pos=(%d,%d) button=%02x\n",
hwnd, pos->x, pos->y, buttons);
}
#endif
/****************************************************************************
- * Name:
+ * Name: nxeg_kbdinfo
****************************************************************************/
#ifdef CONFIG_NX_KBD
-static void my_kbdin(NXWINDOW hwnd, ubyte nch, const ubyte *ch)
+static void nxeg_kbdinfo(ubyte nch, const ubyte *ch)
{
int i;
- message("my_kbdin: hwnd=%p nch=%d\n", hwnd, nch);
for (i = 0; i < nch; i++)
{
if (isprint(ch[i]))
@@ -158,6 +257,30 @@ static void my_kbdin(NXWINDOW hwnd, ubyte nch, const ubyte *ch)
#endif
/****************************************************************************
+ * Name: nxeg_kbdin1
+ ****************************************************************************/
+
+#ifdef CONFIG_NX_KBD
+static void nxeg_kbdin1(NXWINDOW hwnd, ubyte nch, const ubyte *ch)
+{
+ message("nxeg_kbdin1: hwnd=%p nch=%d\n", hwnd, nch);
+ nxeg_kbdinfo(nch, ch);
+}
+#endif
+
+/****************************************************************************
+ * Name: nxeg_kbdin2
+ ****************************************************************************/
+
+#ifdef CONFIG_NX_KBD
+static void nxeg_kbdin2(NXWINDOW hwnd, ubyte nch, const ubyte *ch)
+{
+ message("nxeg_kbdin2: hwnd=%p nch=%d\n", hwnd, nch);
+ nxeg_kbdinfo(nch, ch);
+}
+#endif
+
+/****************************************************************************
* Public Functions
****************************************************************************/
@@ -176,25 +299,37 @@ void user_initialize(void)
int user_start(int argc, char *argv[])
{
NXHANDLE hnx;
- NXWINDOW hwnd;
+ NXWINDOW hwnd1;
+ NXWINDOW hwnd2;
#ifndef CONFIG_NX_MULTIUSER
FAR struct fb_vtable_s *fb;
#else
pid_t servrid;
#endif
+ struct nxgl_rect_s rect;
+ struct nxgl_point_s pt;
nxgl_mxpixel_t color;
- int exitcode = 0;
+ int exitcode = NXEXIT_SUCCESS;
int ret;
+ int i;
+
+ /* Initialize window colors */
+
+ for (i = 0; i < CONFIG_NX_NPLANES; i++)
+ {
+ g_color1[i] = CONFIG_EXAMPLES_NX_COLOR1;
+ g_color1[2] = CONFIG_EXAMPLES_NX_COLOR2;
+ }
#ifdef CONFIG_NX_MULTIUSER
/* Start the server task */
message("user_start: Starting nx_servertask task\n");
- servrid = task_create("NX Server", 50, CONFIG_EXAMPLES_NX_STACKSIZE, nx_servertask, argv);
+ servrid = task_create("NX Server", 50, CONFIG_EXAMPLES_NX_STACKSIZE, nx_servertask, NULL);
if (servrid < 0)
{
message("user_start: Failed to create nx_servertask task: %d\n", errno);
- exitcode = 1;
+ exitcode = NXEXIT_TASKCREATE;
goto errout;
}
@@ -204,7 +339,7 @@ int user_start(int argc, char *argv[])
/* Connect to the server */
- hnx = nx_connect(&g_nxcb);
+ hnx = nx_connect();
#else
/* Initialize the frame buffer device */
@@ -213,7 +348,7 @@ int user_start(int argc, char *argv[])
if (ret < 0)
{
message("user_start: up_fbinitialize failed: %d\n", -ret);
- exitcode = 2;
+ exitcode = NXEXIT_FBINITIALIZE;
goto errout;
}
@@ -221,21 +356,21 @@ int user_start(int argc, char *argv[])
if (!fb)
{
message("user_start: up_fbgetvplane failed, vplane=%d\n", CONFIG_EXAMPLES_NX_VPLANE);
- exitcode = 3;
+ exitcode = NXEXIT_FBGETVPLANE;
goto errout;
}
/* Then open NX */
message("user_start: Open NX\n");
- hnx = nx_open(fb, &g_nxcb);
+ hnx = nx_open(fb);
#endif
message("user_start: NX handle=%p\n", hnx);
if (!hnx)
{
message("user_start: Failed to get NX handle: %d\n", errno);
- exitcode = 4;
+ exitcode = NXEXIT_NXOPEN;
goto errout;
}
@@ -247,32 +382,120 @@ int user_start(int argc, char *argv[])
if (ret < 0)
{
message("user_start: nx_setbgcolor failed: %d\n", errno);
- exitcode = 5;
+ exitcode = NXEXIT_NXSETBGCOLOR;
goto errout_with_nx;
}
- /* Create a window */
+ /* Create window #1 */
- message("user_start: Create a window\n");
- hwnd = nx_openwindow(hnx);
- message("user_start: NX window=%p\n", hwnd);
+ message("user_start: Create window #1\n");
+ hwnd1 = nx_openwindow(hnx, &g_nxcb1);
+ message("user_start: hwnd1=%p\n", hwnd1);
- if (!hwnd)
+ if (!hwnd1)
{
message("user_start: nx_openwindow failed: %d\n", errno);
- exitcode = 6;
+ exitcode = NXEXIT_NXOPENWINDOW;
goto errout_with_nx;
}
+ message("user_start: Screen resolution (%d,%d)\n", g_xres, g_yres);
+
+ /* Set the size of the window 2 */
- /* Close the window */
+ rect.pt1.x = 0;
+ rect.pt1.y = 0;
+ rect.pt2.x = g_xres/2;
+ rect.pt2.y = g_yres/2;
-//errout_with_window:
+ message("user_start: Set hwnd1 size to (%d,%d)\n", rect.pt2.x, rect.pt2.y);
+ ret = nx_setsize(hwnd1, &rect);
+ if (ret < 0)
+ {
+ message("user_start: nx_setsize failed: %d\n", errno);
+ exitcode = NXEXIT_NXSETSIZE;
+ goto errout_with_hwnd1;
+ }
+
+ pt.x = g_xres / 4;
+ pt.y = g_yres / 4;
+
+ message("user_start: Set hwnd1 postion to (%d,%d)\n", pt.x, pt.y);
+ ret = nx_setposition(hwnd1, &pt);
+ if (ret < 0)
+ {
+ message("user_start: nx_setposition failed: %d\n", errno);
+ exitcode = NXEXIT_NXSETPOSITION;
+ goto errout_with_hwnd1;
+ }
+
+ /* Create window #2 */
+
+ message("user_start: Create window #1\n");
+ hwnd2 = nx_openwindow(hnx, &g_nxcb2);
+ message("user_start: hwnd2=%p\n", hwnd2);
+
+ if (!hwnd2)
+ {
+ message("user_start: nx_openwindow failed: %d\n", errno);
+ exitcode = NXEXIT_NXOPENWINDOW;
+ goto errout_with_hwnd1;
+ }
+
+ /* Set the size of the window 2 == size of window 1*/
+
+ message("user_start: Set hwnd2 size to (%d,%d)\n", rect.pt2.x, rect.pt2.y);
+ ret = nx_setsize(hwnd2, &rect);
+ if (ret < 0)
+ {
+ message("user_start: nx_setsize failed: %d\n", errno);
+ exitcode = NXEXIT_NXSETSIZE;
+ goto errout_with_hwnd2;
+ }
+
+ pt.x = g_xres - rect.pt2.x - pt.x;
+ pt.y = g_yres - rect.pt2.y - pt.y;
+
+ message("user_start: Set hwnd2 postion to (%d,%d)\n", pt.x, pt.y);
+ ret = nx_setposition(hwnd2, &pt);
+ if (ret < 0)
+ {
+ message("user_start: nx_setposition failed: %d\n", errno);
+ exitcode = NXEXIT_NXSETPOSITION;
+ goto errout_with_hwnd2;
+ }
+
+ /* Lower window 2 */
+
+ message("user_start: Lower window #2\n");
+ ret = nx_lower(hwnd2);
+ if (ret < 0)
+ {
+ message("user_start: nx_lower failed: %d\n", errno);
+ exitcode = NXEXIT_NXSETPOSITION;
+ goto errout_with_hwnd2;
+ }
+
+ /* Close the window 2 */
+
+errout_with_hwnd2:
message("user_start: Close window\n");
- ret = nx_closewindow(hwnd);
- if (!hwnd)
+ ret = nx_closewindow(hwnd2);
+ if (ret < 0)
+ {
+ message("user_start: nx_openwindow failed: %d\n", errno);
+ exitcode = NXEXIT_NXCLOSEWINDOW;
+ goto errout_with_nx;
+ }
+
+ /* Close the window1 */
+
+errout_with_hwnd1:
+ message("user_start: Close window\n");
+ ret = nx_closewindow(hwnd1);
+ if (ret < 0)
{
message("user_start: nx_openwindow failed: %d\n", errno);
- exitcode = 7;
+ exitcode = NXEXIT_NXCLOSEWINDOW;
goto errout_with_nx;
}
diff --git a/nuttx/examples/nx/nx_server.c b/nuttx/examples/nx/nx_server.c
index 3f48d190c..43d61c25b 100644
--- a/nuttx/examples/nx/nx_server.c
+++ b/nuttx/examples/nx/nx_server.c
@@ -45,6 +45,7 @@
#include <unistd.h>
#include <sched.h>
#include <errno.h>
+#include <debug.h>
#include <nuttx/arch.h>
#include <nuttx/nx.h>
@@ -91,7 +92,7 @@ int nx_servertask(int argc, char *argv[])
return 1;
}
- fb = up_fbgetvplane(CONFIG_EXAMPLES_NX_VPLANE)
+ fb = up_fbgetvplane(CONFIG_EXAMPLES_NX_VPLANE);
if (!fb)
{
message("nx_serverthread: up_fbgetvplane failed, vplane=%d\n", CONFIG_EXAMPLES_NX_VPLANE);
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);
}
}
diff --git a/nuttx/include/nuttx/nx.h b/nuttx/include/nuttx/nx.h
index a8e77d227..25ad7d1d0 100644
--- a/nuttx/include/nuttx/nx.h
+++ b/nuttx/include/nuttx/nx.h
@@ -53,6 +53,13 @@
#define NX_DEFAULT_SERVER_MQNAME "/dev/nxs"
+/* Mouse button bits */
+
+#define NX_MOUSE_NOBUTTONS 0x00
+#define NX_MOUSE_LEFTBUTTON 0x01
+#define NX_MOUSE_CENTERBUTTON 0x02
+#define NX_MOUSE_RIGHTBUTTON 0x04
+
/****************************************************************************
* Public Types
****************************************************************************/
@@ -75,19 +82,93 @@ typedef FAR void *NXWINDOW;
/* NX server callbacks ******************************************************/
-/* These define callbacks that must be provided to nx_connect. These
+/* These define callbacks that must be provided to nx_openwindow. These
* callbacks will be invoked as part of the processing performed by
- * nx_message()
+ * nx_eventhandler()
*/
struct nx_callback_s
{
+ /**************************************************************************
+ * Name: redraw
+ *
+ * Descripton:
+ * NX requests that the client re-draw the portion of the window within
+ * with rectangle.
+ *
+ * Input Parameters:
+ * hwnd - Window handle
+ * rect - The rectangle that needs to be re-drawn (in window relative
+ * coordinates
+ * more - TRUE: More re-draw requests will follow
+ *
+ * Returned Value:
+ * None
+ *
+ **************************************************************************/
+
void (*redraw)(NXWINDOW hwnd, FAR const struct nxgl_rect_s *rect, boolean more);
+
+ /**************************************************************************
+ * Name: position
+ *
+ * Descripton:
+ * The size or position of the window has changed (or the window was
+ * just created with zero size.
+ *
+ * Input Parameters:
+ * hwnd - Window handle
+ * size - The size of the window (pt1 should always be zero)
+ * pos - The position of the upper left hand corner of the window on
+ * the overalll display
+ * bounds - The bounding rectangle that the describes the entire
+ * display
+ *
+ * Returned Value:
+ * None
+ *
+ **************************************************************************/
+
void (*position)(NXWINDOW hwnd, FAR const struct nxgl_rect_s *size,
- FAR const struct nxgl_point_s *pos);
+ FAR const struct nxgl_point_s *pos,
+ FAR const struct nxgl_rect_s *bounds);
+
+ /**************************************************************************
+ * Name: mousein
+ *
+ * Descripton:
+ * New mouse data is available for the window
+ *
+ * Input Parameters:
+ * hwnd - Window handle
+ * pos - The (x,y) position of the mouse
+ * buttons - See NX_MOUSE_* definitions
+ *
+ * Returned Value:
+ * None
+ *
+ **************************************************************************/
+
#ifdef CONFIG_NX_MOUSE
void (*mousein)(NXWINDOW hwnd, FAR const struct nxgl_point_s *pos, ubyte buttons);
#endif
+
+ /**************************************************************************
+ * Name: kbdin
+ *
+ * Descripton:
+ * New keyboard/keypad data is available for the window
+ *
+ * Input Parameters:
+ * hwnd - Window handle
+ * nch - The number of characters that are available in ch[]
+ * ch - The array of characters
+ *
+ * Returned Value:
+ * None
+ *
+ **************************************************************************/
+
#ifdef CONFIG_NX_KBD
void (*kbdin)(NXWINDOW hwnd, ubyte nch, const ubyte *ch);
#endif
@@ -135,7 +216,7 @@ extern "C" {
#ifdef CONFIG_NX_MULTIUSER
EXTERN int nx_runinstance(FAR const char *mqname, FAR struct fb_vtable_s *fb);
-# define nx_run(fb) (NX_DEFAULT_SERVER_MQNAME, fb)
+# define nx_run(fb) nx_runinstance(NX_DEFAULT_SERVER_MQNAME, fb)
#endif
/****************************************************************************
@@ -155,7 +236,6 @@ EXTERN int nx_runinstance(FAR const char *mqname, FAR struct fb_vtable_s *fb);
*
* 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
@@ -164,9 +244,8 @@ EXTERN int nx_runinstance(FAR const char *mqname, FAR struct fb_vtable_s *fb);
****************************************************************************/
#ifdef CONFIG_NX_MULTIUSER
-EXTERN NXHANDLE nx_connectionstance(FAR const char *svrmqname,
- FAR const struct nx_callback_s *cb);
-# define nx_connect(cb) nx_connectionstance(NX_DEFAULT_SERVER_MQNAME, cb)
+EXTERN NXHANDLE nx_connectionstance(FAR const char *svrmqname);
+# define nx_connect(cb) nx_connectionstance(NX_DEFAULT_SERVER_MQNAME)
#endif
/****************************************************************************
@@ -190,8 +269,7 @@ EXTERN NXHANDLE nx_connectionstance(FAR const char *svrmqname,
****************************************************************************/
#ifndef CONFIG_NX_MULTIUSER
-EXTERN NXHANDLE nx_open(FAR struct fb_vtable_s *fb,
- FAR const struct nx_callback_s *cb);
+EXTERN NXHANDLE nx_open(FAR struct fb_vtable_s *fb);
#endif
/****************************************************************************
@@ -271,7 +349,7 @@ EXTERN int nx_eventhandler(NXHANDLE handle);
*
* Input Parameters:
* handle - The handle returned by nx_connect
- * wnd - Location to return the handle of the new window
+ * cb - Callbacks used to process window events
*
* Return:
* Success: A non-NULL handle used with subsequent NX accesses
@@ -279,7 +357,8 @@ EXTERN int nx_eventhandler(NXHANDLE handle);
*
****************************************************************************/
-EXTERN NXWINDOW nx_openwindow(NXHANDLE handle);
+EXTERN NXWINDOW nx_openwindow(NXHANDLE handle,
+ FAR const struct nx_callback_s *cb);
/****************************************************************************
* Name: nx_closewindow
@@ -333,6 +412,23 @@ EXTERN int nx_getposition(NXWINDOW hwnd);
EXTERN int nx_setposition(NXWINDOW hwnd, FAR struct nxgl_point_s *pos);
/****************************************************************************
+ * Name: nx_setsize
+ *
+ * Description:
+ * Set the size of the selected window
+ *
+ * Input Parameters:
+ * hwnd - The window handle
+ * size - The new size of the window.
+ *
+ * Return:
+ * OK on success; ERROR on failure with errno set appropriately
+ *
+ ****************************************************************************/
+
+EXTERN int nx_setsize(NXWINDOW hwnd, FAR struct nxgl_rect_s *size);
+
+/****************************************************************************
* Name: nx_raise
*
* Description:
@@ -380,7 +476,7 @@ EXTERN int nx_lower(NXWINDOW hwnd);
*
****************************************************************************/
-EXTERN int nx_fill(NXWINDOW hwnd, FAR struct nxgl_rect_s *rect,
+EXTERN int nx_fill(NXWINDOW hwnd, FAR const struct nxgl_rect_s *rect,
nxgl_mxpixel_t color[CONFIG_NX_NPLANES]);
/****************************************************************************
diff --git a/nuttx/include/nuttx/nxglib.h b/nuttx/include/nuttx/nxglib.h
index 47471a5f8..18284a2d4 100644
--- a/nuttx/include/nuttx/nxglib.h
+++ b/nuttx/include/nuttx/nxglib.h
@@ -446,6 +446,18 @@ EXTERN void nxgl_trapoffset(FAR struct nxgl_trapezoid_s *dest,
EXTERN void nxgl_trapcopy(FAR struct nxgl_trapezoid_s *dest,
FAR const struct nxgl_trapezoid_s *src);
+/****************************************************************************
+ * Name: nxgl_colorcopy
+ *
+ * Description:
+ * 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.
+ *
+ ****************************************************************************/
+
+EXTERN void nxgl_colorcopy(nxgl_mxpixel_t dest[CONFIG_NX_NPLANES],
+ const nxgl_mxpixel_t src[CONFIG_NX_NPLANES]);
#undef EXTERN
#if defined(__cplusplus)
}