diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2008-11-28 23:04:54 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2008-11-28 23:04:54 +0000 |
commit | 62f15df2d7d7ad3a3bc4a93fbb6e94644f1e0f3f (patch) | |
tree | ecd94fbfa9e5e21f09aa4526ddaabaa93472a1b7 /nuttx/graphics/nxsu | |
parent | 783dea5150512780cfaba1048403caf757108f45 (diff) | |
download | px4-nuttx-62f15df2d7d7ad3a3bc4a93fbb6e94644f1e0f3f.tar.gz px4-nuttx-62f15df2d7d7ad3a3bc4a93fbb6e94644f1e0f3f.tar.bz2 px4-nuttx-62f15df2d7d7ad3a3bc4a93fbb6e94644f1e0f3f.zip |
Changes from initial NX debug
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@1341 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/graphics/nxsu')
-rw-r--r-- | nuttx/graphics/nxsu/Make.defs | 2 | ||||
-rw-r--r-- | nuttx/graphics/nxsu/nx_fill.c | 2 | ||||
-rw-r--r-- | nuttx/graphics/nxsu/nx_kbdchin.c | 8 | ||||
-rw-r--r-- | nuttx/graphics/nxsu/nx_kbdin.c | 8 | ||||
-rw-r--r-- | nuttx/graphics/nxsu/nx_mousein.c | 4 | ||||
-rw-r--r-- | nuttx/graphics/nxsu/nx_open.c | 49 | ||||
-rw-r--r-- | nuttx/graphics/nxsu/nx_openwindow.c | 11 | ||||
-rw-r--r-- | nuttx/graphics/nxsu/nx_setbgcolor.c | 1 | ||||
-rw-r--r-- | nuttx/graphics/nxsu/nxfe.h | 9 | ||||
-rw-r--r-- | nuttx/graphics/nxsu/nxsu_mouse.c | 178 | ||||
-rw-r--r-- | nuttx/graphics/nxsu/nxsu_redrawreq.c | 10 | ||||
-rw-r--r-- | nuttx/graphics/nxsu/nxsu_reportposition.c | 9 |
12 files changed, 76 insertions, 215 deletions
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_mouse.c b/nuttx/graphics/nxsu/nxsu_mouse.c deleted file mode 100644 index 5650c8dd2..000000000 --- a/nuttx/graphics/nxsu/nxsu_mouse.c +++ /dev/null @@ -1,178 +0,0 @@ -/**************************************************************************** - * graphics/nxmu/nxmu__mouse.c - * - * Copyright (C) 2008 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name NuttX nor the names of its contributors may be - * used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include <nuttx/config.h> - -#include <sys/types.h> -#include <errno.h> -#include <debug.h> - -#include <nuttx/nx.h> -#include "nxfe.h" - -#ifdef CONFIG_NX_MOUSE - -/**************************************************************************** - * Pre-Processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Types - ****************************************************************************/ - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -static struct nxgl_point_s g_mpos; -static struct nxgl_rect_s g_mrange; -static struct g_mbutton; - -/**************************************************************************** - * Public Data - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: nxmu_mouseinit - * - * Description: - * Initialize with the mouse in the center of the display - * - ****************************************************************************/ - -void nxmu_mouseinit(int x, int y) -{ - g_mrange.x = x; - g_mrange.y = y; - g_mpos.x = x / 2; - g_mpos.y = y / 2; - g_mbutton = 0; -} - -/**************************************************************************** - * 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); - } -} - -/**************************************************************************** - * 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/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); } } |