summaryrefslogtreecommitdiff
path: root/nuttx/examples/nx/nx_main.c
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2008-12-01 13:22:34 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2008-12-01 13:22:34 +0000
commitad2faab27444c4f2e24e5bcde65898036a86767b (patch)
tree532459fbfda124d5b0b781ba52a3900cdf215231 /nuttx/examples/nx/nx_main.c
parentfb34a4488c575b10b465ef59cd72a568079330ce (diff)
downloadpx4-nuttx-ad2faab27444c4f2e24e5bcde65898036a86767b.tar.gz
px4-nuttx-ad2faab27444c4f2e24e5bcde65898036a86767b.tar.bz2
px4-nuttx-ad2faab27444c4f2e24e5bcde65898036a86767b.zip
Add argument to window callbacks
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@1366 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/examples/nx/nx_main.c')
-rw-r--r--nuttx/examples/nx/nx_main.c104
1 files changed, 72 insertions, 32 deletions
diff --git a/nuttx/examples/nx/nx_main.c b/nuttx/examples/nx/nx_main.c
index a98795d42..f1a136f82 100644
--- a/nuttx/examples/nx/nx_main.c
+++ b/nuttx/examples/nx/nx_main.c
@@ -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;
@@ -655,6 +679,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);
/* Close the window 2 */