[Xcb-commit] 3 commits - xcb-demo xcb-proto xcb-util

Ian Osgood iano at kemper.freedesktop.org
Tue Mar 21 08:24:02 PST 2006


 xcb-demo/neko/Makefile              |    2 -
 xcb-demo/neko/README                |    1 
 xcb-demo/neko/xcbneko.c             |   44 +++++++++++++-----------------------
 xcb-proto/doc/xml-xcb.txt           |   11 ++++++---
 xcb-util/image/test_xcb_image.c     |    5 +---
 xcb-util/image/test_xcb_image_shm.c |    1 
 xcb-util/image/xcb_image.h          |    4 ++-
 7 files changed, 30 insertions(+), 38 deletions(-)

New commits:
diff-tree 107f317681300e2e21c511406929d0c5663f70a0 (from c4ab2f41e12d77be36f09bcf8fce1ea72d4bf602)
Author: Ian Osgood <iano at quirkster.com>
Date:   Tue Mar 21 08:21:18 2006 -0800

    Detect Alt-Q to quit using xcb_keysyms.h library.

diff --git a/xcb-demo/neko/Makefile b/xcb-demo/neko/Makefile
index de7ac0b..089f915 100644
--- a/xcb-demo/neko/Makefile
+++ b/xcb-demo/neko/Makefile
@@ -1,5 +1,5 @@
 CFLAGS = -g -Wall -Wpointer-arith -Wstrict-prototypes
-LIBS = -lxcb -lXCBAux -lXCBICCCM -lXCBAtom
+LIBS = -lxcb -lXCBAux -lXCBICCCM -lXCBAtom -lXCBKeysyms
 
 xcbneko:	xcbneko.c
 	$(CC) $(CFLAGS) xcbneko.c $(LIBS) -o xcbneko
diff --git a/xcb-demo/neko/README b/xcb-demo/neko/README
index a0d2e37..1902013 100644
--- a/xcb-demo/neko/README
+++ b/xcb-demo/neko/README
@@ -9,7 +9,6 @@ XCB TODO
 * DEBUG not supported
 * -geometry not supported
 * WM hints, -iconic not supported (don't like the util interfaces)
-* quit on Alt-Q not supported (XLookupString)
 
 XCB ENHANCEMENTS
 ----------------
diff --git a/xcb-demo/neko/xcbneko.c b/xcb-demo/neko/xcbneko.c
index a10b9e1..bd7b706 100644
--- a/xcb-demo/neko/xcbneko.c
+++ b/xcb-demo/neko/xcbneko.c
@@ -27,6 +27,7 @@
 #include <X11/XCB/xcb_aux.h>		/* XCBAuxGetScreen */
 #include <X11/XCB/xcb_icccm.h>
 #include <X11/XCB/xcb_atom.h>		/* STRING atom */
+#include <X11/XCB/xcb_keysyms.h>
 
 typedef enum { False, True } Bool;
 
@@ -148,6 +149,7 @@ unsigned long  theBlackPixel;
 unsigned long  theWhitePixel;
 XCBWINDOW         theWindow;
 XCBCURSOR         theCursor;
+XCBKeySymbols	*theKeySyms;
 
 static unsigned int  WindowWidth;
 static unsigned int  WindowHeight;
@@ -509,7 +511,6 @@ void  InitBitmapAndGCs(void) {
   
   /* later: XCBFreePixmap( c, bitmap ); */
   /* later: XCBFreeGC( c, gc ); */
-  XCBFlush( xc );
 }
 
 void
@@ -698,6 +699,12 @@ InitScreen( char *DisplayName, char *the
   InitBitmapAndGCs();
 
   XCBFlush(xc);
+
+  /* latency: ask for keysyms now, and receive them later */
+  theKeySyms = XCBKeySymbolsAlloc( xc );
+
+  /* later: XCBKeySymbolsFree( keysyms ); */
+  /* later: XCBRefreshKeyboardMapping ( keysyms, mappingEvent ); */
 }
 
 
@@ -1076,36 +1083,17 @@ void  DisplayCharacters() {
 Bool
 ProcessKeyPress( XCBKeyPressEvent *theKeyEvent )
 {
-#if TODO    
   Bool ReturnState = True;
 
-  int			Length;
-  char		theKeyBuffer[ AVAIL_KEYBUF + 1 ];
-    int			theKeyBufferMaxLen = AVAIL_KEYBUF;
-  KeySym		theKeySym;
-  XComposeStatus	theComposeStatus;
-
-  Length = XLookupString( theKeyEvent,
-						 theKeyBuffer, theKeyBufferMaxLen,
-						 &theKeySym, &theComposeStatus );
-
-  if ( Length > 0 ) {
-	switch ( theKeyBuffer[ 0 ] ) {
-	case 'q':
-	case 'Q':
-	  if ( theKeyEvent->state & XCBModMask1 ) {	/* META (Alt) %-!< */
-		ReturnState = False;
-	  }
-	  break;
-	default:
-	  break;
-	}
-  }
-#else
-  /* quit on any key */
-  Bool ReturnState = False;
-#endif
+  /* quit on Meta-Q (Alt-Q) */
+  XCBKEYSYM theKeySym;
+
+  /* last param is "int col". What? add enumeration to xcb_keysyms.h */
+  theKeySym = XCBKeyPressLookupKeysym( theKeySyms, theKeyEvent, 1 );
 
+  /* KeySym XK_Q == 'Q' */
+  if (theKeySym.id == 'Q' && (theKeyEvent->state & XCBModMask1))
+    ReturnState = False;
 
 #ifdef	DEBUG
   if ( EventState == DEBUG_MOVE ) {
diff-tree c4ab2f41e12d77be36f09bcf8fce1ea72d4bf602 (from 40146dfcaa599a669ccc25a96f28ff8045344ec1)
Author: Ian Osgood <iano at quirkster.com>
Date:   Mon Mar 20 07:36:39 2006 -0800

    Update xml-xcb.txt to include new <bit> expression.

diff --git a/xcb-proto/doc/xml-xcb.txt b/xcb-proto/doc/xml-xcb.txt
index 51e641b..b88d182 100644
--- a/xcb-proto/doc/xml-xcb.txt
+++ b/xcb-proto/doc/xml-xcb.txt
@@ -259,9 +259,9 @@ Expressions
 <op op="operator">expression expression</op>
 
   The op element represents an operator, with the op attribute specifying
-  which operator.  The supported operations are *, /, &amp;, and &lt;&lt;, and
-  their semantics are identical to the corresponding operators in C.  The two
-  operand expressions may be fieldref, value, or op elements.
+  which operator.  The supported operations are +, -, *, /, &amp;, and
+  &lt;&lt;, and their semantics are identical to the corresponding operators
+  in C.  The two operand expressions may be other expression elements.
 
 <fieldref>identifier</fieldref>
 
@@ -273,3 +273,8 @@ Expressions
 
   The value element represents a literal integer value in an expression.  The
   integer may be expressed in decimal or hexadecimal.
+
+<bit>integer</bit>
+
+  The bit element represents a literal bitmask value in an expression.
+  The integer must be in the range 0..31, expanding to (1<<n) in C.
diff-tree 40146dfcaa599a669ccc25a96f28ff8045344ec1 (from 3f905a20421cbc588dbec547c5dab739d8182985)
Author: Ian Osgood <iano at quirkster.com>
Date:   Sun Mar 19 21:47:12 2006 -0800

    Remove xcb_image dependency on X11/Xlib.h

diff --git a/xcb-util/image/test_xcb_image.c b/xcb-util/image/test_xcb_image.c
index 726c3fa..dbe9576 100644
--- a/xcb-util/image/test_xcb_image.c
+++ b/xcb-util/image/test_xcb_image.c
@@ -5,7 +5,6 @@
 
 #include <X11/XCB/xcb.h>
 #include <X11/XCB/shm.h>
-#include <X11/Xlib.h>
 
 #include "xcb_aux.h"
 #include "xcb_image.h"
@@ -36,7 +35,7 @@ reflect_window (XCBConnection *c,
   printf ("get_image %d %d\n", width, height);
   image = XCBImageGet (c, win,
 			 0, 0, width, height,
-			 AllPlanes,
+			 XCBAllPlanes,
 			 format);
 
   printf ("Create image summary:\n");
@@ -92,7 +91,7 @@ reflect_window (XCBConnection *c,
 		 0, 0, 0, 0, width, height);
   image = XCBImageGet (c, new_win,
 			 0, 0, width, height,
-			 AllPlanes,
+			 XCBAllPlanes,
 			 format);
   printf ("New : \n");
   for (j = 0 ; j < image->height ; j++)
diff --git a/xcb-util/image/test_xcb_image_shm.c b/xcb-util/image/test_xcb_image_shm.c
index 4975fe5..6e15be3 100644
--- a/xcb-util/image/test_xcb_image_shm.c
+++ b/xcb-util/image/test_xcb_image_shm.c
@@ -6,7 +6,6 @@
 
 #include <X11/XCB/xcb.h>
 #include <X11/XCB/shm.h>
-#include <X11/Xlib.h>
 
 #include "xcb_aux.h"
 #include "xcb_image.h"
diff --git a/xcb-util/image/xcb_image.h b/xcb-util/image/xcb_image.h
index 36d33a7..1a54550 100644
--- a/xcb-util/image/xcb_image.h
+++ b/xcb-util/image/xcb_image.h
@@ -107,6 +107,8 @@ int XCBImageInit (XCBImage *image);
  */
 int XCBImageDestroy (XCBImage *image);
 
+#define XCBAllPlanes ((unsigned long)~0L)
+
 /**
  * Return a pointer to a XCBImage.
  * @param conn The connection to the X server.
@@ -117,7 +119,7 @@ int XCBImageDestroy (XCBImage *image);
  * drawable and define the upper-left corner of the rectangle.
  * @param width The width of the subimage, in pixels.
  * @param height The height of the subimage, in pixels.
- * @param plane_mask The plane mask.
+ * @param plane_mask The plane mask (can be XCBAllPlanes).
  * @param format The format of the image. You can pass XYBitmap,
  * XYPixmap, or ZPixmap.
  * @return The subimage of @p draw defined by @p x, @p y, @p w, @p h.


More information about the xcb-commit mailing list