mirror of
https://github.com/apache/nuttx.git
synced 2025-01-13 08:38:38 +08:00
Add argument to window callbacks
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@1366 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
parent
558ffa59d1
commit
4f6ef2af8d
10 changed files with 104 additions and 48 deletions
|
@ -84,20 +84,22 @@ enum exitcode_e
|
|||
****************************************************************************/
|
||||
|
||||
static void nxeg_redraw1(NXWINDOW hwnd, FAR const struct nxgl_rect_s *rect,
|
||||
boolean more);
|
||||
boolean morem, FAR void *arg);
|
||||
static void nxeg_redraw2(NXWINDOW hwnd, FAR const struct nxgl_rect_s *rect,
|
||||
boolean more);
|
||||
boolean more, FAR void *arg);
|
||||
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);
|
||||
FAR const struct nxgl_rect_s *bounds,
|
||||
FAR void *arg);
|
||||
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);
|
||||
FAR const struct nxgl_rect_s *bounds,
|
||||
FAR void *arg);
|
||||
#ifdef CONFIG_NX_MOUSE
|
||||
static void nxeg_mousein1(NXWINDOW hwnd, FAR const struct nxgl_point_s *pos,
|
||||
ubyte buttons);
|
||||
ubyte buttons, FAR void *arg);
|
||||
static void nxeg_mousein2(NXWINDOW hwnd, FAR const struct nxgl_point_s *pos,
|
||||
ubyte buttons);
|
||||
ubyte buttons, FAR void *arg);
|
||||
#endif
|
||||
#ifdef CONFIG_NX_KBD
|
||||
static void nxeg_kbdin(NXWINDOW hwnd, ubyte nch, const ubyte *ch);
|
||||
|
@ -163,10 +165,10 @@ static nxgl_mxpixel_t g_color2[CONFIG_NX_NPLANES];
|
|||
****************************************************************************/
|
||||
|
||||
static void nxeg_redraw1(NXWINDOW hwnd, FAR const struct nxgl_rect_s *rect,
|
||||
boolean more)
|
||||
boolean more, FAR void *arg)
|
||||
{
|
||||
message("nxeg_redraw1: hwnd=%p rect={(%d,%d),(%d,%d)} more=%s\n",
|
||||
hwnd,
|
||||
message("nxeg_redraw%d: hwnd=%p rect={(%d,%d),(%d,%d)} more=%s arg=%p\n",
|
||||
(int)arg, hwnd,
|
||||
rect->pt1.x, rect->pt1.y, rect->pt2.x, rect->pt2.y,
|
||||
more ? "TRUE" : "FALSE");
|
||||
nx_fill(hwnd, rect, g_color1);
|
||||
|
@ -177,12 +179,13 @@ static void nxeg_redraw1(NXWINDOW hwnd, FAR const struct nxgl_rect_s *rect,
|
|||
****************************************************************************/
|
||||
|
||||
static void nxeg_redraw2(NXWINDOW hwnd, FAR const struct nxgl_rect_s *rect,
|
||||
boolean more)
|
||||
boolean more, FAR void *arg)
|
||||
{
|
||||
message("nxeg_redraw2: hwnd=%p rect={(%d,%d),(%d,%d)} more=%s\n",
|
||||
hwnd,
|
||||
message("nxeg_redraw%d: hwnd=%p rect={(%d,%d),(%d,%d)} more=%s arg=%p\n",
|
||||
(int)arg, hwnd,
|
||||
rect->pt1.x, rect->pt1.y, rect->pt2.x, rect->pt2.y,
|
||||
more ? "TRUE" : "FALSE");
|
||||
more ? "TRUE" : "FALSE",
|
||||
arg);
|
||||
nx_fill(hwnd, rect, g_color2);
|
||||
}
|
||||
|
||||
|
@ -192,12 +195,13 @@ static void nxeg_redraw2(NXWINDOW hwnd, FAR const struct nxgl_rect_s *rect,
|
|||
|
||||
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)
|
||||
FAR const struct nxgl_rect_s *bounds,
|
||||
FAR void *arg)
|
||||
{
|
||||
/* Report the position */
|
||||
|
||||
message("nxeg_position1: hwnd=%p size={(%d,%d),(%d,%d)} pos=(%d,%d) bounds={(%d,%d),(%d,%d)}\n",
|
||||
hwnd,
|
||||
message("nxeg_position%d: hwnd=%p size={(%d,%d),(%d,%d)} pos=(%d,%d) bounds={(%d,%d),(%d,%d)}\n",
|
||||
arg, 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);
|
||||
|
@ -223,12 +227,13 @@ static void nxeg_position1(NXWINDOW hwnd, FAR const struct nxgl_rect_s *size,
|
|||
|
||||
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)
|
||||
FAR const struct nxgl_rect_s *bounds,
|
||||
FAR void *arg)
|
||||
{
|
||||
/* Report the position */
|
||||
|
||||
message("nxeg_position2: hwnd=%p size={(%d,%d),(%d,%d)} pos=(%d,%d) bounds={(%d,%d),(%d,%d)}\n",
|
||||
hwnd,
|
||||
message("nxeg_position%d: hwnd=%p size={(%d,%d),(%d,%d)} pos=(%d,%d) bounds={(%d,%d),(%d,%d)}\n",
|
||||
arg, 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);
|
||||
|
@ -240,10 +245,10 @@ static void nxeg_position2(NXWINDOW hwnd, FAR const struct nxgl_rect_s *size,
|
|||
|
||||
#ifdef CONFIG_NX_MOUSE
|
||||
static void nxeg_mousein1(NXWINDOW hwnd, FAR const struct nxgl_point_s *pos,
|
||||
ubyte buttons)
|
||||
ubyte buttons, FAR void *arg)
|
||||
{
|
||||
message("nxeg_mousein1: hwnd=%p pos=(%d,%d) button=%02x\n",
|
||||
hwnd, pos->x, pos->y, buttons);
|
||||
message("nxeg_mousein%d: hwnd=%p pos=(%d,%d) button=%02x\n",
|
||||
arg, hwnd, pos->x, pos->y, buttons);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -253,7 +258,7 @@ static void nxeg_mousein1(NXWINDOW hwnd, FAR const struct nxgl_point_s *pos,
|
|||
|
||||
#ifdef CONFIG_NX_MOUSE
|
||||
static void nxeg_mousein2(NXWINDOW hwnd, FAR const struct nxgl_point_s *pos,
|
||||
ubyte buttons)
|
||||
ubyte buttons, FAR void *arg)
|
||||
{
|
||||
message("nxeg_mousein2: hwnd=%p pos=(%d,%d) button=%02x\n",
|
||||
hwnd, pos->x, pos->y, buttons);
|
||||
|
@ -546,7 +551,7 @@ int user_start(int argc, char *argv[])
|
|||
/* Create window #1 */
|
||||
|
||||
message("user_start: Create window #1\n");
|
||||
hwnd1 = nx_openwindow(g_hnx, &g_nxcb1);
|
||||
hwnd1 = nx_openwindow(g_hnx, &g_nxcb1, (FAR void *)2);
|
||||
message("user_start: hwnd1=%p\n", hwnd1);
|
||||
|
||||
if (!hwnd1)
|
||||
|
@ -580,8 +585,18 @@ int user_start(int argc, char *argv[])
|
|||
goto errout_with_hwnd1;
|
||||
}
|
||||
|
||||
pt.x = g_xres / 4;
|
||||
pt.y = g_yres / 4;
|
||||
/* Sleep a bit -- both so that we can see the result of the above operations
|
||||
* but also, in the multi-user case, so that the server can get a chance to
|
||||
* actually do them!
|
||||
*/
|
||||
|
||||
message("user_start: Sleeping\n\n");
|
||||
sleep(1);
|
||||
|
||||
/* Set the position of window #1 */
|
||||
|
||||
pt.x = g_xres / 8;
|
||||
pt.y = g_yres / 8;
|
||||
|
||||
message("user_start: Set hwnd1 postion to (%d,%d)\n", pt.x, pt.y);
|
||||
ret = nx_setposition(hwnd1, &pt);
|
||||
|
@ -592,18 +607,15 @@ int user_start(int argc, char *argv[])
|
|||
goto errout_with_hwnd1;
|
||||
}
|
||||
|
||||
/* Sleep a bit -- both so that we can see the result of the above operations
|
||||
* but also, in the multi-user case, so that the server can get a chance to
|
||||
* actually do them!
|
||||
*/
|
||||
/* Sleep a bit */
|
||||
|
||||
message("user_start: Sleeping\n\n");
|
||||
sleep(2);
|
||||
|
||||
/* Create window #2 */
|
||||
|
||||
message("user_start: Create window #1\n");
|
||||
hwnd2 = nx_openwindow(g_hnx, &g_nxcb2);
|
||||
message("user_start: Create window #2\n");
|
||||
hwnd2 = nx_openwindow(g_hnx, &g_nxcb2, (FAR void *)2);
|
||||
message("user_start: hwnd2=%p\n", hwnd2);
|
||||
|
||||
if (!hwnd2)
|
||||
|
@ -613,6 +625,11 @@ int user_start(int argc, char *argv[])
|
|||
goto errout_with_hwnd1;
|
||||
}
|
||||
|
||||
/* Sleep a bit */
|
||||
|
||||
message("user_start: Sleeping\n\n");
|
||||
sleep(1);
|
||||
|
||||
/* 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);
|
||||
|
@ -624,6 +641,13 @@ int user_start(int argc, char *argv[])
|
|||
goto errout_with_hwnd2;
|
||||
}
|
||||
|
||||
/* Sleep a bit */
|
||||
|
||||
message("user_start: Sleeping\n\n");
|
||||
sleep(1);
|
||||
|
||||
/* Set the position of window #2 */
|
||||
|
||||
pt.x = g_xres - rect.pt2.x - pt.x;
|
||||
pt.y = g_yres - rect.pt2.y - pt.y;
|
||||
|
||||
|
@ -654,6 +678,22 @@ int user_start(int argc, char *argv[])
|
|||
|
||||
/* Sleep a bit */
|
||||
|
||||
message("user_start: Sleeping\n\n");
|
||||
sleep(1);
|
||||
|
||||
/* Lower window 1 */
|
||||
|
||||
message("user_start: Raise window #2\n");
|
||||
ret = nx_raise(hwnd2);
|
||||
if (ret < 0)
|
||||
{
|
||||
message("user_start: nx_raise failed: %d\n", errno);
|
||||
g_exitcode = NXEXIT_NXSETPOSITION;
|
||||
goto errout_with_hwnd2;
|
||||
}
|
||||
|
||||
/* Sleep a bit */
|
||||
|
||||
message("user_start: Sleeping\n\n");
|
||||
sleep(2);
|
||||
|
||||
|
|
|
@ -142,9 +142,14 @@ struct nxbe_window_s
|
|||
FAR struct nxbe_window_s *above; /* The window "above" this window */
|
||||
FAR struct nxbe_window_s *below; /* The window "below this one */
|
||||
|
||||
/* Window geometry */
|
||||
|
||||
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 */
|
||||
|
||||
/* Client state information this is provide in window callbacks */
|
||||
|
||||
FAR void *arg;
|
||||
};
|
||||
|
||||
/* Back-end state ***********************************************************/
|
||||
|
|
|
@ -193,7 +193,7 @@ int nx_eventhandler(NXHANDLE handle)
|
|||
DEBUGASSERT(wnd);
|
||||
if (wnd->cb->redraw)
|
||||
{
|
||||
wnd->cb->redraw((NXWINDOW)wnd, &redraw->rect, redraw->more);
|
||||
wnd->cb->redraw((NXWINDOW)wnd, &redraw->rect, redraw->more, wnd->arg);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -205,7 +205,7 @@ int nx_eventhandler(NXHANDLE handle)
|
|||
DEBUGASSERT(wnd);
|
||||
if (wnd->cb->position)
|
||||
{
|
||||
wnd->cb->position((NXWINDOW)wnd, &postn->size, &postn->pos, &postn->bounds);
|
||||
wnd->cb->position((NXWINDOW)wnd, &postn->size, &postn->pos, &postn->bounds, wnd->arg);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -218,7 +218,7 @@ int nx_eventhandler(NXHANDLE handle)
|
|||
DEBUGASSERT(wnd);
|
||||
if (wnd->cb->mousein)
|
||||
{
|
||||
wnd->cb->mousein((NXWINDOW)wnd, &mouse->pos, mouse->buttons);
|
||||
wnd->cb->mousein((NXWINDOW)wnd, &mouse->pos, mouse->buttons, wnd->arg);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -232,7 +232,7 @@ int nx_eventhandler(NXHANDLE handle)
|
|||
DEBUGASSERT(wnd);
|
||||
if (wnd->cb->kbdin)
|
||||
{
|
||||
wnd->cb->kbdin((NXWINDOW)wnd, kbd->nch, kbd->ch);
|
||||
wnd->cb->kbdin((NXWINDOW)wnd, kbd->nch, kbd->ch, wnd->arg);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -93,7 +93,7 @@ int nx_kbdchin(NXHANDLE handle, ubyte ch)
|
|||
|
||||
if (wnd->cb->kbdin)
|
||||
{
|
||||
wnd->kbdin(wnd, 1, &ch);
|
||||
wnd->cb->kbdin(wnd, 1, &ch, wnd->arg);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -92,7 +92,7 @@ int int nx_kbdin(NXHANDLE handle, ubyte nch const char *ch)
|
|||
|
||||
if (wnd->cb->kbdin)
|
||||
{
|
||||
wnd->cb->kbdin(wnd, kbd->nch, kbd->ch);
|
||||
wnd->cb->kbdin(wnd, kbd->nch, kbd->ch, wnd->arg);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -107,7 +107,7 @@ void nxsu_mousereport(struct nxbe_window_s *wnd)
|
|||
|
||||
if (win->cb->mousein)
|
||||
{
|
||||
win->cb->mousein((NXWINDOW)wnd, &g_mpos, g_mbutton);
|
||||
win->cb->mousein((NXWINDOW)wnd, &g_mpos, g_mbutton, wnd->arg);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -61,7 +61,8 @@
|
|||
****************************************************************************/
|
||||
|
||||
static void nxsu_bkgdredraw(NXWINDOW hwnd,
|
||||
FAR const struct nxgl_rect_s *rect, boolean more);
|
||||
FAR const struct nxgl_rect_s *rect,
|
||||
boolean more, FAR void *arg);
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
|
@ -92,7 +93,8 @@ const struct nx_callback_s g_bkgdcb =
|
|||
****************************************************************************/
|
||||
|
||||
static void nxsu_bkgdredraw(NXWINDOW hwnd,
|
||||
FAR const struct nxgl_rect_s *rect, boolean more)
|
||||
FAR const struct nxgl_rect_s *rect,
|
||||
boolean more, FAR void *arg)
|
||||
{
|
||||
FAR struct nxbe_window_s *wnd = (FAR struct nxbe_window_s *)hwnd;
|
||||
FAR struct nxbe_state_s *be = wnd->be;
|
||||
|
|
|
@ -97,7 +97,7 @@ void nxfe_redrawreq(FAR struct nxbe_window_s *wnd, FAR const struct nxgl_rect_s
|
|||
|
||||
/* And request the redraw */
|
||||
|
||||
wnd->cb->redraw((NXWINDOW)wnd, &relrect, FALSE);
|
||||
wnd->cb->redraw((NXWINDOW)wnd, &relrect, FALSE, wnd->arg);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -102,6 +102,6 @@ void nxfe_reportposition(FAR struct nxbe_window_s *wnd)
|
|||
|
||||
/* And provide this to the client */
|
||||
|
||||
wnd->cb->position(wnd, &rect, &wnd->origin, &be->bkgd.bounds);
|
||||
wnd->cb->position(wnd, &rect, &wnd->origin, &be->bkgd.bounds, wnd->arg);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -101,13 +101,15 @@ struct nx_callback_s
|
|||
* rect - The rectangle that needs to be re-drawn (in window relative
|
||||
* coordinates
|
||||
* more - TRUE: More re-draw requests will follow
|
||||
* arg - User provided argument (see nx_openwindow, nx_constructwindow)
|
||||
*
|
||||
* 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, FAR void *arg);
|
||||
|
||||
/**************************************************************************
|
||||
* Name: position
|
||||
|
@ -123,6 +125,7 @@ struct nx_callback_s
|
|||
* the overalll display
|
||||
* bounds - The bounding rectangle that the describes the entire
|
||||
* display
|
||||
* arg - User provided argument (see nx_openwindow, nx_constructwindow)
|
||||
*
|
||||
* Returned Value:
|
||||
* None
|
||||
|
@ -131,7 +134,8 @@ struct nx_callback_s
|
|||
|
||||
void (*position)(NXWINDOW hwnd, FAR const struct nxgl_rect_s *size,
|
||||
FAR const struct nxgl_point_s *pos,
|
||||
FAR const struct nxgl_rect_s *bounds);
|
||||
FAR const struct nxgl_rect_s *bounds,
|
||||
FAR void *arg);
|
||||
|
||||
/**************************************************************************
|
||||
* Name: mousein
|
||||
|
@ -143,6 +147,7 @@ struct nx_callback_s
|
|||
* hwnd - Window handle
|
||||
* pos - The (x,y) position of the mouse
|
||||
* buttons - See NX_MOUSE_* definitions
|
||||
* arg - User provided argument (see nx_openwindow, nx_constructwindow)
|
||||
*
|
||||
* Returned Value:
|
||||
* None
|
||||
|
@ -150,7 +155,8 @@ struct nx_callback_s
|
|||
**************************************************************************/
|
||||
|
||||
#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, FAR void *arg);
|
||||
#endif
|
||||
|
||||
/**************************************************************************
|
||||
|
@ -163,6 +169,7 @@ struct nx_callback_s
|
|||
* hwnd - Window handle
|
||||
* nch - The number of characters that are available in ch[]
|
||||
* ch - The array of characters
|
||||
* arg - User provided argument (see nx_openwindow, nx_constructwindow)
|
||||
*
|
||||
* Returned Value:
|
||||
* None
|
||||
|
@ -170,7 +177,7 @@ struct nx_callback_s
|
|||
**************************************************************************/
|
||||
|
||||
#ifdef CONFIG_NX_KBD
|
||||
void (*kbdin)(NXWINDOW hwnd, ubyte nch, const ubyte *ch);
|
||||
void (*kbdin)(NXWINDOW hwnd, ubyte nch, const ubyte *ch, FAR void *arg);
|
||||
#endif
|
||||
};
|
||||
|
||||
|
@ -390,6 +397,7 @@ EXTERN int nx_eventnotify(NXHANDLE handle, int signo);
|
|||
* Input Parameters:
|
||||
* handle - The handle returned by nx_connect
|
||||
* cb - Callbacks used to process window events
|
||||
* arg - User provided value that will be returned with NX callbacks.
|
||||
*
|
||||
* Return:
|
||||
* Success: A non-NULL handle used with subsequent NX accesses
|
||||
|
@ -398,7 +406,8 @@ EXTERN int nx_eventnotify(NXHANDLE handle, int signo);
|
|||
****************************************************************************/
|
||||
|
||||
EXTERN NXWINDOW nx_openwindow(NXHANDLE handle,
|
||||
FAR const struct nx_callback_s *cb);
|
||||
FAR const struct nx_callback_s *cb,
|
||||
FAR void *arg);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nx_closewindow
|
||||
|
|
Loading…
Reference in a new issue