From f5220117e970a40c09babe199709bb2db69c4311 Mon Sep 17 00:00:00 2001 From: Povilas Kanapickas Date: Sat, 10 Oct 2020 02:51:39 +0300 Subject: [PATCH] dix: Extract FreezeThisEventIfNeededForSyncGrab() --- dix/events.c | 49 +++++++++++++++++++++++++++++-------------------- include/dix.h | 4 ++++ 2 files changed, 33 insertions(+), 20 deletions(-) diff --git a/dix/events.c b/dix/events.c index 22880008a..1441cff25 100644 --- a/dix/events.c +++ b/dix/events.c @@ -4256,7 +4256,6 @@ DeliverGrabbedEvent(InternalEvent *event, DeviceIntPtr thisDev, GrabPtr grab; GrabInfoPtr grabinfo; int deliveries = 0; - DeviceIntPtr dev; SpritePtr pSprite = thisDev->spriteInfo->sprite; BOOL sendCore = FALSE; @@ -4304,30 +4303,40 @@ DeliverGrabbedEvent(InternalEvent *event, DeviceIntPtr thisDev, event->any.type == ET_KeyRelease || event->any.type == ET_ButtonPress || event->any.type == ET_ButtonRelease)) { - 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; - } + FreezeThisEventIfNeededForSyncGrab(thisDev, event); } 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 is only used when the pressing of keys does not cause the device's processInputProc to be called, as in for example Mouse Keys. diff --git a/include/dix.h b/include/dix.h index 017be8a49..ece8b6f76 100644 --- a/include/dix.h +++ b/include/dix.h @@ -449,6 +449,10 @@ DeliverGrabbedEvent(InternalEvent * /* event */ , DeviceIntPtr /* thisDev */ , Bool /* deactivateGrab */ ); +extern void +FreezeThisEventIfNeededForSyncGrab(DeviceIntPtr thisDev, + InternalEvent *event); + extern void FixKeyState(DeviceEvent * /* event */ , DeviceIntPtr /* keybd */ );