458
440
* Return the single byte of the device's XI2 mask that contains the mask
459
441
* for the event_type.
462
GetXI2MaskByte(unsigned char xi2mask[][XI2MASKSIZE], DeviceIntPtr dev, int event_type)
444
GetXI2MaskByte(XI2Mask *mask, DeviceIntPtr dev, int event_type)
464
int byte = GetXI2EventFilterOffset(event_type);
465
return xi2mask[dev->id][byte] |
466
xi2mask[XIAllDevices][byte] |
467
(IsMaster(dev) ? xi2mask[XIAllMasterDevices][byte] : 0);
446
/* we just return the matching filter because that's the only use
447
* for this mask anyway.
449
if (xi2mask_isset(mask, dev, event_type))
450
return event_get_filter_from_xi2type(event_type);
472
* Return the windows complete XI2 mask for the given XI2 event type.
457
* @return TRUE if the mask is set for this event from this device on the
458
* window, or FALSE otherwise.
475
GetWindowXI2Mask(DeviceIntPtr dev, WindowPtr win, xEvent* ev)
461
WindowXI2MaskIsset(DeviceIntPtr dev, WindowPtr win, xEvent* ev)
477
463
OtherInputMasks *inputMasks = wOtherInputMasks(win);
481
466
if (!inputMasks || xi2_get_type(ev) == 0)
484
469
evtype = ((xGenericEvent*)ev)->evtype;
485
filter = GetEventFilter(dev, ev);
487
return (GetXI2MaskByte(inputMasks->xi2mask, dev, evtype) & filter);
471
return xi2mask_isset(inputMasks->xi2mask, dev, evtype);
1977
1959
ActivateImplicitGrab(DeviceIntPtr dev, ClientPtr client, WindowPtr win,
1978
1960
xEvent *event, Mask deliveryMask)
1981
1963
OtherInputMasks *inputMasks;
1982
1964
CARD8 type = event->u.u.type;
1965
enum InputLevel grabtype;
1985
1967
if (type == ButtonPress)
1986
grabtype = GRABTYPE_CORE;
1987
1969
else if (type == DeviceButtonPress)
1988
grabtype = GRABTYPE_XI;
1989
1971
else if ((type = xi2_get_type(event)) == XI_ButtonPress)
1990
grabtype = GRABTYPE_XI2;
1994
memset(&tempGrab, 0, sizeof(GrabRec));
1995
tempGrab.next = NULL;
1996
tempGrab.device = dev;
1997
tempGrab.resource = client->clientAsMask;
1998
tempGrab.window = win;
1999
tempGrab.ownerEvents = (deliveryMask & OwnerGrabButtonMask) ? TRUE : FALSE;
2000
tempGrab.eventMask = deliveryMask;
2001
tempGrab.keyboardMode = GrabModeAsync;
2002
tempGrab.pointerMode = GrabModeAsync;
2003
tempGrab.confineTo = NullWindow;
2004
tempGrab.cursor = NullCursor;
2005
tempGrab.type = type;
2006
tempGrab.grabtype = grabtype;
1976
tempGrab = AllocGrab();
1979
tempGrab->next = NULL;
1980
tempGrab->device = dev;
1981
tempGrab->resource = client->clientAsMask;
1982
tempGrab->window = win;
1983
tempGrab->ownerEvents = (deliveryMask & OwnerGrabButtonMask) ? TRUE : FALSE;
1984
tempGrab->eventMask = deliveryMask;
1985
tempGrab->keyboardMode = GrabModeAsync;
1986
tempGrab->pointerMode = GrabModeAsync;
1987
tempGrab->confineTo = NullWindow;
1988
tempGrab->cursor = NullCursor;
1989
tempGrab->type = type;
1990
tempGrab->grabtype = grabtype;
2008
1992
/* get the XI and XI2 device mask */
2009
1993
inputMasks = wOtherInputMasks(win);
2010
tempGrab.deviceMask = (inputMasks) ? inputMasks->inputEvents[dev->id]: 0;
1994
tempGrab->deviceMask = (inputMasks) ? inputMasks->inputEvents[dev->id]: 0;
2012
1996
if (inputMasks)
2013
memcpy(tempGrab.xi2mask, inputMasks->xi2mask,
2014
sizeof(tempGrab.xi2mask));
1997
xi2mask_merge(tempGrab->xi2mask, inputMasks->xi2mask);
2016
(*dev->deviceGrab.ActivateGrab)(dev, &tempGrab,
1999
(*dev->deviceGrab.ActivateGrab)(dev, tempGrab,
2017
2000
currentTime, TRUE | ImplicitGrabMask);
2021
enum EventDeliveryState {
2022
EVENT_DELIVERED, /**< Event has been delivered to a client */
2023
EVENT_NOT_DELIVERED, /**< Event was not delivered to any client */
2024
EVENT_SKIP, /**< Event can be discarded by the caller */
2025
EVENT_REJECTED, /**< Event was rejected for delivery to the client */
2029
2006
* Attempt event delivery to the client owning the window.
2577
DeliverEvent(DeviceIntPtr dev, xEvent *xE, int count,
2578
WindowPtr win, Window child, GrabPtr grab)
2580
SpritePtr pSprite = dev->spriteInfo->sprite;
2584
if (XaceHook(XACE_SEND_ACCESS, NULL, dev, win, xE, count) == Success) {
2585
filter = GetEventFilter(dev, xE);
2586
FixUpEventFromWindow(pSprite, xE, win, child, FALSE);
2587
deliveries = DeliverEventsToWindow(dev, win, xE, count,
2595
DeliverOneEvent(InternalEvent *event, DeviceIntPtr dev, enum InputLevel level,
2596
WindowPtr win, Window child, GrabPtr grab)
2606
rc = EventToXI2(event, &xE);
2610
rc = EventToXI(event, &xE, &count);
2613
rc = EventToCore(event, &xE, &count);
2619
deliveries = DeliverEvent(dev, xE, count, win, child, grab);
2622
BUG_WARN_MSG(rc != BadMatch, "%s: conversion to level %d failed with rc %d\n",
2623
dev->name, level, rc);
2603
2628
* Deliver events caused by input devices.
2622
2647
DeliverDeviceEvents(WindowPtr pWin, InternalEvent *event, GrabPtr grab,
2623
2648
WindowPtr stopAt, DeviceIntPtr dev)
2625
SpritePtr pSprite = dev->spriteInfo->sprite;
2626
2650
Window child = None;
2628
2651
int deliveries = 0;
2629
xEvent *xE = NULL, *core = NULL;
2630
int rc, mask, count = 0;
2632
2654
verify_internal_event(event);
2636
if ((mask = EventIsDeliverable(dev, event, pWin)))
2658
if ((mask = EventIsDeliverable(dev, event->any.type, pWin)))
2638
2660
/* XI2 events first */
2639
2661
if (mask & EVENT_XI2_MASK)
2642
rc = EventToXI2(event, &xi2);
2646
filter = GetEventFilter(dev, xi2);
2647
FixUpEventFromWindow(pSprite, xi2, pWin, child, FALSE);
2648
deliveries = DeliverEventsToWindow(dev, pWin, xi2, 1,
2653
} else if (rc != BadMatch)
2654
ErrorF("[dix] %s: XI2 conversion failed in DDE (%d).\n",
2663
deliveries = DeliverOneEvent(event, dev, XI2, pWin, child, grab);
2658
2668
/* XI events */
2659
2669
if (mask & EVENT_XI1_MASK)
2661
rc = EventToXI(event, &xE, &count);
2662
if (rc == Success) {
2663
if (XaceHook(XACE_SEND_ACCESS, NULL, dev, pWin, xE, count) == Success) {
2664
filter = GetEventFilter(dev, xE);
2665
FixUpEventFromWindow(pSprite, xE, pWin, child, FALSE);
2666
deliveries = DeliverEventsToWindow(dev, pWin, xE, count,
2671
} else if (rc != BadMatch)
2672
ErrorF("[dix] %s: XI conversion failed in DDE (%d, %d). Skipping delivery.\n",
2673
dev->name, event->any.type, rc);
2671
deliveries = DeliverOneEvent(event, dev, XI, pWin, child, grab);
2676
2676
/* Core event */
2677
2677
if ((mask & EVENT_CORE_MASK) && IsMaster(dev) && dev->coreEvents)
2679
rc = EventToCore(event, &core, &count);
2680
if (rc == Success) {
2681
if (XaceHook(XACE_SEND_ACCESS, NULL, dev, pWin, core, count) == Success) {
2682
filter = GetEventFilter(dev, core);
2683
FixUpEventFromWindow(pSprite, core, pWin, child, FALSE);
2684
deliveries = DeliverEventsToWindow(dev, pWin, core,
2685
count, filter, grab);
2689
} else if (rc != BadMatch)
2690
ErrorF("[dix] %s: Core conversion failed in DDE (%d, %d).\n",
2691
dev->name, event->any.type, rc);
2694
if ((deliveries < 0) || (pWin == stopAt) ||
2695
(mask & EVENT_DONT_PROPAGATE_MASK))
2679
deliveries = DeliverOneEvent(event, dev, CORE, pWin, child, grab);
2686
if ((deliveries < 0) || (pWin == stopAt) ||
2687
(mask & EVENT_DONT_PROPAGATE_MASK))
2702
2693
child = pWin->drawable.id;
2703
2694
pWin = pWin->parent;
2709
2697
return deliveries;
3627
* Activate the given passive grab. If the grab is activated successfully, the
3628
* event has been delivered to the client.
3630
* @param device The device of the event to check.
3631
* @param grab The grab to check.
3632
* @param event The current device event.
3634
* @return Whether the grab has been activated.
3637
ActivatePassiveGrab(DeviceIntPtr device, GrabPtr grab, InternalEvent *event)
3639
SpritePtr pSprite = device->spriteInfo->sprite;
3640
GrabInfoPtr grabinfo = &device->deviceGrab;
3645
/* The only consumers of corestate are Xi 1.x and core events, which
3646
* are guaranteed to come from DeviceEvents. */
3647
if (grab->grabtype == XI || grab->grabtype == CORE)
3651
event->device_event.corestate &= 0x1f00;
3653
if (grab->grabtype == CORE)
3654
gdev = GetMaster(device, KEYBOARD_OR_FLOAT);
3656
gdev = grab->modifierDevice;
3658
if (gdev && gdev->key && gdev->key->xkbInfo)
3659
event->device_event.corestate |=
3660
gdev->key->xkbInfo->state.grab_mods & (~0x1f00);
3663
if (grab->grabtype == CORE)
3665
rc = EventToCore(event, &xE, &count);
3668
BUG_WARN_MSG(rc != BadMatch,"[dix] %s: core conversion failed"
3669
"(%d, %d).\n", device->name, event->any.type, rc);
3672
} else if (grab->grabtype == XI2)
3674
rc = EventToXI2(event, &xE);
3678
BUG_WARN_MSG(rc != BadMatch,"[dix] %s: XI2 conversion failed"
3679
"(%d, %d).\n", device->name, event->any.type, rc);
3685
rc = EventToXI(event, &xE, &count);
3689
BUG_WARN_MSG(rc != BadMatch,"[dix] %s: XI conversion failed"
3690
"(%d, %d).\n", device->name, event->any.type, rc);
3695
(*grabinfo->ActivateGrab)(device, grab, currentTime, TRUE);
3699
FixUpEventFromWindow(pSprite, xE, grab->window, None, TRUE);
3702
TryClientEvents(rClient(grab), device, xE, count,
3703
GetEventFilter(device, xE),
3704
GetEventFilter(device, xE), grab);
3707
if (grabinfo->sync.state == FROZEN_NO_EVENT)
3708
grabinfo->sync.state = FROZEN_WITH_EVENT;
3709
*grabinfo->sync.event = event->device_event;
3716
CoreGrabInterferes(DeviceIntPtr device, GrabPtr grab)
3719
BOOL interfering = FALSE;
3721
for (other = inputInfo.devices; other; other = other->next)
3723
GrabPtr othergrab = other->deviceGrab.grab;
3724
if (othergrab && othergrab->grabtype == CORE &&
3725
SameClient(grab, rClient(othergrab)) &&
3726
((IsPointerDevice(grab->device) &&
3727
IsPointerDevice(othergrab->device)) ||
3728
(IsKeyboardDevice(grab->device) &&
3729
IsKeyboardDevice(othergrab->device))))
3747
* Match the grab against the temporary grab on the given input level.
3748
* Modifies the temporary grab pointer.
3750
* @param grab The grab to match against
3751
* @param tmp The temporary grab to use for matching
3752
* @param level The input level we want to match on
3753
* @param event_type Wire protocol event type
3755
* @return The respective matched flag or 0 for no match
3757
static enum MatchFlags
3758
MatchForType(const GrabPtr grab, GrabPtr tmp, enum InputLevel level, int event_type)
3760
enum MatchFlags match;
3761
BOOL ignore_device = FALSE;
3769
evtype = GetXI2Type(event_type);
3775
evtype = GetXIType(event_type);
3780
evtype = GetCoreType(event_type);
3782
ignore_device = TRUE;
3786
tmp->grabtype = grabtype;
3789
if (tmp->type && GrabMatchesSecond(tmp, grab, ignore_device))
3796
* Check an individual grab against an event to determine if a passive grab
3797
* should be activated.
3799
* @param device The device of the event to check.
3800
* @param grab The grab to check.
3801
* @param event The current device event.
3802
* @param checkCore Check for core grabs too.
3803
* @param tempGrab A pre-allocated temporary grab record for matching. This
3804
* must have the window and device values filled in.
3806
* @return Whether the grab matches the event.
3809
CheckPassiveGrab(DeviceIntPtr device, GrabPtr grab, InternalEvent *event,
3810
Bool checkCore, GrabPtr tempGrab)
3813
XkbSrvInfoPtr xkbi = NULL;
3814
enum MatchFlags match = 0;
3816
gdev = grab->modifierDevice;
3817
if (grab->grabtype == CORE)
3819
gdev = GetMaster(device, KEYBOARD_OR_FLOAT);
3820
} else if (grab->grabtype == XI2)
3822
/* if the device is an attached slave device, gdev must be the
3823
* attached master keyboard. Since the slave may have been
3824
* reattached after the grab, the modifier device may not be the
3826
if (!IsMaster(grab->device) && !IsFloating(device))
3827
gdev = GetMaster(device, MASTER_KEYBOARD);
3830
if (gdev && gdev->key)
3831
xkbi= gdev->key->xkbInfo;
3832
tempGrab->modifierDevice = grab->modifierDevice;
3833
tempGrab->modifiersDetail.exact = xkbi ? xkbi->state.grab_mods : 0;
3835
/* Check for XI2 and XI grabs first */
3836
match = MatchForType(grab, tempGrab, XI2, GetXI2Type(event->any.type));
3839
match = MatchForType(grab, tempGrab, XI, GetXIType(event->any.type));
3841
if (!match && checkCore)
3842
match = MatchForType(grab, tempGrab, CORE, GetCoreType(event->any.type));
3844
if (!match || (grab->confineTo &&
3845
(!grab->confineTo->realized ||
3846
!BorderSizeNotEmpty(device, grab->confineTo))))
3849
/* In some cases a passive core grab may exist, but the client
3850
* already has a core grab on some other device. In this case we
3851
* must not get the grab, otherwise we may never ungrab the
3855
if (grab->grabtype == CORE)
3857
/* A passive grab may have been created for a different device
3858
than it is assigned to at this point in time.
3859
Update the grab's device and modifier device to reflect the
3861
Since XGrabDeviceButton requires to specify the
3862
modifierDevice explicitly, we don't override this choice.
3864
if (grab->type < GenericEvent)
3866
grab->device = device;
3867
grab->modifierDevice = GetMaster(device, MASTER_KEYBOARD);
3870
if (CoreGrabInterferes(device, grab))
3639
3878
* "CheckPassiveGrabsOnWindow" checks to see if the event passed in causes a
3640
3879
* passive grab set on the window to be activated.
3641
3880
* If activate is true and a passive grab is found, it will be activated,
3656
3895
BOOL checkCore,
3659
SpritePtr pSprite = device->spriteInfo->sprite;
3660
3898
GrabPtr grab = wPassiveGrabs(pWin);
3662
GrabInfoPtr grabinfo;
3663
#define CORE_MATCH 0x1
3664
#define XI_MATCH 0x2
3665
#define XI2_MATCH 0x4
3904
tempGrab = AllocGrab();
3670
3906
/* Fill out the grab details, but leave the type for later before
3672
3908
switch (event->any.type)
3674
3910
case ET_KeyPress:
3675
3911
case ET_KeyRelease:
3676
tempGrab.detail.exact = event->device_event.detail.key;
3912
tempGrab->detail.exact = event->device_event.detail.key;
3678
3914
case ET_ButtonPress:
3679
3915
case ET_ButtonRelease:
3680
tempGrab.detail.exact = event->device_event.detail.button;
3916
tempGrab->detail.exact = event->device_event.detail.button;
3683
tempGrab.detail.exact = 0;
3919
tempGrab->detail.exact = 0;
3686
tempGrab.window = pWin;
3687
tempGrab.device = device;
3688
tempGrab.detail.pMask = NULL;
3689
tempGrab.modifiersDetail.pMask = NULL;
3690
tempGrab.next = NULL;
3922
tempGrab->window = pWin;
3923
tempGrab->device = device;
3924
tempGrab->detail.pMask = NULL;
3925
tempGrab->modifiersDetail.pMask = NULL;
3926
tempGrab->next = NULL;
3691
3928
for (; grab; grab = grab->next)
3694
XkbSrvInfoPtr xkbi = NULL;
3698
gdev= grab->modifierDevice;
3699
if (grab->grabtype == GRABTYPE_CORE)
3701
gdev = GetMaster(device, KEYBOARD_OR_FLOAT);
3702
} else if (grab->grabtype == GRABTYPE_XI2)
3704
/* if the device is an attached slave device, gdev must be the
3705
* attached master keyboard. Since the slave may have been
3706
* reattached after the grab, the modifier device may not be the
3708
if (!IsMaster(grab->device) && !IsFloating(device))
3709
gdev = GetMaster(device, MASTER_KEYBOARD);
3713
if (gdev && gdev->key)
3714
xkbi= gdev->key->xkbInfo;
3715
tempGrab.modifierDevice = grab->modifierDevice;
3716
tempGrab.modifiersDetail.exact = xkbi ? xkbi->state.grab_mods : 0;
3718
/* Check for XI2 and XI grabs first */
3719
tempGrab.type = GetXI2Type(event);
3720
tempGrab.grabtype = GRABTYPE_XI2;
3721
if (GrabMatchesSecond(&tempGrab, grab, FALSE))
3726
tempGrab.grabtype = GRABTYPE_XI;
3727
if ((tempGrab.type = GetXIType(event)) &&
3728
(GrabMatchesSecond(&tempGrab, grab, FALSE)))
3732
/* Check for a core grab (ignore the device when comparing) */
3733
if (!match && checkCore)
3735
tempGrab.grabtype = GRABTYPE_CORE;
3736
if ((tempGrab.type = GetCoreType(event)) &&
3737
(GrabMatchesSecond(&tempGrab, grab, TRUE)))
3741
if (!match || (grab->confineTo &&
3742
(!grab->confineTo->realized ||
3743
!BorderSizeNotEmpty(device, grab->confineTo))))
3746
grabinfo = &device->deviceGrab;
3747
/* In some cases a passive core grab may exist, but the client
3748
* already has a core grab on some other device. In this case we
3749
* must not get the grab, otherwise we may never ungrab the
3753
if (grab->grabtype == GRABTYPE_CORE)
3756
BOOL interfering = FALSE;
3758
/* A passive grab may have been created for a different device
3759
than it is assigned to at this point in time.
3760
Update the grab's device and modifier device to reflect the
3762
Since XGrabDeviceButton requires to specify the
3763
modifierDevice explicitly, we don't override this choice.
3765
if (tempGrab.type < GenericEvent)
3767
grab->device = device;
3768
grab->modifierDevice = GetMaster(device, MASTER_KEYBOARD);
3771
for (other = inputInfo.devices; other; other = other->next)
3773
GrabPtr othergrab = other->deviceGrab.grab;
3774
if (othergrab && othergrab->grabtype == GRABTYPE_CORE &&
3775
SameClient(grab, rClient(othergrab)) &&
3776
((IsPointerDevice(grab->device) &&
3777
IsPointerDevice(othergrab->device)) ||
3778
(IsKeyboardDevice(grab->device) &&
3779
IsKeyboardDevice(othergrab->device))))
3793
else if (!GetXIType(event) && !GetCoreType(event))
3795
ErrorF("Event type %d in CheckPassiveGrabsOnWindow is neither"
3796
" XI 1.x nor core\n", event->any.type);
3800
/* The only consumers of corestate are Xi 1.x and core events, which
3801
* are guaranteed to come from DeviceEvents. */
3802
if (match & (XI_MATCH | CORE_MATCH))
3804
event->device_event.corestate &= 0x1f00;
3805
event->device_event.corestate |= tempGrab.modifiersDetail.exact &
3809
if (match & CORE_MATCH)
3811
rc = EventToCore(event, &xE, &count);
3815
ErrorF("[dix] %s: core conversion failed in CPGFW "
3816
"(%d, %d).\n", device->name, event->any.type, rc);
3819
} else if (match & XI2_MATCH)
3821
rc = EventToXI2(event, &xE);
3825
ErrorF("[dix] %s: XI2 conversion failed in CPGFW "
3826
"(%d, %d).\n", device->name, event->any.type, rc);
3832
rc = EventToXI(event, &xE, &count);
3836
ErrorF("[dix] %s: XI conversion failed in CPGFW "
3837
"(%d, %d).\n", device->name, event->any.type, rc);
3842
(*grabinfo->ActivateGrab)(device, grab, currentTime, TRUE);
3846
FixUpEventFromWindow(pSprite, xE, grab->window, None, TRUE);
3849
TryClientEvents(rClient(grab), device, xE, count,
3850
GetEventFilter(device, xE),
3851
GetEventFilter(device, xE), grab);
3854
if (grabinfo->sync.state == FROZEN_NO_EVENT)
3856
if (!grabinfo->sync.event)
3857
grabinfo->sync.event = calloc(1, sizeof(DeviceEvent));
3858
*grabinfo->sync.event = event->device_event;
3859
grabinfo->sync.state = FROZEN_WITH_EVENT;
3930
if (!CheckPassiveGrab(device, grab, event, checkCore, tempGrab))
3933
if (activate && !ActivatePassiveGrab(device, grab, event))
4128
DeliverOneGrabbedEvent(InternalEvent *event, DeviceIntPtr dev, enum InputLevel level)
4130
SpritePtr pSprite = dev->spriteInfo->sprite;
4136
GrabInfoPtr grabinfo = &dev->deviceGrab;
4137
GrabPtr grab = grabinfo->grab;
4143
rc = EventToXI2(event, &xE);
4147
int evtype = xi2_get_type(xE);
4148
mask = xi2mask_isset(grab->xi2mask, dev, evtype);
4153
if (grabinfo->fromPassiveGrab && grabinfo->implicitGrab)
4154
mask = grab->deviceMask;
4156
mask = grab->eventMask;
4157
rc = EventToXI(event, &xE, &count);
4159
filter = GetEventFilter(dev, xE);
4162
rc = EventToCore(event, &xE, &count);
4163
mask = grab->eventMask;
4165
filter = GetEventFilter(dev, xE);
4168
BUG_WARN_MSG(1, "Invalid input level %d\n", level);
4174
FixUpEventFromWindow(pSprite, xE, grab->window, None, TRUE);
4175
if (XaceHook(XACE_SEND_ACCESS, 0, dev,
4176
grab->window, xE, count) ||
4177
XaceHook(XACE_RECEIVE_ACCESS, rClient(grab),
4178
grab->window, xE, count))
4179
deliveries = 1; /* don't send, but pretend we did */
4180
else if (level != CORE || !IsInterferingGrab(rClient(grab), dev, xE))
4182
deliveries = TryClientEvents(rClient(grab), dev,
4183
xE, count, mask, filter,
4187
BUG_WARN_MSG(rc != BadMatch, "%s: conversion to mode %d failed on %d with %d\n",
4188
dev->name, level, event->any.type, rc);
4055
4196
* Deliver an event from a device that is currently grabbed. Uses
4056
4197
* DeliverDeviceEvents() for further delivery if a ownerEvents is set on the
4098
4236
focus = PointerRootWin;
4099
4237
if (focus == PointerRootWin)
4100
deliveries = DeliverDeviceEvents(pSprite->win, event, grab,
4101
NullWindow, thisDev);
4102
else if (focus && (focus == pSprite->win ||
4103
IsParent(focus, pSprite->win)))
4104
deliveries = DeliverDeviceEvents(pSprite->win, event, grab, focus,
4241
} else if (focus && (focus == pSprite->win ||
4242
IsParent(focus, pSprite->win)))
4106
4244
else if (focus)
4107
deliveries = DeliverDeviceEvents(focus, event, grab, focus,
4247
deliveries = DeliverDeviceEvents(win, event, grab, focus, thisDev);
4110
4249
if (!deliveries)
4114
4251
/* XXX: In theory, we could pass the internal events through to
4115
4252
* everything and only convert just before hitting the wire. We can't
4116
4253
* do that yet, so DGE is the last stop for internal events. From here
4117
4254
* onwards, we deal with core/XI events.
4120
mask = grab->eventMask;
4122
4257
sendCore = (IsMaster(thisDev) && thisDev->coreEvents);
4123
4258
/* try core event */
4124
if (sendCore && grab->grabtype == GRABTYPE_CORE)
4126
rc = EventToCore(event, &core, &count);
4129
FixUpEventFromWindow(pSprite, core, grab->window, None, TRUE);
4130
if (XaceHook(XACE_SEND_ACCESS, 0, thisDev,
4131
grab->window, core, count) ||
4132
XaceHook(XACE_RECEIVE_ACCESS, rClient(grab),
4133
grab->window, core, count))
4134
deliveries = 1; /* don't send, but pretend we did */
4135
else if (!IsInterferingGrab(rClient(grab), thisDev, core))
4137
deliveries = TryClientEvents(rClient(grab), thisDev,
4139
GetEventFilter(thisDev, core),
4142
} else if (rc != BadMatch)
4143
ErrorF("[dix] DeliverGrabbedEvent. Core conversion failed.\n");
4148
rc = EventToXI2(event, &xi2);
4151
int evtype = xi2_get_type(xi2);
4152
mask = GetXI2MaskByte(grab->xi2mask, thisDev, evtype);
4154
FixUpEventFromWindow(pSprite, xi2, grab->window, None, TRUE);
4156
deliveries = TryClientEvents(rClient(grab), thisDev, xi2, 1, mask,
4157
GetEventFilter(thisDev, xi2), grab);
4158
} else if (rc != BadMatch)
4159
ErrorF("[dix] %s: XI2 conversion failed in DGE (%d, %d). Skipping delivery.\n",
4160
thisDev->name, event->any.type, rc);
4165
rc = EventToXI(event, &xi, &count);
4169
if (grabinfo->fromPassiveGrab &&
4170
grabinfo->implicitGrab)
4171
mask = grab->deviceMask;
4173
mask = grab->eventMask;
4175
FixUpEventFromWindow(pSprite, xi, grab->window, None, TRUE);
4177
if (XaceHook(XACE_SEND_ACCESS, 0, thisDev,
4178
grab->window, xi, count) ||
4179
XaceHook(XACE_RECEIVE_ACCESS, rClient(grab),
4180
grab->window, xi, count))
4181
deliveries = 1; /* don't send, but pretend we did */
4185
TryClientEvents(rClient(grab), thisDev,
4188
GetEventFilter(thisDev, xi),
4191
} else if (rc != BadMatch)
4192
ErrorF("[dix] %s: XI conversion failed in DGE (%d, %d). Skipping delivery.\n",
4193
thisDev->name, event->any.type, rc);
4259
if (sendCore && grab->grabtype == CORE)
4261
deliveries = DeliverOneGrabbedEvent(event, thisDev, CORE);
4266
deliveries = DeliverOneGrabbedEvent(event, thisDev, XI2);
4271
deliveries = DeliverOneGrabbedEvent(event, thisDev, XI);
4196
4274
if (deliveries && (event->any.type == ET_Motion))
5079
5150
*status = GrabFrozen;
5084
/* Otherwise segfaults happen on grabbed MPX devices */
5085
memset(&tempGrab, 0, sizeof(GrabRec));
5087
tempGrab.next = NULL;
5088
tempGrab.window = pWin;
5089
tempGrab.resource = client->clientAsMask;
5090
tempGrab.ownerEvents = ownerEvents;
5091
tempGrab.keyboardMode = keyboard_mode;
5092
tempGrab.pointerMode = pointer_mode;
5093
if (grabtype == GRABTYPE_CORE)
5094
tempGrab.eventMask = mask->core;
5095
else if (grabtype == GRABTYPE_XI)
5096
tempGrab.eventMask = mask->xi;
5155
tempGrab = AllocGrab();
5157
tempGrab->next = NULL;
5158
tempGrab->window = pWin;
5159
tempGrab->resource = client->clientAsMask;
5160
tempGrab->ownerEvents = ownerEvents;
5161
tempGrab->keyboardMode = keyboard_mode;
5162
tempGrab->pointerMode = pointer_mode;
5163
if (grabtype == CORE)
5164
tempGrab->eventMask = mask->core;
5165
else if (grabtype == XI)
5166
tempGrab->eventMask = mask->xi;
5098
memcpy(tempGrab.xi2mask, mask->xi2mask, sizeof(tempGrab.xi2mask));
5099
tempGrab.device = dev;
5100
tempGrab.cursor = cursor;
5101
tempGrab.confineTo = confineTo;
5102
tempGrab.grabtype = grabtype;
5103
(*grabInfo->ActivateGrab)(dev, &tempGrab, time, FALSE);
5168
xi2mask_merge(tempGrab->xi2mask, mask->xi2mask);
5169
tempGrab->device = dev;
5170
tempGrab->cursor = cursor;
5171
tempGrab->confineTo = confineTo;
5172
tempGrab->grabtype = grabtype;
5173
(*grabInfo->ActivateGrab)(dev, tempGrab, time, FALSE);
5104
5174
*status = GrabSuccess;
5106
5178
return Success;