From 8de9688b29b23356e80b22309e83df81b0f82d39 Mon Sep 17 00:00:00 2001 From: Sean Burke Date: Tue, 15 Mar 2005 01:32:24 +0000 Subject: [PATCH] A much more elegant solution for input handling in X11; can still probably do with some improvement --- .../arch/InputHandler/InputHandler_X11.cpp | 21 +++++++++---------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/stepmania/src/arch/InputHandler/InputHandler_X11.cpp b/stepmania/src/arch/InputHandler/InputHandler_X11.cpp index 887db572b6..937812b94c 100644 --- a/stepmania/src/arch/InputHandler/InputHandler_X11.cpp +++ b/stepmania/src/arch/InputHandler/InputHandler_X11.cpp @@ -127,18 +127,17 @@ void InputHandler_X11::Update(float fDeltaTime) /* XXX: This steals input from other windows, but XCheckMaskEvent won't return anything * if it isn't called. */ if (X11Helper::Win()) - XGrabKeyboard(X11Helper::Dpy(),X11Helper::Win(),true,GrabModeAsync,GrabModeAsync,CurrentTime); - while(XCheckMaskEvent(X11Helper::Dpy(), KeyPressMask, &event) - || XCheckMaskEvent(X11Helper::Dpy(), KeyReleaseMask, &event) ) - { - LOG->Trace("key: sym %i, key %i, state %i", - XLookupKeysym(&event.xkey,0), XSymToKeySym(XLookupKeysym(&event.xkey,0)), - event.type == KeyPress ); + while(XCheckTypedWindowEvent(X11Helper::Dpy(), X11Helper::Win(), KeyPress, &event) + || XCheckTypedWindowEvent(X11Helper::Dpy(), X11Helper::Win(), KeyRelease, &event) ) + { + LOG->Trace("key: sym %i, key %i, state %i", + XLookupKeysym(&event.xkey,0), XSymToKeySym(XLookupKeysym(&event.xkey,0)), + event.type == KeyPress ); - DeviceInput di( DEVICE_KEYBOARD, - XSymToKeySym(XLookupKeysym(&event.xkey,0)) ); - ButtonPressed(di, event.type == KeyPress); - } + DeviceInput di( DEVICE_KEYBOARD, + XSymToKeySym(XLookupKeysym(&event.xkey,0)) ); + ButtonPressed(di, event.type == KeyPress); + } InputHandler::UpdateTimer(); }