X-Git-Url: http://git.demorecorder.com/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=neko%2Fxcbneko.c;h=bd7b7068aeeda2295c09dd3a07077a1998984e0e;hb=6db1b7e5de1abfc6315038aadc763ecfbb4213d0;hp=5eff1ce407d9a9869a07a465434af90dff098afd;hpb=a35253a9f35cc9dfe6800e4f8e5f0c70dd5c2a81;p=free-sw%2Fxcb%2Fdemo diff --git a/neko/xcbneko.c b/neko/xcbneko.c index 5eff1ce..bd7b706 100644 --- a/neko/xcbneko.c +++ b/neko/xcbneko.c @@ -27,6 +27,7 @@ #include /* XCBAuxGetScreen */ #include #include /* STRING atom */ +#include 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 ); */ - XCBSync( xc, NULL ); } void @@ -697,7 +698,13 @@ InitScreen( char *DisplayName, char *theGeometry, char *theTitle, Bool iconicSta InitBitmapAndGCs(); - XCBSync(xc, NULL); + XCBFlush(xc); + + /* latency: ask for keysyms now, and receive them later */ + theKeySyms = XCBKeySymbolsAlloc( xc ); + + /* later: XCBKeySymbolsFree( keysyms ); */ + /* later: XCBRefreshKeyboardMapping ( keysyms, mappingEvent ); */ } @@ -744,7 +751,7 @@ SetNekoState( int SetValue ) } /* FillRct.c */ -/* Xlib does merging of requests, but the Sync and frequent DrawGC changes +/* Xlib does merging of requests, but the Flush and frequent DrawGC changes defeat this mechanism */ void @@ -767,7 +774,7 @@ DrawNeko( int x, int y, XCBGCONTEXT DrawGC ) XCBPolyFillRectangle( xc, drawable, DrawGC, 1, &rect ); - XCBSync( xc, NULL ); + XCBFlush( xc ); NekoLastX = x; NekoLastY = y; @@ -782,7 +789,7 @@ void RedrawNeko(void) { XCBPolyFillRectangle( xc, drawable, NekoLastGC, 1, &rect ); - XCBSync( xc, NULL ); + XCBFlush( xc ); } @@ -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 ) {