[PATCH] libtXt: add simple example for XtAppNextEvent() man page

walter harms wharms at bfs.de
Sun Jan 23 08:10:44 PST 2011


Add simple example for XtAppNextEvent() man page

Signed-off-by: walter harms <wharms at bfs.de>
---
 man/XtAppNextEvent.man |   43 +++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 43 insertions(+), 0 deletions(-)

diff --git a/man/XtAppNextEvent.man b/man/XtAppNextEvent.man
index e7278a5..58a4685 100644
--- a/man/XtAppNextEvent.man
+++ b/man/XtAppNextEvent.man
@@ -1,3 +1,5 @@
+.\" $Xorg: XtAppNEv.man,v 1.3 2000/08/17 19:41:58 cpqbld Exp $
+.\"
 .\" Copyright 1993 X Consortium
 .\"
 .\" Permission is hereby granted, free of charge, to any person obtaining
@@ -23,6 +25,7 @@
 .\" not be used in advertising or otherwise to promote the sale, use or
 .\" other dealings in this Software without prior written authorization
 .\" from the X Consortium.
+.\" $XFree86: xc/doc/man/Xt/XtAppNEv.man,v 1.5 2001/01/27 18:20:24 dawes Exp $
 .\"
 .ds tk X Toolkit
 .ds xT X Toolkit Intrinsics \- C Language Interface
@@ -273,6 +276,46 @@ Applications can provide their own version of this loop,
 which tests some global termination flag or tests that the number
 of top-level widgets is larger than zero before circling back to the call to
 .ZN XtAppNextEvent .
+.SH EXAMPLE
+The example shows a home grown version of XtAppMainLoop(). After start
+you will see all events printed on the command line.
+.nf
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <X11/Intrinsic.h>
+#include <Xaw/Label.h>
+
+/* gcc -I /usr/include/X11/ sample.c -o sample -lX11 -lXaw */
+
+int main(int argc, char *argv[])
+{
+  XtAppContext app;
+  Widget toplevel, label;
+  XEvent event;
+
+  toplevel=XtVaAppInitialize(&app,"XtAppNextEvent",
+			     NULL,0,		/* XrmOptionDesc */
+         		     &argc, argv,      /* cli args */
+			     NULL, /* Resources */	
+			     NULL );
+
+  label=XtVaCreateManagedWidget("XtAppNextEvent", labelWidgetClass, toplevel, NULL);
+	
+  XtRealizeWidget(toplevel);
+  for(;;) {
+    XtAppNextEvent(app, &event); /* sleeps on next event */
+    printf("event: type=%02d serial=%04ld send_event=%d"
+           " display=%s window=%08lx\\n",
+           event.type, event.xany.serial, event.xany.send_event,
+           DisplayString(event.xany.display), (long)event.xany.window);
+    XtDispatchEvent(&event);
+  }
+  return 0;
+}
+
+.fi
+
 .SH "SEE ALSO"
 .br
 \fI\*(xT\fP
-- 
1.6.0.2



More information about the xorg-devel mailing list