dix: Extract FreezeThisEventIfNeededForSyncGrab()

This commit is contained in:
Povilas Kanapickas 2020-10-10 02:51:39 +03:00 committed by Peter Hutterer
parent 36f8dacc06
commit f5220117e9
2 changed files with 33 additions and 20 deletions

View File

@ -4256,7 +4256,6 @@ DeliverGrabbedEvent(InternalEvent *event, DeviceIntPtr thisDev,
GrabPtr grab; GrabPtr grab;
GrabInfoPtr grabinfo; GrabInfoPtr grabinfo;
int deliveries = 0; int deliveries = 0;
DeviceIntPtr dev;
SpritePtr pSprite = thisDev->spriteInfo->sprite; SpritePtr pSprite = thisDev->spriteInfo->sprite;
BOOL sendCore = FALSE; BOOL sendCore = FALSE;
@ -4304,30 +4303,40 @@ DeliverGrabbedEvent(InternalEvent *event, DeviceIntPtr thisDev,
event->any.type == ET_KeyRelease || event->any.type == ET_KeyRelease ||
event->any.type == ET_ButtonPress || event->any.type == ET_ButtonPress ||
event->any.type == ET_ButtonRelease)) { event->any.type == ET_ButtonRelease)) {
switch (grabinfo->sync.state) { FreezeThisEventIfNeededForSyncGrab(thisDev, event);
case FREEZE_BOTH_NEXT_EVENT:
dev = GetPairedDevice(thisDev);
if (dev) {
FreezeThaw(dev, TRUE);
if ((dev->deviceGrab.sync.state == FREEZE_BOTH_NEXT_EVENT) &&
(CLIENT_BITS(grab->resource) ==
CLIENT_BITS(dev->deviceGrab.grab->resource)))
dev->deviceGrab.sync.state = FROZEN_NO_EVENT;
else
dev->deviceGrab.sync.other = grab;
}
/* fall through */
case FREEZE_NEXT_EVENT:
grabinfo->sync.state = FROZEN_WITH_EVENT;
FreezeThaw(thisDev, TRUE);
*grabinfo->sync.event = *event;
break;
}
} }
return deliveries; return deliveries;
} }
void
FreezeThisEventIfNeededForSyncGrab(DeviceIntPtr thisDev, InternalEvent *event)
{
GrabInfoPtr grabinfo = &thisDev->deviceGrab;
GrabPtr grab = grabinfo->grab;
DeviceIntPtr dev;
switch (grabinfo->sync.state) {
case FREEZE_BOTH_NEXT_EVENT:
dev = GetPairedDevice(thisDev);
if (dev) {
FreezeThaw(dev, TRUE);
if ((dev->deviceGrab.sync.state == FREEZE_BOTH_NEXT_EVENT) &&
(CLIENT_BITS(grab->resource) ==
CLIENT_BITS(dev->deviceGrab.grab->resource)))
dev->deviceGrab.sync.state = FROZEN_NO_EVENT;
else
dev->deviceGrab.sync.other = grab;
}
/* fall through */
case FREEZE_NEXT_EVENT:
grabinfo->sync.state = FROZEN_WITH_EVENT;
FreezeThaw(thisDev, TRUE);
*grabinfo->sync.event = *event;
break;
}
}
/* This function is used to set the key pressed or key released state - /* This function is used to set the key pressed or key released state -
this is only used when the pressing of keys does not cause this is only used when the pressing of keys does not cause
the device's processInputProc to be called, as in for example Mouse Keys. the device's processInputProc to be called, as in for example Mouse Keys.

View File

@ -449,6 +449,10 @@ DeliverGrabbedEvent(InternalEvent * /* event */ ,
DeviceIntPtr /* thisDev */ , DeviceIntPtr /* thisDev */ ,
Bool /* deactivateGrab */ ); Bool /* deactivateGrab */ );
extern void
FreezeThisEventIfNeededForSyncGrab(DeviceIntPtr thisDev,
InternalEvent *event);
extern void extern void
FixKeyState(DeviceEvent * /* event */ , FixKeyState(DeviceEvent * /* event */ ,
DeviceIntPtr /* keybd */ ); DeviceIntPtr /* keybd */ );