Changes from initial NX debug

git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@1341 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
patacongo
2008-11-28 23:04:54 +00:00
parent ac8a252e30
commit 63101c7916
32 changed files with 584 additions and 252 deletions
+2
View File
@@ -589,3 +589,5 @@
* Added some rasterizers to the graphics library * Added some rasterizers to the graphics library
0.3.20 2008-xx-xx Gregory Nutt <spudmonkey@racsa.co.cr> 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)
+2 -1
View File
@@ -8,7 +8,7 @@
<tr align="center" bgcolor="#e4e4e4"> <tr align="center" bgcolor="#e4e4e4">
<td> <td>
<h1><big><font color="#3c34ec"><i>NuttX RTOS</i></font></big></h1> <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> </td>
</tr> </tr>
</table> </table>
@@ -1205,6 +1205,7 @@ buildroot-0.1.2 2007-11-06 &lt;spudmonkey@racsa.co.cr&gt
<pre><ul> <pre><ul>
nuttx-0.3.20 2008-xx-xx Gregory Nutt &lt;spudmonkey@racsa.co.cr&gt; 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; pascal-0.1.3 2008-xx-xx Gregory Nutt &lt;spudmonkey@racsa.co.cr&gt;
+9 -1
View File
@@ -58,7 +58,15 @@
#endif #endif
#ifndef CONFIG_EXAMPLES_NX_BGCOLOR #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 #endif
/* Debug ********************************************************************/ /* Debug ********************************************************************/
+273 -50
View File
@@ -41,6 +41,7 @@
#include <sys/types.h> #include <sys/types.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h>
#include <unistd.h> #include <unistd.h>
#include <sched.h> #include <sched.h>
#include <errno.h> #include <errno.h>
@@ -59,90 +60,188 @@
* Private Types * 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 * Private Function Prototypes
****************************************************************************/ ****************************************************************************/
static void my_redraw(NXWINDOW handle, FAR const struct nxgl_rect_s *rect, static void nxeg_redraw1(NXWINDOW hwnd, FAR const struct nxgl_rect_s *rect,
boolean more); boolean more);
static void my_position(NXWINDOW handle, FAR const struct nxgl_rect_s *size, static void nxeg_redraw2(NXWINDOW hwnd, FAR const struct nxgl_rect_s *rect,
FAR const struct nxgl_point_s *pos); 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 #ifdef CONFIG_NX_MOUSE
static void my_mousein(NXWINDOW handle, FAR const struct nxgl_point_s *pos, static void nxeg_mousein1(NXWINDOW hwnd, FAR const struct nxgl_point_s *pos,
ubyte buttons); ubyte buttons);
static void nxeg_mousein2(NXWINDOW hwnd, FAR const struct nxgl_point_s *pos,
ubyte buttons);
#endif #endif
#ifdef CONFIG_NX_KBD #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 #endif
/**************************************************************************** /****************************************************************************
* Private Data * Private Data
****************************************************************************/ ****************************************************************************/
static const struct nx_callback_s g_nxcb = static const struct nx_callback_s g_nxcb1 =
{ {
my_redraw, /* redraw */ nxeg_redraw1, /* redraw */
my_position /* position */ nxeg_position1 /* position */
#ifdef CONFIG_NX_MOUSE #ifdef CONFIG_NX_MOUSE
, my_mousein /* mousein */ , nxeg_mousein1 /* mousein */
#endif #endif
#ifdef CONFIG_NX_KBD #ifdef CONFIG_NX_KBD
, my_kbdin /* my kbdin */ , nxeg_kbdin1 /* my kbdin */
#endif #endif
}; };
static const struct nx_callback_s g_nxcb2 =
{
nxeg_redraw2, /* redraw */
nxeg_position2 /* position */
#ifdef CONFIG_NX_MOUSE
, nxeg_mousein2 /* mousein */
#endif
#ifdef CONFIG_NX_KBD
, 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 * Private Functions
****************************************************************************/ ****************************************************************************/
/**************************************************************************** /****************************************************************************
* Name: my_redraw * Name: nxeg_redraw1
****************************************************************************/ ****************************************************************************/
static void my_redraw(NXWINDOW hwnd, FAR const struct nxgl_rect_s *rect, static void nxeg_redraw1(NXWINDOW hwnd, FAR const struct nxgl_rect_s *rect,
boolean more) 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, hwnd,
rect->pt1.x, rect->pt1.y, rect->pt2.x, rect->pt2.y, rect->pt1.x, rect->pt1.y, rect->pt2.x, rect->pt2.y,
more ? "TRUE" : "FALSE"); 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, static void nxeg_redraw2(NXWINDOW hwnd, FAR const struct nxgl_rect_s *rect,
FAR const struct nxgl_point_s *pos) 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, hwnd,
size->pt1.x, size->pt1.y, size->pt2.x, size->pt2.y, rect->pt1.x, rect->pt1.y, rect->pt2.x, rect->pt2.y,
pos->x, pos->y); more ? "TRUE" : "FALSE");
nx_fill(hwnd, rect, g_color2);
} }
/**************************************************************************** /****************************************************************************
* Name: my_mousein * 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,
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_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 #ifdef CONFIG_NX_MOUSE
static void my_mousein(NXWINDOW hwnd, FAR const struct nxgl_point_s *pos, static void nxeg_mousein1(NXWINDOW hwnd, FAR const struct nxgl_point_s *pos,
ubyte buttons) ubyte buttons)
{ {
message("my_mousein: hwnd=%p pos=(%d,%d) button=%02x\n", message("nxeg_mousein1: hwnd=%p pos=(%d,%d) button=%02x\n",
hwnd, pos->x, pos->y, buttons); hwnd, pos->x, pos->y, buttons);
} }
#endif #endif
/**************************************************************************** /****************************************************************************
* Name: * Name: nxeg_mousein2
****************************************************************************/
#ifdef CONFIG_NX_MOUSE
static void nxeg_mousein2(NXWINDOW hwnd, FAR const struct nxgl_point_s *pos,
ubyte buttons)
{
message("nxeg_mousein2: hwnd=%p pos=(%d,%d) button=%02x\n",
hwnd, pos->x, pos->y, buttons);
}
#endif
/****************************************************************************
* Name: nxeg_kbdinfo
****************************************************************************/ ****************************************************************************/
#ifdef CONFIG_NX_KBD #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; int i;
message("my_kbdin: hwnd=%p nch=%d\n", hwnd, nch);
for (i = 0; i < nch; i++) for (i = 0; i < nch; i++)
{ {
if (isprint(ch[i])) if (isprint(ch[i]))
@@ -157,6 +256,30 @@ static void my_kbdin(NXWINDOW hwnd, ubyte nch, const ubyte *ch)
} }
#endif #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 * Public Functions
****************************************************************************/ ****************************************************************************/
@@ -176,25 +299,37 @@ void user_initialize(void)
int user_start(int argc, char *argv[]) int user_start(int argc, char *argv[])
{ {
NXHANDLE hnx; NXHANDLE hnx;
NXWINDOW hwnd; NXWINDOW hwnd1;
NXWINDOW hwnd2;
#ifndef CONFIG_NX_MULTIUSER #ifndef CONFIG_NX_MULTIUSER
FAR struct fb_vtable_s *fb; FAR struct fb_vtable_s *fb;
#else #else
pid_t servrid; pid_t servrid;
#endif #endif
struct nxgl_rect_s rect;
struct nxgl_point_s pt;
nxgl_mxpixel_t color; nxgl_mxpixel_t color;
int exitcode = 0; int exitcode = NXEXIT_SUCCESS;
int ret; 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 #ifdef CONFIG_NX_MULTIUSER
/* Start the server task */ /* Start the server task */
message("user_start: Starting nx_servertask task\n"); 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) if (servrid < 0)
{ {
message("user_start: Failed to create nx_servertask task: %d\n", errno); message("user_start: Failed to create nx_servertask task: %d\n", errno);
exitcode = 1; exitcode = NXEXIT_TASKCREATE;
goto errout; goto errout;
} }
@@ -204,7 +339,7 @@ int user_start(int argc, char *argv[])
/* Connect to the server */ /* Connect to the server */
hnx = nx_connect(&g_nxcb); hnx = nx_connect();
#else #else
/* Initialize the frame buffer device */ /* Initialize the frame buffer device */
@@ -213,7 +348,7 @@ int user_start(int argc, char *argv[])
if (ret < 0) if (ret < 0)
{ {
message("user_start: up_fbinitialize failed: %d\n", -ret); message("user_start: up_fbinitialize failed: %d\n", -ret);
exitcode = 2; exitcode = NXEXIT_FBINITIALIZE;
goto errout; goto errout;
} }
@@ -221,21 +356,21 @@ int user_start(int argc, char *argv[])
if (!fb) if (!fb)
{ {
message("user_start: up_fbgetvplane failed, vplane=%d\n", CONFIG_EXAMPLES_NX_VPLANE); message("user_start: up_fbgetvplane failed, vplane=%d\n", CONFIG_EXAMPLES_NX_VPLANE);
exitcode = 3; exitcode = NXEXIT_FBGETVPLANE;
goto errout; goto errout;
} }
/* Then open NX */ /* Then open NX */
message("user_start: Open NX\n"); message("user_start: Open NX\n");
hnx = nx_open(fb, &g_nxcb); hnx = nx_open(fb);
#endif #endif
message("user_start: NX handle=%p\n", hnx); message("user_start: NX handle=%p\n", hnx);
if (!hnx) if (!hnx)
{ {
message("user_start: Failed to get NX handle: %d\n", errno); message("user_start: Failed to get NX handle: %d\n", errno);
exitcode = 4; exitcode = NXEXIT_NXOPEN;
goto errout; goto errout;
} }
@@ -247,32 +382,120 @@ int user_start(int argc, char *argv[])
if (ret < 0) if (ret < 0)
{ {
message("user_start: nx_setbgcolor failed: %d\n", errno); message("user_start: nx_setbgcolor failed: %d\n", errno);
exitcode = 5; exitcode = NXEXIT_NXSETBGCOLOR;
goto errout_with_nx; goto errout_with_nx;
} }
/* Create a window */ /* Create window #1 */
message("user_start: Create a window\n"); message("user_start: Create window #1\n");
hwnd = nx_openwindow(hnx); hwnd1 = nx_openwindow(hnx, &g_nxcb1);
message("user_start: NX window=%p\n", hwnd); message("user_start: hwnd1=%p\n", hwnd1);
if (!hwnd) if (!hwnd1)
{ {
message("user_start: nx_openwindow failed: %d\n", errno); message("user_start: nx_openwindow failed: %d\n", errno);
exitcode = 6; exitcode = NXEXIT_NXOPENWINDOW;
goto errout_with_nx; goto errout_with_nx;
} }
message("user_start: Screen resolution (%d,%d)\n", g_xres, g_yres);
/* Close the window */ /* Set the size of the window 2 */
//errout_with_window: rect.pt1.x = 0;
rect.pt1.y = 0;
rect.pt2.x = g_xres/2;
rect.pt2.y = g_yres/2;
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"); message("user_start: Close window\n");
ret = nx_closewindow(hwnd); ret = nx_closewindow(hwnd2);
if (!hwnd) if (ret < 0)
{ {
message("user_start: nx_openwindow failed: %d\n", errno); message("user_start: nx_openwindow failed: %d\n", errno);
exitcode = 7; 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 = NXEXIT_NXCLOSEWINDOW;
goto errout_with_nx; goto errout_with_nx;
} }
+2 -1
View File
@@ -45,6 +45,7 @@
#include <unistd.h> #include <unistd.h>
#include <sched.h> #include <sched.h>
#include <errno.h> #include <errno.h>
#include <debug.h>
#include <nuttx/arch.h> #include <nuttx/arch.h>
#include <nuttx/nx.h> #include <nuttx/nx.h>
@@ -91,7 +92,7 @@ int nx_servertask(int argc, char *argv[])
return 1; return 1;
} }
fb = up_fbgetvplane(CONFIG_EXAMPLES_NX_VPLANE) fb = up_fbgetvplane(CONFIG_EXAMPLES_NX_VPLANE);
if (!fb) if (!fb)
{ {
message("nx_serverthread: up_fbgetvplane failed, vplane=%d\n", CONFIG_EXAMPLES_NX_VPLANE); message("nx_serverthread: up_fbgetvplane failed, vplane=%d\n", CONFIG_EXAMPLES_NX_VPLANE);
+14 -6
View File
@@ -125,21 +125,22 @@ struct nxbe_window_s
{ {
/* State information */ /* 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 #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 #endif
FAR const struct nx_callback_s *cb; /* Event handling callbacks */
/* The following links provide the window's vertical position using a /* The following links provide the window's vertical position using a
* singly linked list. * singly linked list.
*/ */
FAR struct nxbe_window_s *above; /* The window "above" this window */ 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 *below; /* The window "below this one */
struct nxgl_rect_s bounds; /* The bounding rectangle of 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 */ struct nxgl_point_s origin; /* The position of the top-left corner of the window */
}; };
/* Back-end state ***********************************************************/ /* 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 */ 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 */ 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 /* vinfo describes the video controller and plane[n].pinfo describes color
* plane 'n' supported by the video controller. Most common color models * plane 'n' supported by the video controller. Most common color models
* fit in one plane, but this array provides future support for hardware * fit in one plane, but this array provides future support for hardware
+2 -1
View File
@@ -56,8 +56,9 @@ RECT_CSRCS = nxglib_rectcopy.c nxglib_rectoffset.c nxglib_vectoradd.c \
nxglib_rectoverlap.c nxglib_nullrect.c nxglib_rectoverlap.c nxglib_nullrect.c
TRAP_CSRCS = nxglib_runoffset.c nxglib_runcopy.c \ TRAP_CSRCS = nxglib_runoffset.c nxglib_runcopy.c \
nxglib_trapoffset.c nxglib_trapcopy.c nxglib_trapoffset.c nxglib_trapcopy.c
COLOR_CSRCS = nxglib_colorcopy.c
NXGLIB_CSRCS = nxglib_rgb2yuv.c nxglib_yuv2rgb.c \ NXGLIB_CSRCS = nxglib_rgb2yuv.c nxglib_yuv2rgb.c \
$(RFILL1_CSRCS) $(RFILL2_CSRCS) $(TFILL1_CSRCS) $(TFILL2_CSRCS) \ $(RFILL1_CSRCS) $(RFILL2_CSRCS) $(TFILL1_CSRCS) $(TFILL2_CSRCS) \
$(RMOVE1_CSRCS) $(RMOVE2_CSRCS) $(RCOPY1_CSRCS) $(RCOPY2_CSRCS) \ $(RMOVE1_CSRCS) $(RMOVE2_CSRCS) $(RCOPY1_CSRCS) $(RCOPY2_CSRCS) \
$(RECT_CSRCS) $(TRAP_CSRCS) $(RECT_CSRCS) $(TRAP_CSRCS) $(COLOR_CSRCS)
@@ -1,5 +1,5 @@
/**************************************************************************** /****************************************************************************
* graphics/nxmu/nxmu__mouse.c * graphics/nxglib/nxsglib_colorcopy.c
* *
* Copyright (C) 2008 Gregory Nutt. All rights reserved. * Copyright (C) 2008 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr> * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
@@ -40,13 +40,8 @@
#include <nuttx/config.h> #include <nuttx/config.h>
#include <sys/types.h> #include <sys/types.h>
#include <errno.h> #include <nuttx/fb.h>
#include <debug.h> #include <nuttx/nxglib.h>
#include <nuttx/nx.h>
#include "nxfe.h"
#ifdef CONFIG_NX_MOUSE
/**************************************************************************** /****************************************************************************
* Pre-Processor Definitions * Pre-Processor Definitions
@@ -60,10 +55,6 @@
* Private Data * Private Data
****************************************************************************/ ****************************************************************************/
static struct nxgl_point_s g_mpos;
static struct nxgl_rect_s g_mrange;
static struct g_mbutton;
/**************************************************************************** /****************************************************************************
* Public Data * Public Data
****************************************************************************/ ****************************************************************************/
@@ -77,102 +68,22 @@ static struct g_mbutton;
****************************************************************************/ ****************************************************************************/
/**************************************************************************** /****************************************************************************
* Name: nxmu_mouseinit * Name: nxgl_colorcopy
* *
* Description: * 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; int i;
g_mrange.y = y;
g_mpos.x = x / 2;
g_mpos.y = y / 2;
g_mbutton = 0;
}
/**************************************************************************** for (i = 0; i < CONFIG_NX_NPLANES; 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)
{ {
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 */
+5 -4
View File
@@ -34,10 +34,11 @@
############################################################################ ############################################################################
NX_ASRCS = NX_ASRCS =
NXAPI_CSRCS = nx_bitmap.c nx_connect.c nx_disconnect.c nx_eventhandler.c \ NXAPI_CSRCS = nx_bitmap.c nx_closewindow.c nx_connect.c nx_disconnect.c \
nx_fill.c nx_filltrapezoid.c nx_getposition.c nx_kbdchin.c \ nx_eventhandler.c nx_fill.c nx_filltrapezoid.c \
nx_kbdin.c nx_lower.c nx_mousein.c nx_move.c nx_openwindow.c \ nx_getposition.c nx_kbdchin.c nx_kbdin.c nx_lower.c \
nx_raise.c nx_setsize.c nx_setbgcolor.c nx_setposition.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_CSRCS = nxmu_server.c nxmu_openwindow.c nxmu_reportposition.c nxmu_kbdin.c \
nxmu_mouse.c nxmu_redrawreq.c nxmu_semtake.c nxmu_mouse.c nxmu_redrawreq.c nxmu_semtake.c
NX_CSRCS = $(NXAPI_CSRCS) $(NXMU_CSRCS) NX_CSRCS = $(NXAPI_CSRCS) $(NXMU_CSRCS)
+1
View File
@@ -89,6 +89,7 @@
int nx_closewindow(NXWINDOW hwnd) int nx_closewindow(NXWINDOW hwnd)
{ {
FAR struct nxbe_window_s *wnd = (FAR struct nxbe_window_s *)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; struct nxsvrmsg_closewindow_s outmsg;
int ret; int ret;
+2 -8
View File
@@ -99,7 +99,6 @@ static uint32 g_nxcid = 1;
* *
* Input Parameters: * Input Parameters:
* svrmqname - The name for the server incoming message queue * svrmqname - The name for the server incoming message queue
* cb - Callbacks used to process received NX server messages
* *
* Return: * Return:
* Success: A non-NULL handle used with subsequent NX accesses * 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, NXHANDLE nx_connectionstance(FAR const char *svrmqname)
FAR const struct nx_callback_s *cb)
{ {
FAR struct nxfe_conn_s *conn; FAR struct nxfe_conn_s *conn;
struct nxsvrmsg_s msg; struct nxsvrmsg_s msg;
@@ -119,7 +117,7 @@ NXHANDLE nx_connectionstance(FAR const char *svrmqname,
/* Sanity checking */ /* Sanity checking */
#ifdef CONFIG_DEBUG #ifdef CONFIG_DEBUG
if (!svrmqname || !cb) if (!svrmqname)
{ {
errno = EINVAL; errno = EINVAL;
return NULL; return NULL;
@@ -135,10 +133,6 @@ NXHANDLE nx_connectionstance(FAR const char *svrmqname,
goto errout; goto errout;
} }
/* Save the callback vtable */
conn->cb = cb;
/* Create the client MQ name */ /* Create the client MQ name */
nxmu_semtake(&g_nxlibsem); nxmu_semtake(&g_nxlibsem);
+14 -5
View File
@@ -128,6 +128,7 @@ int nx_eventhandler(NXHANDLE handle)
{ {
FAR struct nxfe_conn_s *conn = (FAR struct nxfe_conn_s *)handle; FAR struct nxfe_conn_s *conn = (FAR struct nxfe_conn_s *)handle;
struct nxsvrmsg_s *msg; struct nxsvrmsg_s *msg;
struct nxbe_window_s *wnd;
ubyte buffer[NX_MXCLIMSGLEN]; ubyte buffer[NX_MXCLIMSGLEN];
int nbytes; int nbytes;
@@ -182,7 +183,9 @@ int nx_eventhandler(NXHANDLE handle)
if (conn->cb->redraw) if (conn->cb->redraw)
{ {
FAR struct nxclimsg_redraw_s *redraw = (FAR struct nxclimsg_redraw_s *)buffer; 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; break;
@@ -190,7 +193,9 @@ int nx_eventhandler(NXHANDLE handle)
if (conn->cb->position) if (conn->cb->position)
{ {
FAR struct nxclimsg_newposition_s *postn = (FAR struct nxclimsg_newposition_s *)buffer; 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; break;
@@ -199,7 +204,9 @@ int nx_eventhandler(NXHANDLE handle)
if (conn->cb->mousein) if (conn->cb->mousein)
{ {
FAR struct nxclimsg_mousein_s *mouse = (FAR struct nxclimsg_mousein_s *)buffer; 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; break;
#endif #endif
@@ -209,13 +216,15 @@ int nx_eventhandler(NXHANDLE handle)
if (conn->cb->kbdin) if (conn->cb->kbdin)
{ {
FAR struct nxclimsg_kbdin_s *kbd = (FAR struct nxclimsg_kbdin_s *)buffer; 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; break;
#endif #endif
default: 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; break;
} }
+3 -7
View File
@@ -44,6 +44,7 @@
#include <errno.h> #include <errno.h>
#include <debug.h> #include <debug.h>
#include <nuttx/nxglib.h>
#include <nuttx/nx.h> #include <nuttx/nx.h>
#include "nxfe.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]) nxgl_mxpixel_t color[CONFIG_NX_NPLANES])
{ {
FAR struct nxbe_window_s *wnd = (FAR struct nxbe_window_s *)hwnd; FAR struct nxbe_window_s *wnd = (FAR struct nxbe_window_s *)hwnd;
struct nxsvrmsg_fill_s outmsg; struct nxsvrmsg_fill_s outmsg;
int ret; int ret;
int i;
#ifdef CONFIG_DEBUG #ifdef CONFIG_DEBUG
if (!wnd || !wnd->conn || !rect || !color) if (!wnd || !wnd->conn || !rect || !color)
@@ -110,11 +110,7 @@ int nx_fill(NXWINDOW hwnd, FAR struct nxgl_rect_s *rect,
outmsg.wnd = wnd; outmsg.wnd = wnd;
nxgl_rectcopy(&outmsg.rect, rect); nxgl_rectcopy(&outmsg.rect, rect);
nxgl_colorcopy(outmsg.color, color);
for (i = 0; i < CONFIG_NX_NPLANES; i++)
{
outmsg.color[i] = color[i];
}
/* Forward the fill command to the server */ /* Forward the fill command to the server */
+11 -2
View File
@@ -79,7 +79,7 @@
* *
* Input Parameters: * Input Parameters:
* handle - The handle returned by nx_connect * 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: * Return:
* Success: A non-NULL handle used with subsequent NX accesses * 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 nxfe_conn_s *conn = (FAR struct nxfe_conn_s *)handle;
FAR struct nxbe_window_s *wnd; FAR struct nxbe_window_s *wnd;
struct nxsvrmsg_openwindow_s outmsg; struct nxsvrmsg_openwindow_s outmsg;
int ret; int ret;
#ifdef CONFIG_DEBUG
if (!conn || !cb)
{
errno = EINVAL;
return NULL;
}
#endif
/* Pre-allocate the window structure */ /* Pre-allocate the window structure */
wnd = (FAR struct nxbe_window_s *)zalloc(sizeof(struct nxbe_window_s)); 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.msgid = NX_SVRMSG_OPENWINDOW;
outmsg.conn = conn; outmsg.conn = conn;
outmsg.wnd = wnd; outmsg.wnd = wnd;
outmsg.cb = cb;
ret = mq_send(conn->cwrmq, &outmsg, sizeof(struct nxsvrmsg_openwindow_s), NX_SVRMSG_PRIO); ret = mq_send(conn->cwrmq, &outmsg, sizeof(struct nxsvrmsg_openwindow_s), NX_SVRMSG_PRIO);
if (ret < 0) if (ret < 0)
+2 -7
View File
@@ -91,7 +91,6 @@ int nx_setbgcolor(NXHANDLE handle,
FAR struct nxfe_conn_s *conn = (FAR struct nxfe_conn_s *)handle; FAR struct nxfe_conn_s *conn = (FAR struct nxfe_conn_s *)handle;
struct nxsvrmsg_setbgcolor_s outmsg; struct nxsvrmsg_setbgcolor_s outmsg;
int ret; int ret;
int i;
#ifdef CONFIG_DEBUG #ifdef CONFIG_DEBUG
if (!conn) if (!conn)
@@ -103,12 +102,8 @@ int nx_setbgcolor(NXHANDLE handle,
/* Format the fill command */ /* Format the fill command */
outmsg.msgid = NX_SVRMSG_SETBGCOLOR; outmsg.msgid = NX_SVRMSG_SETBGCOLOR;
nxgl_colorcopy(outmsg.color, color);
for (i = 0; i < CONFIG_NX_NPLANES; i++)
{
outmsg.color[i] = color[i];
}
/* Forward the fill command to the server */ /* Forward the fill command to the server */
+8 -1
View File
@@ -57,6 +57,10 @@
/* Configuration ************************************************************/ /* Configuration ************************************************************/
#ifdef CONFIG_DISABLE_MQUEUE
# error "Message queues are disabled(CONFIG_DISABLE_MQUEUE)"
#endif
#ifndef CONFIG_NX_MXSERVERMSGS #ifndef CONFIG_NX_MXSERVERMSGS
# define CONFIG_NX_MXSERVERMSGS 32 /* Number of pending messages in server MQ */ # define CONFIG_NX_MXSERVERMSGS 32 /* Number of pending messages in server MQ */
#endif #endif
@@ -203,6 +207,7 @@ struct nxclimsg_newposition_s
FAR struct nxbe_window_s *wnd; /* The window whose position/size has changed */ 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_rect_s size; /* The current window size */
FAR struct nxgl_point_s pos; /* The current window position */ 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 */ /* This message reports a new mouse event to a particular window */
@@ -249,6 +254,7 @@ struct nxsvrmsg_openwindow_s
uint32 msgid; /* NX_SVRMSG_OPENWINDOW */ uint32 msgid; /* NX_SVRMSG_OPENWINDOW */
FAR struct nxfe_conn_s *conn; /* The specific connection sending the message */ FAR struct nxfe_conn_s *conn; /* The specific connection sending the message */
FAR struct nxbe_window_s *wnd; /* The pre-allocated window structure */ 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 */ /* 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, EXTERN void nxmu_openwindow(FAR struct nxfe_conn_s *conn,
FAR struct nxbe_state_s *be, 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 * Name: nxfe_reportposition
+6 -3
View File
@@ -77,15 +77,17 @@
* conn - The client containing connection information [IN] * conn - The client containing connection information [IN]
* be - The server state structure [IN] * be - The server state structure [IN]
* wnd - The pre-allocated window structure to be ininitilized [IN/OUT] * wnd - The pre-allocated window structure to be ininitilized [IN/OUT]
* cb - Callbacks used to process window events
* *
* Return: * Return:
* None * None
* *
****************************************************************************/ ****************************************************************************/
void nxsmu_openwindow(FAR struct nxfe_conn_s *conn, void nxmu_openwindow(FAR struct nxfe_conn_s *conn,
FAR struct nxbe_state_s *be, 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)
{ {
/* The window structure was allocated in nx_openwindow and all fields have /* 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 * 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->be = be;
wnd->conn = conn; wnd->conn = conn;
wnd->cb = cb;
/* Now, insert the new window at the top on the display. topwind is /* Now, insert the new window at the top on the display. topwind is
* never NULL (it may point only at the background window, however) * never NULL (it may point only at the background window, however)
+8 -1
View File
@@ -43,6 +43,7 @@
#include <errno.h> #include <errno.h>
#include <debug.h> #include <debug.h>
#include <nuttx/nxglib.h>
#include <nuttx/nx.h> #include <nuttx/nx.h>
#include "nxfe.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.x = wnd->origin.x;
outmsg.pos.y = wnd->origin.y; 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); 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 */ /* And provide this to the client */
ret = mq_send(wnd->conn->swrmq, &outmsg, sizeof(struct nxclimsg_newposition_s), NX_SVRMSG_PRIO); ret = mq_send(wnd->conn->swrmq, &outmsg, sizeof(struct nxclimsg_newposition_s), NX_SVRMSG_PRIO);
+11 -3
View File
@@ -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 */ case NX_SVRMSG_OPENWINDOW: /* Create a new window */
{ {
FAR struct nxsvrmsg_openwindow_s *openmsg = (FAR struct nxsvrmsg_openwindow_s *)buffer; 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; 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 */ case NX_SVRMSG_SETBGCOLOR: /* Set the color of the background */
{ {
FAR struct nxsvrmsg_setbgcolor_s *bgcolormsg = (FAR struct nxsvrmsg_setbgcolor_s *)buffer; 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); nxbe_fill(&fe.be.bkgd, &fe.be.bkgd.bounds, bgcolormsg->color);
} }
break; break;
@@ -478,8 +479,15 @@ int nx_runinstance(FAR const char *mqname, FAR struct fb_vtable_s *fb)
/* Messages sent to the backgound window ***************************/ /* Messages sent to the backgound window ***************************/
case NX_CLIMSG_REDRAW: /* Re-draw the background 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_MOUSEIN: /* Ignored */
case NX_CLIMSG_KBDIN: case NX_CLIMSG_KBDIN:
+1 -1
View File
@@ -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_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_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 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) NX_CSRCS = $(NXAPI_CSRCS) $(NXSU_CSRCS)
+1 -1
View File
@@ -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]) nxgl_mxpixel_t color[CONFIG_NX_NPLANES])
{ {
#ifdef CONFIG_DEBUG #ifdef CONFIG_DEBUG
+5 -3
View File
@@ -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 nxfe_state_s *fe = (FAR struct nxfe_state_s *)handle;
FAR struct nxbe_window_s *wnd = fe->be.topwnd; 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);
} }
} }
+5 -3
View File
@@ -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 nxfe_state_s *fe = (FAR struct nxfe_state_s *)handle;
FAR struct nxbe_window_s *wnd = fe->be.topwnd; 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);
} }
} }
+2 -2
View File
@@ -105,9 +105,9 @@ void nxsu_mousereport(struct nxbe_window_s *wnd)
{ {
/* Give the keypad event only to the top child */ /* 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);
} }
} }
+41 -8
View File
@@ -56,10 +56,28 @@
* Private Types * Private Types
****************************************************************************/ ****************************************************************************/
/****************************************************************************
* Private Function Prototypes
****************************************************************************/
static void nxsu_bkgdredraw(NXWINDOW hwnd,
FAR const struct nxgl_rect_s *rect, boolean more);
/**************************************************************************** /****************************************************************************
* Private Data * 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 * Public Data
****************************************************************************/ ****************************************************************************/
@@ -68,6 +86,21 @@
* Private Functions * Private Functions
****************************************************************************/ ****************************************************************************/
/****************************************************************************
* 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 * Name: nxsu_setup
****************************************************************************/ ****************************************************************************/
@@ -97,9 +130,11 @@ static inline int nxsu_setup(FAR struct fb_vtable_s *fb,
} }
#endif #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.be = &fe->be;
fe->be.bkgd.cb = &g_bkgdcb;
fe->be.bkgd.bounds.pt2.x = fe->be.vinfo.xres; fe->be.bkgd.bounds.pt2.x = fe->be.vinfo.xres;
fe->be.bkgd.bounds.pt2.y = fe->be.vinfo.yres; 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: * Input Parameters:
* fb - Vtable "object" of the framebuffer "driver" to use * fb - Vtable "object" of the framebuffer "driver" to use
* cb - Callbacks used to process received NX server messages
* *
* Return: * Return:
* Success: A non-NULL handle used with subsequent NX accesses * 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; FAR struct nxfe_state_s *fe;
int ret; int ret;
@@ -149,7 +183,7 @@ NXHANDLE nx_open(FAR struct fb_vtable_s *fb, FAR const struct nx_callback_s *cb)
/* Sanity checking */ /* Sanity checking */
#ifdef CONFIG_DEBUG #ifdef CONFIG_DEBUG
if (!cb) if (!fb)
{ {
errno = EINVAL; errno = EINVAL;
return NULL; return NULL;
@@ -165,10 +199,6 @@ NXHANDLE nx_open(FAR struct fb_vtable_s *fb, FAR const struct nx_callback_s *cb)
return NULL; return NULL;
} }
/* Save the callback vtable */
fe->cb = cb;
/* Initialize and configure the server */ /* Initialize and configure the server */
ret = nxsu_setup(fb, fe); 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 */ 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; return (NXHANDLE)fe;
} }
+8 -3
View File
@@ -79,7 +79,7 @@
* *
* Input Parameters: * Input Parameters:
* handle - The handle returned by nx_connect * 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: * Return:
* Success: A non-NULL handle used with subsequent NX accesses * 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 nxfe_state_s *fe = (FAR struct nxfe_state_s *)handle;
FAR struct nxbe_state_s *be = &fe->be; FAR struct nxbe_state_s *be = &fe->be;
FAR struct nxbe_window_s *wnd; FAR struct nxbe_window_s *wnd;
#ifdef CONFIG_DEBUG #ifdef CONFIG_DEBUG
if (!fe) if (!fe || !cb)
{ {
errno = EINVAL; errno = EINVAL;
return NULL; return NULL;
@@ -113,6 +113,7 @@ NXWINDOW nx_openwindow(NXHANDLE handle)
/* Initialize the window structure */ /* Initialize the window structure */
wnd->be = be; wnd->be = be;
wnd->cb = cb;
/* Insert the new window at the top on the display. topwind is /* Insert the new window at the top on the display. topwind is
* never NULL (it may point only at the background window, however) * 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->above = wnd;
be->topwnd = wnd; be->topwnd = wnd;
/* Report the initialize size/position of the window */
nxfe_reportposition((NXWINDOW)wnd);
/* Provide the initial mouse settings */ /* Provide the initial mouse settings */
#ifdef CONFIG_NX_MOUSE #ifdef CONFIG_NX_MOUSE
+1
View File
@@ -98,6 +98,7 @@ int nx_setbgcolor(NXHANDLE handle,
} }
#endif #endif
nxgl_colorcopy(fe->be.bgcolor, color);
nxbe_fill(&fe->be.bkgd, &fe->be.bkgd.bounds, color); nxbe_fill(&fe->be.bkgd, &fe->be.bkgd.bounds, color);
return OK; return OK;
} }
+4 -5
View File
@@ -61,7 +61,10 @@
/* Server state structure ***************************************************/ /* 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 struct nxfe_state_s
{ {
@@ -71,10 +74,6 @@ struct nxfe_state_s
*/ */
struct nxbe_state_s be; struct nxbe_state_s be;
/* Event handling callbacks */
FAR const struct nx_callback_s *cb; /* Message handling callbacks */
}; };
/**************************************************************************** /****************************************************************************
+4 -6
View File
@@ -80,18 +80,16 @@
void nxfe_redrawreq(FAR struct nxbe_window_s *wnd, FAR const struct nxgl_rect_s *rect) void nxfe_redrawreq(FAR struct nxbe_window_s *wnd, FAR const struct nxgl_rect_s *rect)
{ {
FAR struct nxbe_state_s *be = wnd->be; struct nxgl_rect_s relrect;
FAR struct nxfe_state_s *fe = (FAR struct nxfe_state_s *)be;
struct nxgl_rect_s relrect;
#ifdef CONFIG_DEBUG #ifdef CONFIG_DEBUG
if (wnd) if (!wnd)
{ {
return; return;
} }
#endif #endif
if (fe->cb->redraw) if (wnd->cb->redraw)
{ {
/* Convert the frame rectangle to a window-relative rectangle */ /* 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 */ /* And request the redraw */
fe->cb->redraw((NXWINDOW)wnd, &relrect, FALSE); wnd->cb->redraw((NXWINDOW)wnd, &relrect, FALSE);
} }
} }
+4 -5
View File
@@ -80,8 +80,7 @@
void nxfe_reportposition(FAR struct nxbe_window_s *wnd) void nxfe_reportposition(FAR struct nxbe_window_s *wnd)
{ {
FAR struct nxbe_state_s *be = wnd->be; FAR struct nxbe_state_s *be = wnd->be;
FAR struct nxfe_state_s *fe = (FAR struct nxfe_state_s *)be;
struct nxgl_rect_s rect; struct nxgl_rect_s rect;
#ifdef CONFIG_DEBUG #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. * 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 */ /* Convert the frame rectangle to a window-relative rectangle */
nxgl_rectoffset(&rect, &wnd->bounds, -wnd->origin.x, -wnd->origin.y); 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);
} }
} }
+109 -13
View File
@@ -53,6 +53,13 @@
#define NX_DEFAULT_SERVER_MQNAME "/dev/nxs" #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 * Public Types
****************************************************************************/ ****************************************************************************/
@@ -75,19 +82,93 @@ typedef FAR void *NXWINDOW;
/* NX server callbacks ******************************************************/ /* 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 * callbacks will be invoked as part of the processing performed by
* nx_message() * nx_eventhandler()
*/ */
struct nx_callback_s 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); 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, 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 #ifdef CONFIG_NX_MOUSE
void (*mousein)(NXWINDOW hwnd, FAR const struct nxgl_point_s *pos, ubyte buttons); void (*mousein)(NXWINDOW hwnd, FAR const struct nxgl_point_s *pos, ubyte buttons);
#endif #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 #ifdef CONFIG_NX_KBD
void (*kbdin)(NXWINDOW hwnd, ubyte nch, const ubyte *ch); void (*kbdin)(NXWINDOW hwnd, ubyte nch, const ubyte *ch);
#endif #endif
@@ -135,7 +216,7 @@ extern "C" {
#ifdef CONFIG_NX_MULTIUSER #ifdef CONFIG_NX_MULTIUSER
EXTERN int nx_runinstance(FAR const char *mqname, FAR struct fb_vtable_s *fb); 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 #endif
/**************************************************************************** /****************************************************************************
@@ -155,7 +236,6 @@ EXTERN int nx_runinstance(FAR const char *mqname, FAR struct fb_vtable_s *fb);
* *
* Input Parameters: * Input Parameters:
* svrmqname - The name for the server incoming message queue * svrmqname - The name for the server incoming message queue
* cb - Callbacks used to process received NX server messages
* *
* Return: * Return:
* Success: A non-NULL handle used with subsequent NX accesses * 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 #ifdef CONFIG_NX_MULTIUSER
EXTERN NXHANDLE nx_connectionstance(FAR const char *svrmqname, 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)
# define nx_connect(cb) nx_connectionstance(NX_DEFAULT_SERVER_MQNAME, cb)
#endif #endif
/**************************************************************************** /****************************************************************************
@@ -190,8 +269,7 @@ EXTERN NXHANDLE nx_connectionstance(FAR const char *svrmqname,
****************************************************************************/ ****************************************************************************/
#ifndef CONFIG_NX_MULTIUSER #ifndef CONFIG_NX_MULTIUSER
EXTERN NXHANDLE nx_open(FAR struct fb_vtable_s *fb, EXTERN NXHANDLE nx_open(FAR struct fb_vtable_s *fb);
FAR const struct nx_callback_s *cb);
#endif #endif
/**************************************************************************** /****************************************************************************
@@ -271,7 +349,7 @@ EXTERN int nx_eventhandler(NXHANDLE handle);
* *
* Input Parameters: * Input Parameters:
* handle - The handle returned by nx_connect * 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: * Return:
* Success: A non-NULL handle used with subsequent NX accesses * 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 * Name: nx_closewindow
@@ -332,6 +411,23 @@ EXTERN int nx_getposition(NXWINDOW hwnd);
EXTERN int nx_setposition(NXWINDOW hwnd, FAR struct nxgl_point_s *pos); 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 * Name: nx_raise
* *
@@ -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]); nxgl_mxpixel_t color[CONFIG_NX_NPLANES]);
/**************************************************************************** /****************************************************************************
+12
View File
@@ -446,6 +446,18 @@ EXTERN void nxgl_trapoffset(FAR struct nxgl_trapezoid_s *dest,
EXTERN void nxgl_trapcopy(FAR struct nxgl_trapezoid_s *dest, EXTERN void nxgl_trapcopy(FAR struct nxgl_trapezoid_s *dest,
FAR const struct nxgl_trapezoid_s *src); 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 #undef EXTERN
#if defined(__cplusplus) #if defined(__cplusplus)
} }