mirror of
https://github.com/gnif/LookingGlass.git
synced 2024-11-25 14:57:20 +00:00
[client] grab the keyboard when the window has focus
This commit is contained in:
parent
db51acdd8a
commit
4a823d0e4f
@ -925,6 +925,30 @@ static void handleWindowEnter()
|
||||
state.warpState = WARP_STATE_ARMED;
|
||||
}
|
||||
|
||||
// only called for X11
|
||||
static void keyboardGrab()
|
||||
{
|
||||
// grab the keyboard so we can intercept WM keys
|
||||
XGrabKeyboard(
|
||||
state.wminfo.info.x11.display,
|
||||
state.wminfo.info.x11.window,
|
||||
true,
|
||||
GrabModeAsync,
|
||||
GrabModeAsync,
|
||||
CurrentTime
|
||||
);
|
||||
}
|
||||
|
||||
// only called for X11
|
||||
static void keyboardUngrab()
|
||||
{
|
||||
// ungrab the keyboard
|
||||
XUngrabKeyboard(
|
||||
state.wminfo.info.x11.display,
|
||||
CurrentTime
|
||||
);
|
||||
}
|
||||
|
||||
int eventFilter(void * userdata, SDL_Event * event)
|
||||
{
|
||||
switch(event->type)
|
||||
@ -998,6 +1022,18 @@ int eventFilter(void * userdata, SDL_Event * event)
|
||||
state.haveCurLocal = true;
|
||||
handleWindowLeave();
|
||||
break;
|
||||
|
||||
case FocusIn:
|
||||
if (xe.xfocus.mode == NotifyNormal ||
|
||||
xe.xfocus.mode == NotifyUngrab)
|
||||
keyboardGrab();
|
||||
break;
|
||||
|
||||
case FocusOut:
|
||||
if (xe.xfocus.mode == NotifyNormal ||
|
||||
xe.xfocus.mode == NotifyWhileGrabbed)
|
||||
keyboardUngrab();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user