mirror of
https://github.com/gnif/LookingGlass.git
synced 2024-12-23 06:11:46 +00:00
[client] x11: add error checking around XIGrabDevice
This commit is contained in:
parent
4c1893fe20
commit
ef54e1be7f
1 changed files with 33 additions and 2 deletions
|
@ -572,6 +572,25 @@ static bool x11EventFilter(SDL_Event * event)
|
|||
}
|
||||
}
|
||||
|
||||
static void x11PrintGrabError(const char * type, int dev, Status ret)
|
||||
{
|
||||
const char * errStr;
|
||||
switch(ret)
|
||||
{
|
||||
case AlreadyGrabbed : errStr = "AlreadyGrabbed" ; break;
|
||||
case GrabNotViewable: errStr = "GrabNotViewable"; break;
|
||||
case GrabFrozen : errStr = "GrabFrozen" ; break;
|
||||
case GrabInvalidTime: errStr = "GrabInvalidTime"; break;
|
||||
default:
|
||||
errStr = "Unknown";
|
||||
break;
|
||||
}
|
||||
|
||||
DEBUG_ERROR("XIGrabDevice failed for %s dev %d with 0x%x (%s)",
|
||||
type, dev, ret, errStr);
|
||||
|
||||
}
|
||||
|
||||
static void x11GrabPointer(void)
|
||||
{
|
||||
if (x11.pointerGrabbed)
|
||||
|
@ -589,7 +608,7 @@ static void x11GrabPointer(void)
|
|||
XISetMask(mask.mask, XI_RawMotion );
|
||||
XISetMask(mask.mask, XI_Motion );
|
||||
|
||||
XIGrabDevice(
|
||||
Status ret = XIGrabDevice(
|
||||
x11.display,
|
||||
x11.pointerDev,
|
||||
x11.window,
|
||||
|
@ -600,6 +619,12 @@ static void x11GrabPointer(void)
|
|||
false,
|
||||
&mask);
|
||||
|
||||
if (ret != Success)
|
||||
{
|
||||
x11PrintGrabError("pointer", x11.pointerDev, ret);
|
||||
return;
|
||||
}
|
||||
|
||||
XSync(x11.display, False);
|
||||
|
||||
x11.pointerGrabbed = true;
|
||||
|
@ -631,7 +656,7 @@ static void x11GrabKeyboard(void)
|
|||
XISetMask(mask.mask, XI_RawKeyPress );
|
||||
XISetMask(mask.mask, XI_RawKeyRelease);
|
||||
|
||||
XIGrabDevice(
|
||||
Status ret = XIGrabDevice(
|
||||
x11.display,
|
||||
x11.keyboardDev,
|
||||
x11.window,
|
||||
|
@ -642,6 +667,12 @@ static void x11GrabKeyboard(void)
|
|||
false,
|
||||
&mask);
|
||||
|
||||
if (ret != Success)
|
||||
{
|
||||
x11PrintGrabError("keyboard", x11.keyboardDev, ret);
|
||||
return;
|
||||
}
|
||||
|
||||
XSync(x11.display, False);
|
||||
|
||||
x11.keyboardGrabbed = true;
|
||||
|
|
Loading…
Reference in a new issue