X11: release all keys/buttons when window loses focus
This commit is contained in:
@@ -145,6 +145,7 @@ InputHandler_X11::InputHandler_X11()
|
|||||||
XSelectInput( Dpy, Win,
|
XSelectInput( Dpy, Win,
|
||||||
winAttrib.your_event_mask | KeyPressMask | KeyReleaseMask
|
winAttrib.your_event_mask | KeyPressMask | KeyReleaseMask
|
||||||
| ButtonPressMask | ButtonReleaseMask | PointerMotionMask
|
| ButtonPressMask | ButtonReleaseMask | PointerMotionMask
|
||||||
|
| FocusChangeMask
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -152,12 +153,14 @@ InputHandler_X11::~InputHandler_X11()
|
|||||||
{
|
{
|
||||||
if( Dpy == NULL || Win == None )
|
if( Dpy == NULL || Win == None )
|
||||||
return;
|
return;
|
||||||
|
// TODO: Determine if we even need to set this back (or is the window
|
||||||
|
// destroyed just after this?)
|
||||||
XWindowAttributes winAttrib;
|
XWindowAttributes winAttrib;
|
||||||
|
|
||||||
XGetWindowAttributes( Dpy, Win, &winAttrib );
|
XGetWindowAttributes( Dpy, Win, &winAttrib );
|
||||||
XSelectInput( Dpy, Win,
|
XSelectInput( Dpy, Win,
|
||||||
winAttrib.your_event_mask &
|
winAttrib.your_event_mask &
|
||||||
~(KeyPressMask|KeyReleaseMask|ButtonPressMask|ButtonReleaseMask|PointerMotionMask)
|
~(KeyPressMask|KeyReleaseMask|ButtonPressMask|ButtonReleaseMask|PointerMotionMask|FocusChangeMask)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -173,10 +176,13 @@ void InputHandler_X11::Update()
|
|||||||
DeviceButton lastDB = DeviceButton_Invalid;
|
DeviceButton lastDB = DeviceButton_Invalid;
|
||||||
lastEvent.type = 0;
|
lastEvent.type = 0;
|
||||||
|
|
||||||
|
// TODO: Rewrite to use XEventsQueued, XNextEvent, and XPeekEvent - this
|
||||||
|
// will likely make the logic simpler
|
||||||
// todo: add other masks? (like the ones for drag'n drop) -aj
|
// todo: add other masks? (like the ones for drag'n drop) -aj
|
||||||
while( XCheckWindowEvent(Dpy, Win,
|
while( XCheckWindowEvent(Dpy, Win,
|
||||||
KeyPressMask | KeyReleaseMask
|
KeyPressMask | KeyReleaseMask
|
||||||
| ButtonPressMask | ButtonReleaseMask | PointerMotionMask,
|
| ButtonPressMask | ButtonReleaseMask | PointerMotionMask
|
||||||
|
| FocusChangeMask,
|
||||||
&event) )
|
&event) )
|
||||||
{
|
{
|
||||||
const bool bKeyPress = event.type == KeyPress;
|
const bool bKeyPress = event.type == KeyPress;
|
||||||
@@ -201,6 +207,12 @@ void InputHandler_X11::Update()
|
|||||||
lastEvent.type = 0;
|
lastEvent.type = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if( event.type == FocusOut )
|
||||||
|
{
|
||||||
|
// Release all buttons
|
||||||
|
INPUTFILTER->Reset();
|
||||||
|
}
|
||||||
|
|
||||||
// Get the first defined keysym for this event's key
|
// Get the first defined keysym for this event's key
|
||||||
lastDB = XSymToDeviceButton( XLookupKeysym(&event.xkey, 0) );
|
lastDB = XSymToDeviceButton( XLookupKeysym(&event.xkey, 0) );
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user