Lines Matching +full:unmapped +full:- +full:event +full:- +full:sources

16 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
38 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
63 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
77 * Copyright (c) 2003-2005, Oracle and/or its affiliates. All rights reserved.
92 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
100 * This file handles event delivery and a big part of the server-side protocol
105 #include <dix-config.h>
172 #define AllEventMasks (LastEventMask|(LastEventMask-1))
174 /* @return the core event type or 0 if the event is not a core event */
176 core_get_type(const xEvent *event) in core_get_type() argument
178 int type = event->u.u.type; in core_get_type()
183 /* @return the XI2 event type or 0 if the event is not a XI2 event */
185 xi2_get_type(const xEvent *event) in xi2_get_type() argument
187 const xGenericEvent *e = (const xGenericEvent *) event; in xi2_get_type()
189 return (e->type != GenericEvent || in xi2_get_type()
190 e->extension != IReqCode) ? 0 : e->evtype; in xi2_get_type()
194 * Used to indicate a implicit passive grab created by a ButtonPress event.
199 #define WID(w) ((w) ? ((w)->drawable.id) : 0)
201 #define XE_KBPTR (xE->u.keyButtonPointer)
218 xEvent *event);
221 extern BOOL EventIsKeyRepeat(xEvent *event);
267 #define RootWindow(sprite) sprite->spriteTrace[0]
279 * Convert the given event type from an XI event to a core event.
280 * @param[in] The XI 1.x event type.
281 * @return The matching core event type or 0 if there is none.
309 return pDev->spriteInfo->spriteOwner; in DevHasCursor()
319 return (dev->type == MASTER_POINTER) || in IsPointerDevice()
320 (dev->valuator && dev->button) || (dev->valuator && !dev->key); in IsPointerDevice()
333 return (dev->type == MASTER_KEYBOARD) || in IsKeyboardDevice()
334 ((dev->key && dev->kbdfeed) && !IsPointerDevice(dev)); in IsKeyboardDevice()
340 return dev->type == MASTER_POINTER || dev->type == MASTER_KEYBOARD; in IsMaster()
350 * Max event opcode.
356 * Event masks for each event type.
361 * Filters are used whether a given event may be delivered to a client,
362 * usually in the form of if (window-event-mask & filter); then deliver event.
409 * For the given event, return the matching event filter. This filter may then
410 * be AND'ed with the selected event mask.
412 * For XI2 events, the returned filter is simply the byte containing the event
416 * @param[in] dev The device the event belongs to, may be NULL.
417 * @param[in] event The event to get the filter for. Only the type of the
418 * event matters, or the extension + evtype for GenericEvents.
419 * @return The filter mask for the given event.
424 GetEventFilter(DeviceIntPtr dev, xEvent *event) in GetEventFilter() argument
428 if (event->u.u.type != GenericEvent) in GetEventFilter()
429 return event_get_filter_from_type(dev, event->u.u.type); in GetEventFilter()
430 else if ((evtype = xi2_get_type(event))) in GetEventFilter()
432 ErrorF("[dix] Unknown event type %d. No filter\n", event->u.u.type); in GetEventFilter()
453 * @return TRUE if the mask is set for this event from this device on the
465 evtype = ((xGenericEvent *) ev)->evtype; in WindowXI2MaskIsset()
467 return xi2mask_isset(inputMasks->xi2mask, dev, evtype); in WindowXI2MaskIsset()
471 GetEventMask(DeviceIntPtr dev, xEvent *event, InputClients * other) in GetEventMask() argument
476 if ((evtype = xi2_get_type(event))) { in GetEventMask()
477 return GetXI2MaskByte(other->xi2mask, dev, evtype); in GetEventMask()
479 else if (core_get_type(event) != 0) in GetEventMask()
480 return other->mask[XIAllDevices]; in GetEventMask()
482 return other->mask[dev->id]; in GetEventMask()
496 screenno = dev->spriteInfo->sprite->screen->myNum; in SyntheticMotion()
512 SpritePtr pSprite = pDev->spriteInfo->sprite; in XineramaSetCursorPosition()
518 pScreen = pSprite->screen; in XineramaSetCursorPosition()
519 x += screenInfo.screens[0]->x; in XineramaSetCursorPosition()
520 y += screenInfo.screens[0]->y; in XineramaSetCursorPosition()
524 if (i == pScreen->myNum) in XineramaSetCursorPosition()
533 pSprite->screen = pScreen; in XineramaSetCursorPosition()
534 pSprite->hotPhys.x = x - screenInfo.screens[0]->x; in XineramaSetCursorPosition()
535 pSprite->hotPhys.y = y - screenInfo.screens[0]->y; in XineramaSetCursorPosition()
536 x -= pScreen->x; in XineramaSetCursorPosition()
537 y -= pScreen->y; in XineramaSetCursorPosition()
539 return (*pScreen->SetCursorPosition) (pDev, pScreen, x, y, generateEvent); in XineramaSetCursorPosition()
545 SpritePtr pSprite = pDev->spriteInfo->sprite; in XineramaConstrainCursor()
549 pScreen = pSprite->screen; in XineramaConstrainCursor()
550 newBox = pSprite->physLimits; in XineramaConstrainCursor()
554 newBox.x1 += screenInfo.screens[0]->x - pScreen->x; in XineramaConstrainCursor()
555 newBox.x2 += screenInfo.screens[0]->x - pScreen->x; in XineramaConstrainCursor()
556 newBox.y1 += screenInfo.screens[0]->y - pScreen->y; in XineramaConstrainCursor()
557 newBox.y2 += screenInfo.screens[0]->y - pScreen->y; in XineramaConstrainCursor()
559 (*pScreen->ConstrainCursor) (pDev, pScreen, &newBox); in XineramaConstrainCursor()
565 SpritePtr pSprite = pDev->spriteInfo->sprite; in XineramaSetWindowPntrs()
567 if (pWin == screenInfo.screens[0]->root) { in XineramaSetWindowPntrs()
571 pSprite->windows[i] = screenInfo.screens[i]->root; in XineramaSetWindowPntrs()
577 rc = dixLookupResourceByType((void **) &win, pWin->drawable.id, in XineramaSetWindowPntrs()
583 rc = dixLookupWindow(pSprite->windows + i, win->info[i].id, in XineramaSetWindowPntrs()
585 if (rc != Success) /* window is being unmapped */ in XineramaSetWindowPntrs()
596 SpritePtr pSprite = pDev->spriteInfo->sprite; in XineramaConfineCursorToWindow()
605 i = PanoramiXNumScreens - 1; in XineramaConfineCursorToWindow()
607 RegionCopy(&pSprite->Reg1, &pSprite->windows[i]->borderSize); in XineramaConfineCursorToWindow()
608 off_x = screenInfo.screens[i]->x; in XineramaConfineCursorToWindow()
609 off_y = screenInfo.screens[i]->y; in XineramaConfineCursorToWindow()
611 while (i--) { in XineramaConfineCursorToWindow()
612 x = off_x - screenInfo.screens[i]->x; in XineramaConfineCursorToWindow()
613 y = off_y - screenInfo.screens[i]->y; in XineramaConfineCursorToWindow()
616 RegionTranslate(&pSprite->Reg1, x, y); in XineramaConfineCursorToWindow()
618 RegionUnion(&pSprite->Reg1, &pSprite->Reg1, in XineramaConfineCursorToWindow()
619 &pSprite->windows[i]->borderSize); in XineramaConfineCursorToWindow()
621 off_x = screenInfo.screens[i]->x; in XineramaConfineCursorToWindow()
622 off_y = screenInfo.screens[i]->y; in XineramaConfineCursorToWindow()
625 pSprite->hotLimits = *RegionExtents(&pSprite->Reg1); in XineramaConfineCursorToWindow()
627 if (RegionNumRects(&pSprite->Reg1) > 1) in XineramaConfineCursorToWindow()
628 pSprite->hotShape = &pSprite->Reg1; in XineramaConfineCursorToWindow()
630 pSprite->hotShape = NullRegion; in XineramaConfineCursorToWindow()
632 pSprite->confined = FALSE; in XineramaConfineCursorToWindow()
633 pSprite->confineWin = in XineramaConfineCursorToWindow()
634 (pWin == screenInfo.screens[0]->root) ? NullWindow : pWin; in XineramaConfineCursorToWindow()
636 CheckPhysLimits(pDev, pSprite->current, generateEvents, FALSE, NULL); in XineramaConfineCursorToWindow()
642 * Modifies the filter for the given protocol event type to the given masks.
645 * The latter initialises masks for the matching XI events, it's a once-off
653 * @param[in] event Protocol event type.
656 SetMaskForEvent(int deviceid, Mask mask, int event) in SetMaskForEvent() argument
660 event_filters[deviceid][event] = mask; in SetMaskForEvent()
664 SetCriticalEvent(int event) in SetCriticalEvent() argument
666 if (event >= MAXEVENTS) in SetCriticalEvent()
667 FatalError("SetCriticalEvent: bogus event number"); in SetCriticalEvent()
668 criticalEvents[event >> 3] |= 1 << (event & 7); in SetCriticalEvent()
685 incx = -1; in ConfineToShape()
686 x = *px - 1; in ConfineToShape()
693 incy = -1; in ConfineToShape()
694 y = *py - 1; in ConfineToShape()
710 SpritePtr pSprite = pDev->spriteInfo->sprite; in CheckPhysLimits()
714 new = pSprite->hotPhys; in CheckPhysLimits()
718 pSprite->physLimits = pSprite->hotLimits; in CheckPhysLimits()
726 (*pScreen->CursorLimits) (pDev, pScreen, cursor, &pSprite->hotLimits, in CheckPhysLimits()
727 &pSprite->physLimits); in CheckPhysLimits()
728 pSprite->confined = confineToScreen; in CheckPhysLimits()
729 (*pScreen->ConstrainCursor) (pDev, pScreen, &pSprite->physLimits); in CheckPhysLimits()
733 if (new.x < pSprite->physLimits.x1) in CheckPhysLimits()
734 new.x = pSprite->physLimits.x1; in CheckPhysLimits()
735 else if (new.x >= pSprite->physLimits.x2) in CheckPhysLimits()
736 new.x = pSprite->physLimits.x2 - 1; in CheckPhysLimits()
737 if (new.y < pSprite->physLimits.y1) in CheckPhysLimits()
738 new.y = pSprite->physLimits.y1; in CheckPhysLimits()
739 else if (new.y >= pSprite->physLimits.y2) in CheckPhysLimits()
740 new.y = pSprite->physLimits.y2 - 1; in CheckPhysLimits()
741 if (pSprite->hotShape) in CheckPhysLimits()
742 ConfineToShape(pDev, pSprite->hotShape, &new.x, &new.y); in CheckPhysLimits()
747 (pScreen != pSprite->hotPhys.pScreen)) || in CheckPhysLimits()
748 (new.x != pSprite->hotPhys.x) || (new.y != pSprite->hotPhys.y)) { in CheckPhysLimits()
755 if (pScreen != pSprite->hotPhys.pScreen) in CheckPhysLimits()
756 pSprite->hotPhys = new; in CheckPhysLimits()
757 (*pScreen->SetCursorPosition) in CheckPhysLimits()
774 SpritePtr pSprite = pDev->spriteInfo->sprite; in CheckVirtualMotion()
779 ev = &qe->event->device_event; in CheckVirtualMotion()
780 switch (ev->type) { in CheckVirtualMotion()
788 pSprite->hot.pScreen = qe->pScreen; in CheckVirtualMotion()
789 pSprite->hot.x = ev->root_x; in CheckVirtualMotion()
790 pSprite->hot.y = ev->root_y; in CheckVirtualMotion()
792 pDev->deviceGrab.grab ? pDev->deviceGrab.grab-> in CheckVirtualMotion()
809 i = PanoramiXNumScreens - 1; in CheckVirtualMotion()
811 RegionCopy(&pSprite->Reg2, &pSprite->windows[i]->borderSize); in CheckVirtualMotion()
812 off_x = screenInfo.screens[i]->x; in CheckVirtualMotion()
813 off_y = screenInfo.screens[i]->y; in CheckVirtualMotion()
815 while (i--) { in CheckVirtualMotion()
816 x = off_x - screenInfo.screens[i]->x; in CheckVirtualMotion()
817 y = off_y - screenInfo.screens[i]->y; in CheckVirtualMotion()
820 RegionTranslate(&pSprite->Reg2, x, y); in CheckVirtualMotion()
822 RegionUnion(&pSprite->Reg2, &pSprite->Reg2, in CheckVirtualMotion()
823 &pSprite->windows[i]->borderSize); in CheckVirtualMotion()
825 off_x = screenInfo.screens[i]->x; in CheckVirtualMotion()
826 off_y = screenInfo.screens[i]->y; in CheckVirtualMotion()
832 if (pSprite->hot.pScreen != pWin->drawable.pScreen) { in CheckVirtualMotion()
833 pSprite->hot.pScreen = pWin->drawable.pScreen; in CheckVirtualMotion()
834 pSprite->hot.x = pSprite->hot.y = 0; in CheckVirtualMotion()
838 lims = *RegionExtents(&pWin->borderSize); in CheckVirtualMotion()
839 if (pSprite->hot.x < lims.x1) in CheckVirtualMotion()
840 pSprite->hot.x = lims.x1; in CheckVirtualMotion()
841 else if (pSprite->hot.x >= lims.x2) in CheckVirtualMotion()
842 pSprite->hot.x = lims.x2 - 1; in CheckVirtualMotion()
843 if (pSprite->hot.y < lims.y1) in CheckVirtualMotion()
844 pSprite->hot.y = lims.y1; in CheckVirtualMotion()
845 else if (pSprite->hot.y >= lims.y2) in CheckVirtualMotion()
846 pSprite->hot.y = lims.y2 - 1; in CheckVirtualMotion()
850 if (RegionNumRects(&pSprite->Reg2) > 1) in CheckVirtualMotion()
851 reg = &pSprite->Reg2; in CheckVirtualMotion()
858 reg = &pWin->borderSize; in CheckVirtualMotion()
862 ConfineToShape(pDev, reg, &pSprite->hot.x, &pSprite->hot.y); in CheckVirtualMotion()
865 qe->pScreen = pSprite->hot.pScreen; in CheckVirtualMotion()
866 ev->root_x = pSprite->hot.x; in CheckVirtualMotion()
867 ev->root_y = pSprite->hot.y; in CheckVirtualMotion()
873 RootWindow(pDev->spriteInfo->sprite) = pSprite->hot.pScreen->root; in CheckVirtualMotion()
880 SpritePtr pSprite = pDev->spriteInfo->sprite; in ConfineCursorToWindow()
884 SyntheticMotion(pDev, pSprite->hot.x, pSprite->hot.y); in ConfineCursorToWindow()
887 ScreenPtr pScreen = pWin->drawable.pScreen; in ConfineCursorToWindow()
895 pSprite->hotLimits = *RegionExtents(&pWin->borderSize); in ConfineCursorToWindow()
896 pSprite->hotShape = wBoundingShape(pWin) ? &pWin->borderSize in ConfineCursorToWindow()
898 CheckPhysLimits(pDev, pSprite->current, generateEvents, in ConfineCursorToWindow()
899 confineToScreen, pWin->drawable.pScreen); in ConfineCursorToWindow()
901 if (*pScreen->CursorConfinedTo) in ConfineCursorToWindow()
902 (*pScreen->CursorConfinedTo) (pDev, pScreen, pWin); in ConfineCursorToWindow()
909 return pDev->spriteInfo->sprite->confined; in PointerConfinedToScreen()
922 SpritePtr pSprite = pDev->spriteInfo->sprite; in ChangeToCursor()
925 if (cursor != pSprite->current) { in ChangeToCursor()
926 if ((pSprite->current->bits->xhot != cursor->bits->xhot) || in ChangeToCursor()
927 (pSprite->current->bits->yhot != cursor->bits->yhot)) in ChangeToCursor()
928 CheckPhysLimits(pDev, cursor, FALSE, pSprite->confined, in ChangeToCursor()
933 pScreen = pSprite->screen; in ChangeToCursor()
936 pScreen = pSprite->hotPhys.pScreen; in ChangeToCursor()
938 (*pScreen->DisplayCursor) (pDev, pScreen, cursor); in ChangeToCursor()
939 FreeCursor(pSprite->current, (Cursor) 0); in ChangeToCursor()
940 pSprite->current = RefCursor(cursor); in ChangeToCursor()
950 for (b = b->parent; b; b = b->parent) in IsParent()
965 GrabPtr grab = pDev->deviceGrab.grab; in PostNewCursor()
966 SpritePtr pSprite = pDev->spriteInfo->sprite; in PostNewCursor()
972 if (grab->cursor) { in PostNewCursor()
973 ChangeToCursor(pDev, grab->cursor); in PostNewCursor()
976 if (IsParent(grab->window, pSprite->win)) in PostNewCursor()
977 win = pSprite->win; in PostNewCursor()
979 win = grab->window; in PostNewCursor()
982 win = pSprite->win; in PostNewCursor()
983 for (; win; win = win->parent) { in PostNewCursor()
984 if (win->optional) { in PostNewCursor()
986 if (!pCursor && win->optional->cursor != NullCursor) in PostNewCursor()
987 pCursor = win->optional->cursor; in PostNewCursor()
1003 return RootWindow(dev->spriteInfo->sprite); in GetCurrentRootWindow()
1012 return pDev->spriteInfo->sprite->win; in GetSpriteWindow()
1021 return pDev->spriteInfo->sprite->current; in GetSpriteCursor()
1030 SpritePtr pSprite = pDev->spriteInfo->sprite; in GetSpritePosition()
1032 *px = pSprite->hotPhys.x; in GetSpritePosition()
1033 *py = pSprite->hotPhys.y; in GetSpritePosition()
1041 return pDev->spriteInfo->sprite->screen->myNum; in XineramaGetCursorScreen()
1055 * different sources in sorted order, then it's possible for time to go in MonthChangedOrBadTime()
1058 if ((currentTime.milliseconds - *ms) > TIMESLOP) in MonthChangedOrBadTime()
1069 lastDeviceEventTime[dev->id].time = currentTime; in NoticeTime()
1071 LastEventTimeToggleResetFlag(dev->id, TRUE); in NoticeTime()
1090 NoticeTimeMillis(dev, &ev->any.time); in NoticeEventTime()
1116 LastEventTimeToggleResetFlag(dev->id, FALSE); in LastEventTimeToggleResetAll()
1128 * Instead of delivering the events to the client, the event is tacked onto a
1136 SpritePtr pSprite = device->spriteInfo->sprite; in EnqueueEvent()
1138 DeviceEvent *event = &ev->device_event; in EnqueueEvent() local
1143 NoticeTimeMillis(device, &ev->any.time); in EnqueueEvent()
1146 if (device->key != NULL && device->key->xkbInfo != NULL && in EnqueueEvent()
1147 event->type == ET_KeyRelease) in EnqueueEvent()
1148 AccessXCancelRepeatKey(device->key->xkbInfo, event->detail.key); in EnqueueEvent()
1157 * GetCurrentRootWindow()->drawable.id doesn't give you the right in EnqueueEvent()
1158 * answer on the first motion event after a screen change because in EnqueueEvent()
1162 if (ev->any.type == ET_Motion) in EnqueueEvent()
1163 ev->device_event.root = pSprite->hotPhys.pScreen->root->drawable.id; in EnqueueEvent()
1165 eventinfo.event = ev; in EnqueueEvent()
1170 if (event->type == ET_Motion) { in EnqueueEvent()
1173 event->root_x += pSprite->screen->x - screenInfo.screens[0]->x; in EnqueueEvent()
1174 event->root_y += pSprite->screen->y - screenInfo.screens[0]->y; in EnqueueEvent()
1177 pSprite->hotPhys.x = event->root_x; in EnqueueEvent()
1178 pSprite->hotPhys.y = event->root_y; in EnqueueEvent()
1181 (tail->event->any.type == ET_Motion) && in EnqueueEvent()
1182 (tail->device == device) && in EnqueueEvent()
1183 (tail->pScreen == pSprite->hotPhys.pScreen)) { in EnqueueEvent()
1184 DeviceEvent *tailev = &tail->event->device_event; in EnqueueEvent()
1186 tailev->root_x = pSprite->hotPhys.x; in EnqueueEvent()
1187 tailev->root_y = pSprite->hotPhys.y; in EnqueueEvent()
1188 tailev->time = event->time; in EnqueueEvent()
1189 tail->months = currentTime.months; in EnqueueEvent()
1194 eventlen = event->length; in EnqueueEvent()
1199 xorg_list_init(&qe->next); in EnqueueEvent()
1200 qe->device = device; in EnqueueEvent()
1201 qe->pScreen = pSprite->hotPhys.pScreen; in EnqueueEvent()
1202 qe->months = currentTime.months; in EnqueueEvent()
1203 qe->event = (InternalEvent *) (qe + 1); in EnqueueEvent()
1204 memcpy(qe->event, event, eventlen); in EnqueueEvent()
1205 xorg_list_append(&qe->next, &syncEvents.pending); in EnqueueEvent()
1210 * For each event do:
1211 * If the device for this event is not frozen anymore, take it and process it
1215 * frozen, then re-run from the beginning of the event queue.
1227 if (!qe->device->deviceGrab.sync.frozen) { in PlayReleasedEvents()
1228 xorg_list_del(&qe->next); in PlayReleasedEvents()
1229 pDev = qe->device; in PlayReleasedEvents()
1230 if (qe->event->any.type == ET_Motion) in PlayReleasedEvents()
1232 syncEvents.time.months = qe->months; in PlayReleasedEvents()
1233 syncEvents.time.milliseconds = qe->event->any.time; in PlayReleasedEvents()
1239 DeviceEvent *ev = &qe->event->device_event; in PlayReleasedEvents()
1241 switch (ev->type) { in PlayReleasedEvents()
1252 ev->root_x += screenInfo.screens[0]->x - in PlayReleasedEvents()
1253 pDev->spriteInfo->sprite->screen->x; in PlayReleasedEvents()
1254 ev->root_y += screenInfo.screens[0]->y - in PlayReleasedEvents()
1255 pDev->spriteInfo->sprite->screen->y; in PlayReleasedEvents()
1263 (*qe->device->public.processInputProc) (qe->event, qe->device); in PlayReleasedEvents()
1265 for (dev = inputInfo.devices; dev && dev->deviceGrab.sync.frozen; in PlayReleasedEvents()
1266 dev = dev->next); in PlayReleasedEvents()
1270 /* Playing the event may have unfrozen another device. */ in PlayReleasedEvents()
1288 dev->deviceGrab.sync.frozen = frozen; in FreezeThaw()
1290 dev->public.processInputProc = dev->public.enqueueInputProc; in FreezeThaw()
1292 dev->public.processInputProc = dev->public.realInputProc; in FreezeThaw()
1298 * ComputeFreezes takes the first event in the device's frozen event queue. It
1311 for (dev = inputInfo.devices; dev; dev = dev->next) in ComputeFreezes()
1312 FreezeThaw(dev, dev->deviceGrab.sync.other || in ComputeFreezes()
1313 (dev->deviceGrab.sync.state >= FROZEN)); in ComputeFreezes()
1319 DeviceEvent *event = replayDev->deviceGrab.sync.event; in ComputeFreezes() local
1323 w = XYToWindow(replayDev->spriteInfo->sprite, in ComputeFreezes()
1324 event->root_x, event->root_y); in ComputeFreezes()
1325 if (!CheckDeviceGrabs(replayDev, event, syncEvents.replayWin)) { in ComputeFreezes()
1326 if (IsTouchEvent((InternalEvent *) event)) { in ComputeFreezes()
1328 TouchFindByClientID(replayDev, event->touchid); in ComputeFreezes()
1333 else if (replayDev->focus && in ComputeFreezes()
1334 !IsPointerEvent((InternalEvent *) event)) in ComputeFreezes()
1335 DeliverFocusedEvent(replayDev, (InternalEvent *) event, w); in ComputeFreezes()
1337 DeliverDeviceEvents(w, (InternalEvent *) event, NullGrab, in ComputeFreezes()
1341 for (dev = inputInfo.devices; dev; dev = dev->next) { in ComputeFreezes()
1342 if (!dev->deviceGrab.sync.frozen) { in ComputeFreezes()
1348 for (dev = inputInfo.devices; dev; dev = dev->next) { in ComputeFreezes()
1352 if ((grab = dev->deviceGrab.grab) && grab->confineTo) { in ComputeFreezes()
1353 if (grab->confineTo->drawable.pScreen != in ComputeFreezes()
1354 dev->spriteInfo->sprite->hotPhys.pScreen) in ComputeFreezes()
1355 dev->spriteInfo->sprite->hotPhys.x = in ComputeFreezes()
1356 dev->spriteInfo->sprite->hotPhys.y = 0; in ComputeFreezes()
1357 ConfineCursorToWindow(dev, grab->confineTo, TRUE, TRUE); in ComputeFreezes()
1361 dev->spriteInfo->sprite->hotPhys.pScreen-> in ComputeFreezes()
1375 for (pDev = inputInfo.devices; pDev; pDev = pDev->next) { in ScreenRestructured()
1381 if ((grab = pDev->deviceGrab.grab) && grab->confineTo) { in ScreenRestructured()
1382 if (grab->confineTo->drawable.pScreen in ScreenRestructured()
1383 != pDev->spriteInfo->sprite->hotPhys.pScreen) in ScreenRestructured()
1384 pDev->spriteInfo->sprite->hotPhys.x = in ScreenRestructured()
1385 pDev->spriteInfo->sprite->hotPhys.y = 0; in ScreenRestructured()
1386 ConfineCursorToWindow(pDev, grab->confineTo, TRUE, TRUE); in ScreenRestructured()
1390 pDev->spriteInfo->sprite->hotPhys.pScreen-> in ScreenRestructured()
1399 GrabPtr grab = thisDev->deviceGrab.grab; in CheckGrabForSyncs()
1403 thisDev->deviceGrab.sync.state = FROZEN_NO_EVENT; in CheckGrabForSyncs()
1405 thisDev->deviceGrab.sync.state = THAWED; in CheckGrabForSyncs()
1406 if (thisDev->deviceGrab.sync.other && in CheckGrabForSyncs()
1407 (CLIENT_BITS(thisDev->deviceGrab.sync.other->resource) == in CheckGrabForSyncs()
1408 CLIENT_BITS(grab->resource))) in CheckGrabForSyncs()
1409 thisDev->deviceGrab.sync.other = NullGrab; in CheckGrabForSyncs()
1415 dev->deviceGrab.sync.other = grab; in CheckGrabForSyncs()
1417 if (dev->deviceGrab.sync.other && in CheckGrabForSyncs()
1418 (CLIENT_BITS(dev->deviceGrab.sync.other->resource) == in CheckGrabForSyncs()
1419 CLIENT_BITS(grab->resource))) in CheckGrabForSyncs()
1420 dev->deviceGrab.sync.other = NullGrab; in CheckGrabForSyncs()
1429 * the duration of the grab, the device is detached, ungrabbing re-attaches it
1441 dev->saved_master_id = GetMaster(dev, MASTER_ATTACHED)->id; in DetachFromMaster()
1454 dixLookupDevice(&master, dev->saved_master_id, serverClient, DixUseAccess); in ReattachToOldMaster()
1458 dev->saved_master_id = 0; in ReattachToOldMaster()
1471 if (!mouse->touch || mouse->deviceGrab.fromPassiveGrab) in UpdateTouchesForGrab()
1474 for (i = 0; i < mouse->touch->num_touches; i++) { in UpdateTouchesForGrab()
1475 TouchPointInfoPtr ti = mouse->touch->touches + i; in UpdateTouchesForGrab()
1476 TouchListener *listener = &ti->listeners[0]; in UpdateTouchesForGrab()
1477 GrabPtr grab = mouse->deviceGrab.grab; in UpdateTouchesForGrab()
1479 if (ti->active && in UpdateTouchesForGrab()
1480 CLIENT_BITS(listener->listener) == grab->resource) { in UpdateTouchesForGrab()
1481 listener->listener = grab->resource; in UpdateTouchesForGrab()
1482 listener->level = grab->grabtype; in UpdateTouchesForGrab()
1483 listener->state = LISTENER_IS_OWNER; in UpdateTouchesForGrab()
1484 listener->window = grab->window; in UpdateTouchesForGrab()
1486 if (grab->grabtype == CORE || grab->grabtype == XI || in UpdateTouchesForGrab()
1487 !xi2mask_isset(grab->xi2mask, mouse, XI_TouchBegin)) in UpdateTouchesForGrab()
1488 listener->type = LISTENER_POINTER_GRAB; in UpdateTouchesForGrab()
1490 listener->type = LISTENER_GRAB; in UpdateTouchesForGrab()
1491 if (listener->grab) in UpdateTouchesForGrab()
1492 FreeGrab(listener->grab); in UpdateTouchesForGrab()
1493 listener->grab = AllocGrab(grab); in UpdateTouchesForGrab()
1506 * is an implicit grab caused by a ButtonPress event.
1510 * @param autoGrab True if the grab was caused by a button down event and not
1517 GrabInfoPtr grabinfo = &mouse->deviceGrab; in ActivatePointerGrab()
1518 GrabPtr oldgrab = grabinfo->grab; in ActivatePointerGrab()
1519 WindowPtr oldWin = (grabinfo->grab) ? in ActivatePointerGrab()
1520 grabinfo->grab->window : mouse->spriteInfo->sprite->win; in ActivatePointerGrab()
1524 if (grab->grabtype == XI2 && in ActivatePointerGrab()
1528 if (grab->confineTo) { in ActivatePointerGrab()
1529 if (grab->confineTo->drawable.pScreen in ActivatePointerGrab()
1530 != mouse->spriteInfo->sprite->hotPhys.pScreen) in ActivatePointerGrab()
1531 mouse->spriteInfo->sprite->hotPhys.x = in ActivatePointerGrab()
1532 mouse->spriteInfo->sprite->hotPhys.y = 0; in ActivatePointerGrab()
1533 ConfineCursorToWindow(mouse, grab->confineTo, FALSE, TRUE); in ActivatePointerGrab()
1535 if (! (grabinfo->grab && oldWin == grabinfo->grab->window in ActivatePointerGrab()
1536 && oldWin == grab->window)) in ActivatePointerGrab()
1537 DoEnterLeaveEvents(mouse, mouse->id, oldWin, grab->window, NotifyGrab); in ActivatePointerGrab()
1538 mouse->valuator->motionHintWindow = NullWindow; in ActivatePointerGrab()
1540 grabinfo->grabTime = syncEvents.time; in ActivatePointerGrab()
1542 grabinfo->grabTime = time; in ActivatePointerGrab()
1543 grabinfo->grab = AllocGrab(grab); in ActivatePointerGrab()
1544 grabinfo->fromPassiveGrab = isPassive; in ActivatePointerGrab()
1545 grabinfo->implicitGrab = autoGrab & ImplicitGrabMask; in ActivatePointerGrab()
1548 CheckGrabForSyncs(mouse, (Bool) grab->pointerMode, in ActivatePointerGrab()
1549 (Bool) grab->keyboardMode); in ActivatePointerGrab()
1562 GrabPtr grab = mouse->deviceGrab.grab; in DeactivatePointerGrab()
1564 Bool wasPassive = mouse->deviceGrab.fromPassiveGrab; in DeactivatePointerGrab()
1565 Bool wasImplicit = (mouse->deviceGrab.fromPassiveGrab && in DeactivatePointerGrab()
1566 mouse->deviceGrab.implicitGrab); in DeactivatePointerGrab()
1567 XID grab_resource = grab->resource; in DeactivatePointerGrab()
1572 for (i = 0; !wasPassive && mouse->touch && i < mouse->touch->num_touches; i++) { in DeactivatePointerGrab()
1573 TouchPointInfoPtr ti = mouse->touch->touches + i; in DeactivatePointerGrab()
1574 if (ti->active && TouchResourceIsOwner(ti, grab_resource)) { in DeactivatePointerGrab()
1578 already has the end event */ in DeactivatePointerGrab()
1579 if (grab->grabtype == CORE || grab->grabtype == XI || in DeactivatePointerGrab()
1580 !xi2mask_isset(mouse->deviceGrab.grab->xi2mask, mouse, XI_TouchBegin)) { in DeactivatePointerGrab()
1586 ti->listeners[0].state = LISTENER_HAS_END; in DeactivatePointerGrab()
1594 mouse->valuator->motionHintWindow = NullWindow; in DeactivatePointerGrab()
1595 mouse->deviceGrab.grab = NullGrab; in DeactivatePointerGrab()
1596 mouse->deviceGrab.sync.state = NOT_GRABBED; in DeactivatePointerGrab()
1597 mouse->deviceGrab.fromPassiveGrab = FALSE; in DeactivatePointerGrab()
1599 for (dev = inputInfo.devices; dev; dev = dev->next) { in DeactivatePointerGrab()
1600 if (dev->deviceGrab.sync.other == grab) in DeactivatePointerGrab()
1601 dev->deviceGrab.sync.other = NullGrab; in DeactivatePointerGrab()
1603 DoEnterLeaveEvents(mouse, mouse->id, grab->window, in DeactivatePointerGrab()
1604 mouse->spriteInfo->sprite->win, NotifyUngrab); in DeactivatePointerGrab()
1605 if (grab->confineTo) in DeactivatePointerGrab()
1609 if (!wasImplicit && grab->grabtype == XI2) in DeactivatePointerGrab()
1626 GrabInfoPtr grabinfo = &keybd->deviceGrab; in ActivateKeyboardGrab()
1627 GrabPtr oldgrab = grabinfo->grab; in ActivateKeyboardGrab()
1631 if (grab->grabtype == XI2 && keybd->enabled && in ActivateKeyboardGrab()
1635 if (!keybd->enabled) in ActivateKeyboardGrab()
1637 else if (grabinfo->grab) in ActivateKeyboardGrab()
1638 oldWin = grabinfo->grab->window; in ActivateKeyboardGrab()
1639 else if (keybd->focus) in ActivateKeyboardGrab()
1640 oldWin = keybd->focus->win; in ActivateKeyboardGrab()
1642 oldWin = keybd->spriteInfo->sprite->win; in ActivateKeyboardGrab()
1644 oldWin = keybd->focus->win; in ActivateKeyboardGrab()
1645 if (keybd->valuator) in ActivateKeyboardGrab()
1646 keybd->valuator->motionHintWindow = NullWindow; in ActivateKeyboardGrab()
1648 ! (grabinfo->grab && oldWin == grabinfo->grab->window in ActivateKeyboardGrab()
1649 && oldWin == grab->window)) in ActivateKeyboardGrab()
1650 DoFocusEvents(keybd, oldWin, grab->window, NotifyGrab); in ActivateKeyboardGrab()
1652 grabinfo->grabTime = syncEvents.time; in ActivateKeyboardGrab()
1654 grabinfo->grabTime = time; in ActivateKeyboardGrab()
1655 grabinfo->grab = AllocGrab(grab); in ActivateKeyboardGrab()
1656 grabinfo->fromPassiveGrab = passive; in ActivateKeyboardGrab()
1657 grabinfo->implicitGrab = passive & ImplicitGrabMask; in ActivateKeyboardGrab()
1658 CheckGrabForSyncs(keybd, (Bool) grab->keyboardMode, in ActivateKeyboardGrab()
1659 (Bool) grab->pointerMode); in ActivateKeyboardGrab()
1670 GrabPtr grab = keybd->deviceGrab.grab; in DeactivateKeyboardGrab()
1673 Bool wasImplicit = (keybd->deviceGrab.fromPassiveGrab && in DeactivateKeyboardGrab()
1674 keybd->deviceGrab.implicitGrab); in DeactivateKeyboardGrab()
1676 if (keybd->valuator) in DeactivateKeyboardGrab()
1677 keybd->valuator->motionHintWindow = NullWindow; in DeactivateKeyboardGrab()
1678 keybd->deviceGrab.grab = NullGrab; in DeactivateKeyboardGrab()
1679 keybd->deviceGrab.sync.state = NOT_GRABBED; in DeactivateKeyboardGrab()
1680 keybd->deviceGrab.fromPassiveGrab = FALSE; in DeactivateKeyboardGrab()
1682 for (dev = inputInfo.devices; dev; dev = dev->next) { in DeactivateKeyboardGrab()
1683 if (dev->deviceGrab.sync.other == grab) in DeactivateKeyboardGrab()
1684 dev->deviceGrab.sync.other = NullGrab; in DeactivateKeyboardGrab()
1687 if (keybd->focus) in DeactivateKeyboardGrab()
1688 focusWin = keybd->focus->win; in DeactivateKeyboardGrab()
1689 else if (keybd->spriteInfo->sprite) in DeactivateKeyboardGrab()
1690 focusWin = keybd->spriteInfo->sprite->win; in DeactivateKeyboardGrab()
1695 focusWin = inputInfo.keyboard->focus->win; in DeactivateKeyboardGrab()
1697 DoFocusEvents(keybd, grab->window, focusWin, NotifyUngrab); in DeactivateKeyboardGrab()
1699 if (!wasImplicit && grab->grabtype == XI2) in DeactivateKeyboardGrab()
1713 GrabInfoPtr devgrabinfo, grabinfo = &thisDev->deviceGrab; in AllowSome()
1715 thisGrabbed = grabinfo->grab && SameClient(grabinfo->grab, client); in AllowSome()
1719 grabTime = grabinfo->grabTime; in AllowSome()
1720 for (dev = inputInfo.devices; dev; dev = dev->next) { in AllowSome()
1721 devgrabinfo = &dev->deviceGrab; in AllowSome()
1725 if (devgrabinfo->grab && SameClient(devgrabinfo->grab, client)) { in AllowSome()
1727 (CompareTimeStamps(devgrabinfo->grabTime, grabTime) == LATER)) in AllowSome()
1728 grabTime = devgrabinfo->grabTime; in AllowSome()
1730 if (grabinfo->sync.other == devgrabinfo->grab) in AllowSome()
1732 if (devgrabinfo->sync.state >= FROZEN) in AllowSome()
1736 if (!((thisGrabbed && grabinfo->sync.state >= FROZEN) || thisSynced)) in AllowSome()
1744 grabinfo->sync.state = THAWED; in AllowSome()
1746 grabinfo->sync.other = NullGrab; in AllowSome()
1751 grabinfo->sync.state = FREEZE_NEXT_EVENT; in AllowSome()
1753 grabinfo->sync.other = NullGrab; in AllowSome()
1759 for (dev = inputInfo.devices; dev; dev = dev->next) { in AllowSome()
1760 devgrabinfo = &dev->deviceGrab; in AllowSome()
1761 if (devgrabinfo->grab && SameClient(devgrabinfo->grab, client)) in AllowSome()
1762 devgrabinfo->sync.state = THAWED; in AllowSome()
1763 if (devgrabinfo->sync.other && in AllowSome()
1764 SameClient(devgrabinfo->sync.other, client)) in AllowSome()
1765 devgrabinfo->sync.other = NullGrab; in AllowSome()
1772 for (dev = inputInfo.devices; dev; dev = dev->next) { in AllowSome()
1773 devgrabinfo = &dev->deviceGrab; in AllowSome()
1774 if (devgrabinfo->grab && SameClient(devgrabinfo->grab, client)) in AllowSome()
1775 devgrabinfo->sync.state = FREEZE_BOTH_NEXT_EVENT; in AllowSome()
1776 if (devgrabinfo->sync.other in AllowSome()
1777 && SameClient(devgrabinfo->sync.other, client)) in AllowSome()
1778 devgrabinfo->sync.other = NullGrab; in AllowSome()
1784 if (thisGrabbed && grabinfo->sync.state == FROZEN_WITH_EVENT) { in AllowSome()
1786 grabinfo->sync.other = NullGrab; in AllowSome()
1788 syncEvents.replayWin = grabinfo->grab->window; in AllowSome()
1789 (*grabinfo->DeactivateGrab) (thisDev); in AllowSome()
1795 for (dev = inputInfo.devices; dev; dev = dev->next) { in AllowSome()
1798 devgrabinfo = &dev->deviceGrab; in AllowSome()
1799 if (devgrabinfo->grab && SameClient(devgrabinfo->grab, client)) in AllowSome()
1800 devgrabinfo->sync.state = THAWED; in AllowSome()
1801 if (devgrabinfo->sync.other in AllowSome()
1802 && SameClient(devgrabinfo->sync.other, client)) in AllowSome()
1803 devgrabinfo->sync.other = NullGrab; in AllowSome()
1816 IsTouchEvent((InternalEvent*)grabinfo->sync.event)) { in AllowSome()
1817 TouchAcceptAndEnd(thisDev, grabinfo->sync.event->touchid); in AllowSome()
1822 * Server-side protocol handling for AllowEvents request.
1837 time = ClientTimeToServerTime(stuff->time); in ProcAllowEvents()
1842 switch (stuff->mode) { in ProcAllowEvents()
1868 client->errorValue = stuff->mode; in ProcAllowEvents()
1888 for (dev = inputInfo.devices; dev; dev = dev->next) { in ReleaseActiveGrabs()
1889 if (dev->deviceGrab.grab && in ReleaseActiveGrabs()
1890 SameClient(dev->deviceGrab.grab, client)) { in ReleaseActiveGrabs()
1891 (*dev->deviceGrab.DeactivateGrab) (dev); in ReleaseActiveGrabs()
1905 * More than one event may be delivered at a time. This is the case with
1911 * An event is only delivered if
1912 * - mask and filter match up.
1913 * - no other client has a grab on the device that caused the event.
1917 * @param dev The device the event came from. May be NULL.
1920 * @param mask Event mask as set by the window.
1921 * @param filter Mask based on event type.
1922 * @param grab Possible grab on the device that caused the event.
1924 * @return 1 if event was delivered, 0 if not or -1 if grab was not set by the
1934 ErrorF("[dix] Event([%d, %d], mask=0x%lx), client=%d%s", in TryClientEvents()
1935 pEvents->u.u.type, pEvents->u.u.detail, mask, in TryClientEvents()
1936 client ? client->index : -1, in TryClientEvents()
1937 (client && client->clientGone) ? " (gone)" : ""); in TryClientEvents()
1940 if (!client || client == serverClient || client->clientGone) { in TryClientEvents()
1958 return -1; /* don't send, but notify caller */ in TryClientEvents()
1961 type = pEvents->u.u.type; in TryClientEvents()
1964 if (WID(dev->valuator->motionHintWindow) == in TryClientEvents()
1965 pEvents->u.keyButtonPointer.event) { in TryClientEvents()
1968 ErrorF("[dix] motionHintWindow == keyButtonPointer.event\n"); in TryClientEvents()
1972 pEvents->u.u.detail = NotifyHint; in TryClientEvents()
1975 pEvents->u.u.detail = NotifyNormal; in TryClientEvents()
2022 if (client->smart_priority < SMART_MAX_PRIORITY) in TryClientEvents()
2023 client->smart_priority++; in TryClientEvents()
2036 xEvent *event, Mask deliveryMask) in ActivateImplicitGrab() argument
2040 CARD8 type = event->u.u.type; in ActivateImplicitGrab()
2047 else if ((type = xi2_get_type(event)) == XI_ButtonPress) in ActivateImplicitGrab()
2055 tempGrab->next = NULL; in ActivateImplicitGrab()
2056 tempGrab->device = dev; in ActivateImplicitGrab()
2057 tempGrab->resource = client->clientAsMask; in ActivateImplicitGrab()
2058 tempGrab->window = win; in ActivateImplicitGrab()
2059 tempGrab->ownerEvents = (deliveryMask & OwnerGrabButtonMask) ? TRUE : FALSE; in ActivateImplicitGrab()
2060 tempGrab->eventMask = deliveryMask; in ActivateImplicitGrab()
2061 tempGrab->keyboardMode = GrabModeAsync; in ActivateImplicitGrab()
2062 tempGrab->pointerMode = GrabModeAsync; in ActivateImplicitGrab()
2063 tempGrab->confineTo = NullWindow; in ActivateImplicitGrab()
2064 tempGrab->cursor = NullCursor; in ActivateImplicitGrab()
2065 tempGrab->type = type; in ActivateImplicitGrab()
2066 tempGrab->grabtype = grabtype; in ActivateImplicitGrab()
2070 tempGrab->deviceMask = (inputMasks) ? inputMasks->inputEvents[dev->id] : 0; in ActivateImplicitGrab()
2073 xi2mask_merge(tempGrab->xi2mask, inputMasks->xi2mask); in ActivateImplicitGrab()
2075 (*dev->deviceGrab.ActivateGrab) (dev, tempGrab, in ActivateImplicitGrab()
2082 * Attempt event delivery to the client owning the window.
2088 /* if nobody ever wants to see this event, skip some work */ in DeliverToWindowOwner()
2090 !((wOtherEventMasks(win) | win->eventMask) & filter)) in DeliverToWindowOwner()
2098 count, win->eventMask, in DeliverToWindowOwner()
2111 * Get the list of clients that should be tried for event delivery on the
2114 * @return 1 if the client list should be traversed, zero if the event
2128 /* Has any client selected for the event? */ in GetClientsForDelivery()
2131 *iclients = inputMasks->inputClients; in GetClientsForDelivery()
2136 /* Has any client selected for the event? */ in GetClientsForDelivery()
2137 if (!inputMasks || !(inputMasks->inputEvents[dev->id] & filter)) in GetClientsForDelivery()
2140 *iclients = inputMasks->inputClients; in GetClientsForDelivery()
2149 * Try delivery on each client in inputclients, provided the event mask
2162 for (; inputclients; inputclients = inputclients->next) { in DeliverEventToInputClients()
2189 /* Success overrides non-success, so if we've been in DeliverEventToInputClients()
2206 * @param mask_return On successful delivery, set to the recipient's event
2207 * mask for this event.
2225 * Deliver events to a window. At this point, we do not yet know if the event
2226 * actually needs to be delivered. May activate a grab if the event is a
2230 * something other than CantBeFiltered, the event is also delivered to other
2233 * More than one event may be delivered at a time. This is the case with
2236 * @param pWin The window that would get the event.
2239 * @param filter Mask based on event type.
2240 * @param grab Possible grab on the device that caused the event.
2243 * made, 0 if no events were delivered, or a negative number if the event
2254 int type = pEvents->u.u.type; in DeliverEventsToWindow()
2266 nondeliveries--; in DeliverEventsToWindow()
2269 /* We delivered to the owner, with our event mask */ in DeliverEventsToWindow()
2272 deliveryMask = pWin->eventMask; in DeliverEventsToWindow()
2279 /* CantBeFiltered means only window owner gets the event */ in DeliverEventsToWindow()
2290 nondeliveries--; in DeliverEventsToWindow()
2309 pDev->valuator->motionHintWindow = pWin; in DeliverEventsToWindow()
2325 * @return TRUE if the event should be discarded, FALSE otherwise.
2333 /* device not grabbed -> don't filter */ in FilterRawEvents()
2338 dixLookupPrivate(&client->devPrivates, XIClientPrivateKey); in FilterRawEvents()
2340 cmp = version_compare(client_xi_version->major_version, in FilterRawEvents()
2341 client_xi_version->minor_version, 2, 0); in FilterRawEvents()
2347 return (grab->window != root) ? FALSE : SameClient(grab, client); in FilterRawEvents()
2351 * Deliver a raw event to the grab owner (if any) and to all root windows.
2353 * Raw event delivery differs between XI 2.0 and XI 2.1.
2362 GrabPtr grab = device->deviceGrab.grab; in DeliverRawEvent()
2370 __func__, device->name, rc); in DeliverRawEvent()
2383 root = screenInfo.screens[i]->root; in DeliverRawEvent()
2387 for (; inputclients; inputclients = inputclients->next) { in DeliverRawEvent()
2409 /* If the event goes to dontClient, don't send it and return 0. if
2419 if ((client) && (client != serverClient) && (!client->clientGone) && in XineramaTryClientEventsResult()
2422 return -1; in XineramaTryClientEventsResult()
2433 * @param pWin The window that would get the event.
2436 * @param filter Mask based on event type.
2445 if (pWin->eventMask & filter) { in MaybeDeliverEventsToClient()
2449 if (!noPanoramiXExtension && pWin->drawable.pScreen->myNum) in MaybeDeliverEventsToClient()
2451 pWin->eventMask, filter); in MaybeDeliverEventsToClient()
2456 pWin->eventMask, filter, NullGrab); in MaybeDeliverEventsToClient()
2458 for (other = wOtherClients(pWin); other; other = other->next) { in MaybeDeliverEventsToClient()
2459 if (other->mask & filter) { in MaybeDeliverEventsToClient()
2463 if (!noPanoramiXExtension && pWin->drawable.pScreen->myNum) in MaybeDeliverEventsToClient()
2465 other->mask, filter); in MaybeDeliverEventsToClient()
2471 other->mask, filter, NullGrab); in MaybeDeliverEventsToClient()
2478 FindChildForEvent(SpritePtr pSprite, WindowPtr event) in FindChildForEvent() argument
2488 /* If the source window is same as event window, child should be in FindChildForEvent()
2491 if (w == event) { in FindChildForEvent()
2496 if (w->parent == event) { in FindChildForEvent()
2497 child = w->drawable.id; in FindChildForEvent()
2500 w = w->parent; in FindChildForEvent()
2506 * Adjust event fields to comply with the window properties.
2508 * @param xE Event to be modified in place
2510 * @param child Child window setting for event (if applicable)
2523 xXIDeviceEvent *event = (xXIDeviceEvent *) xE; in FixUpEventFromWindow() local
2544 event->root = RootWindow(pSprite)->drawable.id; in FixUpEventFromWindow()
2545 event->event = pWin->drawable.id; in FixUpEventFromWindow()
2548 event->child = child; in FixUpEventFromWindow()
2552 if (pSprite->hot.pScreen == pWin->drawable.pScreen) { in FixUpEventFromWindow()
2553 event->event_x = event->root_x - double_to_fp1616(pWin->drawable.x); in FixUpEventFromWindow()
2554 event->event_y = event->root_y - double_to_fp1616(pWin->drawable.y); in FixUpEventFromWindow()
2555 event->child = child; in FixUpEventFromWindow()
2558 event->event_x = 0; in FixUpEventFromWindow()
2559 event->event_y = 0; in FixUpEventFromWindow()
2560 event->child = None; in FixUpEventFromWindow()
2563 if (event->evtype == XI_Enter || event->evtype == XI_Leave || in FixUpEventFromWindow()
2564 event->evtype == XI_FocusIn || event->evtype == XI_FocusOut) in FixUpEventFromWindow()
2565 ((xXIEnterEvent *) event)->same_screen = in FixUpEventFromWindow()
2566 (pSprite->hot.pScreen == pWin->drawable.pScreen); in FixUpEventFromWindow()
2570 XE_KBPTR.root = RootWindow(pSprite)->drawable.id; in FixUpEventFromWindow()
2571 XE_KBPTR.event = pWin->drawable.id; in FixUpEventFromWindow()
2572 if (pSprite->hot.pScreen == pWin->drawable.pScreen) { in FixUpEventFromWindow()
2575 XE_KBPTR.eventX = XE_KBPTR.rootX - pWin->drawable.x; in FixUpEventFromWindow()
2576 XE_KBPTR.eventY = XE_KBPTR.rootY - pWin->drawable.y; in FixUpEventFromWindow()
2588 * Check if a given event is deliverable at all on a given window.
2593 * @param[in] dev The device this event is being sent for.
2594 * @param[in] evtype The event type of the event that is to be sent.
2595 * @param[in] win The current event window.
2609 if (inputMasks && xi2mask_isset(inputMasks->xi2mask, dev, type)) in EventIsDeliverable()
2618 (inputMasks->deliverableEvents[dev->id] & filter) && in EventIsDeliverable()
2619 (inputMasks->inputEvents[dev->id] & filter)) in EventIsDeliverable()
2623 if (inputMasks && (inputMasks->dontPropagateMask[dev->id] & filter)) in EventIsDeliverable()
2632 if ((win->deliverableEvents & filter) && in EventIsDeliverable()
2633 ((wOtherEventMasks(win) | win->eventMask) & filter)) in EventIsDeliverable()
2648 SpritePtr pSprite = dev->spriteInfo->sprite; in DeliverEvent()
2662 DeliverOneEvent(InternalEvent *event, DeviceIntPtr dev, enum InputLevel level, in DeliverOneEvent() argument
2672 rc = EventToXI2(event, &xE); in DeliverOneEvent()
2676 rc = EventToXI(event, &xE, &count); in DeliverOneEvent()
2679 rc = EventToCore(event, &xE, &count); in DeliverOneEvent()
2693 dev->name, level, rc); in DeliverOneEvent()
2700 * For events from a non-grabbed, non-focus device, DeliverDeviceEvents is
2707 * @param pWin Window to deliver event to.
2708 * @param event The events to deliver, not yet in wire format.
2711 * @param dev The device that is responsible for the event.
2717 DeliverDeviceEvents(WindowPtr pWin, InternalEvent *event, GrabPtr grab, in DeliverDeviceEvents() argument
2724 verify_internal_event(event); in DeliverDeviceEvents()
2727 if ((mask = EventIsDeliverable(dev, event->any.type, pWin))) { in DeliverDeviceEvents()
2731 DeliverOneEvent(event, dev, XI2, pWin, child, grab); in DeliverDeviceEvents()
2738 deliveries = DeliverOneEvent(event, dev, XI, pWin, child, grab); in DeliverDeviceEvents()
2743 /* Core event */ in DeliverDeviceEvents()
2744 if ((mask & EVENT_CORE_MASK) && IsMaster(dev) && dev->coreEvents) { in DeliverDeviceEvents()
2746 DeliverOneEvent(event, dev, CORE, pWin, child, grab); in DeliverDeviceEvents()
2759 child = pWin->drawable.id; in DeliverDeviceEvents()
2760 pWin = pWin->parent; in DeliverDeviceEvents()
2767 * Deliver event to a window and it's immediate parent. Used for most window
2771 * In case of a ReparentNotify event, the event will be delivered to the
2786 if (!noPanoramiXExtension && pWin->drawable.pScreen->myNum) in DeliverEvents()
2795 switch (xE->u.u.type) { in DeliverEvents()
2806 xE->u.destroyNotify.event = pWin->drawable.id; in DeliverEvents()
2810 switch (xE->u.u.type) { in DeliverEvents()
2830 if (pWin->parent) { in DeliverEvents()
2831 xE->u.destroyNotify.event = pWin->parent->drawable.id; in DeliverEvents()
2832 deliveries += DeliverEventsToWindow(&dummy, pWin->parent, xE, count, in DeliverEvents()
2834 if (xE->u.u.type == ReparentNotify) { in DeliverEvents()
2835 xE->u.destroyNotify.event = otherParent->drawable.id; in DeliverEvents()
2850 if (RegionContainsPoint(&pWin->borderSize, x, y, &box)) in PointInBorderSize()
2856 SpritePtr pSprite = inputInfo.pointer->spriteInfo->sprite; in PointInBorderSize()
2860 if (RegionContainsPoint(&pSprite->windows[i]->borderSize, in PointInBorderSize()
2861 x + screenInfo.screens[0]->x - in PointInBorderSize()
2862 screenInfo.screens[i]->x, in PointInBorderSize()
2863 y + screenInfo.screens[0]->y - in PointInBorderSize()
2864 screenInfo.screens[i]->y, &box)) in PointInBorderSize()
2879 * spriteTrace[spriteTraceGood - 1] ... window at x/y
2886 ScreenPtr pScreen = RootWindow(pSprite)->drawable.pScreen; in XYToWindow()
2888 return (*pScreen->XYToWindow)(pScreen, pSprite, x, y); in XYToWindow()
2902 DeviceEvent event; in ActivateFocusInGrab() local
2904 if (dev->deviceGrab.grab) { in ActivateFocusInGrab()
2905 if (!dev->deviceGrab.fromPassiveGrab || in ActivateFocusInGrab()
2906 dev->deviceGrab.grab->type != XI_FocusIn || in ActivateFocusInGrab()
2907 dev->deviceGrab.grab->window == win || in ActivateFocusInGrab()
2908 IsParent(dev->deviceGrab.grab->window, win)) in ActivateFocusInGrab()
2910 DoEnterLeaveEvents(dev, dev->id, old, win, XINotifyPassiveUngrab); in ActivateFocusInGrab()
2911 (*dev->deviceGrab.DeactivateGrab) (dev); in ActivateFocusInGrab()
2917 event = (DeviceEvent) { in ActivateFocusInGrab()
2922 .deviceid = dev->id, in ActivateFocusInGrab()
2923 .sourceid = dev->id, in ActivateFocusInGrab()
2926 rc = (CheckPassiveGrabsOnWindow(win, dev, (InternalEvent *) &event, FALSE, in ActivateFocusInGrab()
2929 DoEnterLeaveEvents(dev, dev->id, old, win, XINotifyPassiveGrab); in ActivateFocusInGrab()
2943 DeviceEvent event; in ActivateEnterGrab() local
2945 if (dev->deviceGrab.grab) { in ActivateEnterGrab()
2946 if (!dev->deviceGrab.fromPassiveGrab || in ActivateEnterGrab()
2947 dev->deviceGrab.grab->type != XI_Enter || in ActivateEnterGrab()
2948 dev->deviceGrab.grab->window == win || in ActivateEnterGrab()
2949 IsParent(dev->deviceGrab.grab->window, win)) in ActivateEnterGrab()
2951 DoEnterLeaveEvents(dev, dev->id, old, win, XINotifyPassiveUngrab); in ActivateEnterGrab()
2952 (*dev->deviceGrab.DeactivateGrab) (dev); in ActivateEnterGrab()
2955 event = (DeviceEvent) { in ActivateEnterGrab()
2960 .deviceid = dev->id, in ActivateEnterGrab()
2961 .sourceid = dev->id, in ActivateEnterGrab()
2964 rc = (CheckPassiveGrabsOnWindow(win, dev, (InternalEvent *) &event, FALSE, in ActivateEnterGrab()
2967 DoEnterLeaveEvents(dev, dev->id, old, win, XINotifyPassiveGrab); in ActivateEnterGrab()
2972 * Update the sprite coordinates based on the event. Update the cursor
2973 * position, then update the event with the new coordinates that may have been
2977 * CheckMotion() will not do anything and return FALSE if the event is not a
2978 * pointer event.
2986 SpritePtr pSprite = pDev->spriteInfo->sprite; in CheckMotion()
2990 prevSpriteWin = pSprite->win; in CheckMotion()
2995 switch (ev->type) { in CheckMotion()
3013 ev->root_x += pSprite->screen->x - screenInfo.screens[0]->x; in CheckMotion()
3014 ev->root_y += pSprite->screen->y - screenInfo.screens[0]->y; in CheckMotion()
3019 if (pSprite->hot.pScreen != pSprite->hotPhys.pScreen) { in CheckMotion()
3020 pSprite->hot.pScreen = pSprite->hotPhys.pScreen; in CheckMotion()
3021 RootWindow(pDev->spriteInfo->sprite) = in CheckMotion()
3022 pSprite->hot.pScreen->root; in CheckMotion()
3026 pSprite->hot.x = ev->root_x; in CheckMotion()
3027 pSprite->hot.y = ev->root_y; in CheckMotion()
3028 if (pSprite->hot.x < pSprite->physLimits.x1) in CheckMotion()
3029 pSprite->hot.x = pSprite->physLimits.x1; in CheckMotion()
3030 else if (pSprite->hot.x >= pSprite->physLimits.x2) in CheckMotion()
3031 pSprite->hot.x = pSprite->physLimits.x2 - 1; in CheckMotion()
3032 if (pSprite->hot.y < pSprite->physLimits.y1) in CheckMotion()
3033 pSprite->hot.y = pSprite->physLimits.y1; in CheckMotion()
3034 else if (pSprite->hot.y >= pSprite->physLimits.y2) in CheckMotion()
3035 pSprite->hot.y = pSprite->physLimits.y2 - 1; in CheckMotion()
3036 if (pSprite->hotShape) in CheckMotion()
3037 ConfineToShape(pDev, pSprite->hotShape, &pSprite->hot.x, in CheckMotion()
3038 &pSprite->hot.y); in CheckMotion()
3039 pSprite->hotPhys = pSprite->hot; in CheckMotion()
3041 if ((pSprite->hotPhys.x != ev->root_x) || in CheckMotion()
3042 (pSprite->hotPhys.y != ev->root_y)) { in CheckMotion()
3045 XineramaSetCursorPosition(pDev, pSprite->hotPhys.x, in CheckMotion()
3046 pSprite->hotPhys.y, FALSE); in CheckMotion()
3051 (*pSprite->hotPhys.pScreen->SetCursorPosition) (pDev, in CheckMotion()
3052 pSprite-> in CheckMotion()
3054 pSprite-> in CheckMotion()
3056 pSprite-> in CheckMotion()
3062 ev->root_x = pSprite->hot.x; in CheckMotion()
3063 ev->root_y = pSprite->hot.y; in CheckMotion()
3066 newSpriteWin = XYToWindow(pSprite, pSprite->hot.x, pSprite->hot.y); in CheckMotion()
3073 sourceid = pDev->id; /* when from WindowsRestructured */ in CheckMotion()
3076 sourceid = ev->sourceid; in CheckMotion()
3083 /* set pSprite->win after ActivateEnterGrab, otherwise in CheckMotion()
3086 pSprite->win = newSpriteWin; in CheckMotion()
3105 pDev = pDev->next; in WindowsRestructured()
3128 pSprite = pDev->spriteInfo->sprite; in ReinitializeRootWindow()
3129 pSprite->hot.x -= xoff; in ReinitializeRootWindow()
3130 pSprite->hot.y -= yoff; in ReinitializeRootWindow()
3132 pSprite->hotPhys.x -= xoff; in ReinitializeRootWindow()
3133 pSprite->hotPhys.y -= yoff; in ReinitializeRootWindow()
3135 pSprite->hotLimits.x1 -= xoff; in ReinitializeRootWindow()
3136 pSprite->hotLimits.y1 -= yoff; in ReinitializeRootWindow()
3137 pSprite->hotLimits.x2 -= xoff; in ReinitializeRootWindow()
3138 pSprite->hotLimits.y2 -= yoff; in ReinitializeRootWindow()
3140 if (RegionNotEmpty(&pSprite->Reg1)) in ReinitializeRootWindow()
3141 RegionTranslate(&pSprite->Reg1, xoff, yoff); in ReinitializeRootWindow()
3142 if (RegionNotEmpty(&pSprite->Reg2)) in ReinitializeRootWindow()
3143 RegionTranslate(&pSprite->Reg2, xoff, yoff); in ReinitializeRootWindow()
3146 if ((grab = pDev->deviceGrab.grab) && grab->confineTo) { in ReinitializeRootWindow()
3147 if (grab->confineTo->drawable.pScreen in ReinitializeRootWindow()
3148 != pSprite->hotPhys.pScreen) in ReinitializeRootWindow()
3149 pSprite->hotPhys.x = pSprite->hotPhys.y = 0; in ReinitializeRootWindow()
3150 ConfineCursorToWindow(pDev, grab->confineTo, TRUE, TRUE); in ReinitializeRootWindow()
3154 pSprite->hotPhys.pScreen->root, in ReinitializeRootWindow()
3158 pDev = pDev->next; in ReinitializeRootWindow()
3185 if (!pDev->spriteInfo->sprite) { in InitializeSprite()
3188 pDev->spriteInfo->sprite = (SpritePtr) calloc(1, sizeof(SpriteRec)); in InitializeSprite()
3189 if (!pDev->spriteInfo->sprite) in InitializeSprite()
3198 for (it = inputInfo.devices; it; it = it->next) { in InitializeSprite()
3199 if (it->spriteInfo->paired == pDev) in InitializeSprite()
3200 it->spriteInfo->sprite = pDev->spriteInfo->sprite; in InitializeSprite()
3202 if (inputInfo.keyboard->spriteInfo->paired == pDev) in InitializeSprite()
3203 inputInfo.keyboard->spriteInfo->sprite = pDev->spriteInfo->sprite; in InitializeSprite()
3206 pSprite = pDev->spriteInfo->sprite; in InitializeSprite()
3207 pDev->spriteInfo->spriteOwner = TRUE; in InitializeSprite()
3209 pScreen = (pWin) ? pWin->drawable.pScreen : (ScreenPtr) NULL; in InitializeSprite()
3210 pSprite->hot.pScreen = pScreen; in InitializeSprite()
3211 pSprite->hotPhys.pScreen = pScreen; in InitializeSprite()
3213 pSprite->hotPhys.x = pScreen->width / 2; in InitializeSprite()
3214 pSprite->hotPhys.y = pScreen->height / 2; in InitializeSprite()
3215 pSprite->hotLimits.x2 = pScreen->width; in InitializeSprite()
3216 pSprite->hotLimits.y2 = pScreen->height; in InitializeSprite()
3219 pSprite->hot = pSprite->hotPhys; in InitializeSprite()
3220 pSprite->win = pWin; in InitializeSprite()
3224 pSprite->spriteTrace = (WindowPtr *) calloc(1, 32 * sizeof(WindowPtr)); in InitializeSprite()
3225 if (!pSprite->spriteTrace) in InitializeSprite()
3227 pSprite->spriteTraceSize = 32; in InitializeSprite()
3229 RootWindow(pDev->spriteInfo->sprite) = pWin; in InitializeSprite()
3230 pSprite->spriteTraceGood = 1; in InitializeSprite()
3232 pSprite->pEnqueueScreen = pScreen; in InitializeSprite()
3233 pSprite->pDequeueScreen = pSprite->pEnqueueScreen; in InitializeSprite()
3238 pSprite->spriteTrace = NULL; in InitializeSprite()
3239 pSprite->spriteTraceSize = 0; in InitializeSprite()
3240 pSprite->spriteTraceGood = 0; in InitializeSprite()
3241 pSprite->pEnqueueScreen = screenInfo.screens[0]; in InitializeSprite()
3242 pSprite->pDequeueScreen = pSprite->pEnqueueScreen; in InitializeSprite()
3245 if (pSprite->current) in InitializeSprite()
3246 FreeCursor(pSprite->current, None); in InitializeSprite()
3247 pSprite->current = pCursor; in InitializeSprite()
3250 (*pScreen->RealizeCursor) (pDev, pScreen, pSprite->current); in InitializeSprite()
3251 (*pScreen->CursorLimits) (pDev, pScreen, pSprite->current, in InitializeSprite()
3252 &pSprite->hotLimits, &pSprite->physLimits); in InitializeSprite()
3253 pSprite->confined = FALSE; in InitializeSprite()
3255 (*pScreen->ConstrainCursor) (pDev, pScreen, &pSprite->physLimits); in InitializeSprite()
3256 (*pScreen->SetCursorPosition) (pDev, pScreen, pSprite->hot.x, in InitializeSprite()
3257 pSprite->hot.y, FALSE); in InitializeSprite()
3258 (*pScreen->DisplayCursor) (pDev, pScreen, pSprite->current); in InitializeSprite()
3262 pSprite->hotLimits.x1 = -screenInfo.screens[0]->x; in InitializeSprite()
3263 pSprite->hotLimits.y1 = -screenInfo.screens[0]->y; in InitializeSprite()
3264 pSprite->hotLimits.x2 = PanoramiXPixWidth - screenInfo.screens[0]->x; in InitializeSprite()
3265 pSprite->hotLimits.y2 = PanoramiXPixHeight - screenInfo.screens[0]->y; in InitializeSprite()
3266 pSprite->physLimits = pSprite->hotLimits; in InitializeSprite()
3267 pSprite->confineWin = NullWindow; in InitializeSprite()
3268 pSprite->hotShape = NullRegion; in InitializeSprite()
3269 pSprite->screen = pScreen; in InitializeSprite()
3271 RegionNull(&pSprite->Reg1); in InitializeSprite()
3272 RegionNull(&pSprite->Reg2); in InitializeSprite()
3279 if (DevHasCursor(dev) && dev->spriteInfo->sprite) { in FreeSprite()
3280 if (dev->spriteInfo->sprite->current) in FreeSprite()
3281 FreeCursor(dev->spriteInfo->sprite->current, None); in FreeSprite()
3282 free(dev->spriteInfo->sprite->spriteTrace); in FreeSprite()
3283 free(dev->spriteInfo->sprite); in FreeSprite()
3285 dev->spriteInfo->sprite = NULL; in FreeSprite()
3293 * implies that windows that are in pScreen whose pScreen->myNum >0 will never
3314 if (!pDev->spriteInfo->sprite) in UpdateSpriteForScreen()
3317 pSprite = pDev->spriteInfo->sprite; in UpdateSpriteForScreen()
3319 win = pScreen->root; in UpdateSpriteForScreen()
3321 pSprite->hotPhys.pScreen = pScreen; in UpdateSpriteForScreen()
3322 pSprite->hot = pSprite->hotPhys; in UpdateSpriteForScreen()
3323 pSprite->hotLimits.x2 = pScreen->width; in UpdateSpriteForScreen()
3324 pSprite->hotLimits.y2 = pScreen->height; in UpdateSpriteForScreen()
3325 pSprite->win = win; in UpdateSpriteForScreen()
3327 if (pSprite->current) in UpdateSpriteForScreen()
3328 FreeCursor(pSprite->current, 0); in UpdateSpriteForScreen()
3329 pSprite->current = pCursor; in UpdateSpriteForScreen()
3330 pSprite->spriteTraceGood = 1; in UpdateSpriteForScreen()
3331 pSprite->spriteTrace[0] = win; in UpdateSpriteForScreen()
3332 (*pScreen->CursorLimits) (pDev, in UpdateSpriteForScreen()
3334 pSprite->current, in UpdateSpriteForScreen()
3335 &pSprite->hotLimits, &pSprite->physLimits); in UpdateSpriteForScreen()
3336 pSprite->confined = FALSE; in UpdateSpriteForScreen()
3337 (*pScreen->ConstrainCursor) (pDev, pScreen, &pSprite->physLimits); in UpdateSpriteForScreen()
3338 (*pScreen->DisplayCursor) (pDev, pScreen, pSprite->current); in UpdateSpriteForScreen()
3342 pSprite->hotLimits.x1 = -screenInfo.screens[0]->x; in UpdateSpriteForScreen()
3343 pSprite->hotLimits.y1 = -screenInfo.screens[0]->y; in UpdateSpriteForScreen()
3344 pSprite->hotLimits.x2 = PanoramiXPixWidth - screenInfo.screens[0]->x; in UpdateSpriteForScreen()
3345 pSprite->hotLimits.y2 = PanoramiXPixHeight - screenInfo.screens[0]->y; in UpdateSpriteForScreen()
3346 pSprite->physLimits = pSprite->hotLimits; in UpdateSpriteForScreen()
3347 pSprite->screen = pScreen; in UpdateSpriteForScreen()
3364 for (pDev = inputInfo.devices; pDev; pDev = pDev->next) in WindowHasNewCursor()
3378 pSprite = ptr->spriteInfo->sprite; in NewCurrentScreen()
3380 pSprite->hotPhys.x = x; in NewCurrentScreen()
3381 pSprite->hotPhys.y = y; in NewCurrentScreen()
3384 pSprite->hotPhys.x += newScreen->x - screenInfo.screens[0]->x; in NewCurrentScreen()
3385 pSprite->hotPhys.y += newScreen->y - screenInfo.screens[0]->y; in NewCurrentScreen()
3386 if (newScreen != pSprite->screen) { in NewCurrentScreen()
3387 pSprite->screen = newScreen; in NewCurrentScreen()
3389 if (pSprite->confineWin) in NewCurrentScreen()
3390 XineramaConfineCursorToWindow(ptr, pSprite->confineWin, TRUE); in NewCurrentScreen()
3392 XineramaConfineCursorToWindow(ptr, screenInfo.screens[0]->root, in NewCurrentScreen()
3397 (*pSprite->screen->SetCursorPosition) (ptr, in NewCurrentScreen()
3398 pSprite->screen, in NewCurrentScreen()
3399 pSprite->hotPhys.x + in NewCurrentScreen()
3400 screenInfo.screens[0]-> in NewCurrentScreen()
3401 x - pSprite->screen->x, in NewCurrentScreen()
3402 pSprite->hotPhys.y + in NewCurrentScreen()
3403 screenInfo.screens[0]-> in NewCurrentScreen()
3404 y - pSprite->screen->y, in NewCurrentScreen()
3410 if (newScreen != pSprite->hotPhys.pScreen) in NewCurrentScreen()
3411 ConfineCursorToWindow(ptr, newScreen->root, TRUE, FALSE); in NewCurrentScreen()
3422 if (!pWin->realized) in XineramaPointInWindowIsVisible()
3425 if (RegionContainsPoint(&pWin->borderClip, x, y, &box)) in XineramaPointInWindowIsVisible()
3431 xoff = x + screenInfo.screens[0]->x; in XineramaPointInWindowIsVisible()
3432 yoff = y + screenInfo.screens[0]->y; in XineramaPointInWindowIsVisible()
3435 pWin = inputInfo.pointer->spriteInfo->sprite->windows[i]; in XineramaPointInWindowIsVisible()
3437 x = xoff - screenInfo.screens[i]->x; in XineramaPointInWindowIsVisible()
3438 y = yoff - screenInfo.screens[i]->y; in XineramaPointInWindowIsVisible()
3440 if (RegionContainsPoint(&pWin->borderClip, x, y, &box) in XineramaPointInWindowIsVisible()
3443 x - pWin->drawable.x, in XineramaPointInWindowIsVisible()
3444 y - pWin->drawable.y, &box))) in XineramaPointInWindowIsVisible()
3457 SpritePtr pSprite = PickPointer(client)->spriteInfo->sprite; in XineramaWarpPointer()
3461 if (stuff->dstWid != None) { in XineramaWarpPointer()
3462 rc = dixLookupWindow(&dest, stuff->dstWid, client, DixReadAccess); in XineramaWarpPointer()
3466 x = pSprite->hotPhys.x; in XineramaWarpPointer()
3467 y = pSprite->hotPhys.y; in XineramaWarpPointer()
3469 if (stuff->srcWid != None) { in XineramaWarpPointer()
3471 XID winID = stuff->srcWid; in XineramaWarpPointer()
3478 winX = source->drawable.x; in XineramaWarpPointer()
3479 winY = source->drawable.y; in XineramaWarpPointer()
3480 if (source == screenInfo.screens[0]->root) { in XineramaWarpPointer()
3481 winX -= screenInfo.screens[0]->x; in XineramaWarpPointer()
3482 winY -= screenInfo.screens[0]->y; in XineramaWarpPointer()
3484 if (x < winX + stuff->srcX || in XineramaWarpPointer()
3485 y < winY + stuff->srcY || in XineramaWarpPointer()
3486 (stuff->srcWidth != 0 && in XineramaWarpPointer()
3487 winX + stuff->srcX + (int) stuff->srcWidth < x) || in XineramaWarpPointer()
3488 (stuff->srcHeight != 0 && in XineramaWarpPointer()
3489 winY + stuff->srcY + (int) stuff->srcHeight < y) || in XineramaWarpPointer()
3494 x = dest->drawable.x; in XineramaWarpPointer()
3495 y = dest->drawable.y; in XineramaWarpPointer()
3496 if (dest == screenInfo.screens[0]->root) { in XineramaWarpPointer()
3497 x -= screenInfo.screens[0]->x; in XineramaWarpPointer()
3498 y -= screenInfo.screens[0]->y; in XineramaWarpPointer()
3502 x += stuff->dstX; in XineramaWarpPointer()
3503 y += stuff->dstY; in XineramaWarpPointer()
3505 if (x < pSprite->physLimits.x1) in XineramaWarpPointer()
3506 x = pSprite->physLimits.x1; in XineramaWarpPointer()
3507 else if (x >= pSprite->physLimits.x2) in XineramaWarpPointer()
3508 x = pSprite->physLimits.x2 - 1; in XineramaWarpPointer()
3509 if (y < pSprite->physLimits.y1) in XineramaWarpPointer()
3510 y = pSprite->physLimits.y1; in XineramaWarpPointer()
3511 else if (y >= pSprite->physLimits.y2) in XineramaWarpPointer()
3512 y = pSprite->physLimits.y2 - 1; in XineramaWarpPointer()
3513 if (pSprite->hotShape) in XineramaWarpPointer()
3514 ConfineToShape(PickPointer(client), pSprite->hotShape, &x, &y); in XineramaWarpPointer()
3524 * Server-side protocol handling for WarpPointer request.
3541 for (tmp = inputInfo.devices; tmp; tmp = tmp->next) { in ProcWarpPointer()
3549 if (dev->lastSlave) in ProcWarpPointer()
3550 dev = dev->lastSlave; in ProcWarpPointer()
3551 pSprite = dev->spriteInfo->sprite; in ProcWarpPointer()
3558 if (stuff->dstWid != None) { in ProcWarpPointer()
3559 rc = dixLookupWindow(&dest, stuff->dstWid, client, DixGetAttrAccess); in ProcWarpPointer()
3563 x = pSprite->hotPhys.x; in ProcWarpPointer()
3564 y = pSprite->hotPhys.y; in ProcWarpPointer()
3566 if (stuff->srcWid != None) { in ProcWarpPointer()
3568 XID winID = stuff->srcWid; in ProcWarpPointer()
3575 winX = source->drawable.x; in ProcWarpPointer()
3576 winY = source->drawable.y; in ProcWarpPointer()
3577 if (source->drawable.pScreen != pSprite->hotPhys.pScreen || in ProcWarpPointer()
3578 x < winX + stuff->srcX || in ProcWarpPointer()
3579 y < winY + stuff->srcY || in ProcWarpPointer()
3580 (stuff->srcWidth != 0 && in ProcWarpPointer()
3581 winX + stuff->srcX + (int) stuff->srcWidth < x) || in ProcWarpPointer()
3582 (stuff->srcHeight != 0 && in ProcWarpPointer()
3583 winY + stuff->srcY + (int) stuff->srcHeight < y) || in ProcWarpPointer()
3584 (source->parent && !PointInWindowIsVisible(source, x, y))) in ProcWarpPointer()
3588 x = dest->drawable.x; in ProcWarpPointer()
3589 y = dest->drawable.y; in ProcWarpPointer()
3590 newScreen = dest->drawable.pScreen; in ProcWarpPointer()
3593 newScreen = pSprite->hotPhys.pScreen; in ProcWarpPointer()
3595 x += stuff->dstX; in ProcWarpPointer()
3596 y += stuff->dstY; in ProcWarpPointer()
3600 else if (x >= newScreen->width) in ProcWarpPointer()
3601 x = newScreen->width - 1; in ProcWarpPointer()
3604 else if (y >= newScreen->height) in ProcWarpPointer()
3605 y = newScreen->height - 1; in ProcWarpPointer()
3607 if (newScreen == pSprite->hotPhys.pScreen) { in ProcWarpPointer()
3608 if (x < pSprite->physLimits.x1) in ProcWarpPointer()
3609 x = pSprite->physLimits.x1; in ProcWarpPointer()
3610 else if (x >= pSprite->physLimits.x2) in ProcWarpPointer()
3611 x = pSprite->physLimits.x2 - 1; in ProcWarpPointer()
3612 if (y < pSprite->physLimits.y1) in ProcWarpPointer()
3613 y = pSprite->physLimits.y1; in ProcWarpPointer()
3614 else if (y >= pSprite->physLimits.y2) in ProcWarpPointer()
3615 y = pSprite->physLimits.y2 - 1; in ProcWarpPointer()
3616 if (pSprite->hotShape) in ProcWarpPointer()
3617 ConfineToShape(dev, pSprite->hotShape, &x, &y); in ProcWarpPointer()
3618 (*newScreen->SetCursorPosition) (dev, newScreen, x, y, TRUE); in ProcWarpPointer()
3623 if (*newScreen->CursorWarpedTo) in ProcWarpPointer()
3624 (*newScreen->CursorWarpedTo) (dev, newScreen, client, in ProcWarpPointer()
3632 if (RegionNotEmpty(&pWin->borderSize)) in BorderSizeNotEmpty()
3641 (&pDev->spriteInfo->sprite->windows[i]->borderSize)) in BorderSizeNotEmpty()
3651 * event has been delivered to the client.
3653 * @param device The device of the event to check.
3655 * @param event The current device event.
3656 * @param real_event The original event, in case of touch emulation. The
3657 * real event is the one stored in the sync queue.
3662 ActivatePassiveGrab(DeviceIntPtr device, GrabPtr grab, InternalEvent *event, in ActivatePassiveGrab() argument
3665 SpritePtr pSprite = device->spriteInfo->sprite; in ActivatePassiveGrab()
3666 GrabInfoPtr grabinfo = &device->deviceGrab; in ActivatePassiveGrab()
3673 if (grab->grabtype == XI || grab->grabtype == CORE) { in ActivatePassiveGrab()
3676 event->device_event.corestate &= 0x1f00; in ActivatePassiveGrab()
3678 if (grab->grabtype == CORE) in ActivatePassiveGrab()
3681 gdev = grab->modifierDevice; in ActivatePassiveGrab()
3683 if (gdev && gdev->key && gdev->key->xkbInfo) in ActivatePassiveGrab()
3684 event->device_event.corestate |= in ActivatePassiveGrab()
3685 gdev->key->xkbInfo->state.grab_mods & (~0x1f00); in ActivatePassiveGrab()
3688 if (grab->grabtype == CORE) { in ActivatePassiveGrab()
3689 rc = EventToCore(event, &xE, &count); in ActivatePassiveGrab()
3692 "(%d, %d).\n", device->name, event->any.type, rc); in ActivatePassiveGrab()
3696 else if (grab->grabtype == XI2) { in ActivatePassiveGrab()
3697 rc = EventToXI2(event, &xE); in ActivatePassiveGrab()
3701 "(%d, %d).\n", device->name, event->any.type, rc); in ActivatePassiveGrab()
3707 rc = EventToXI(event, &xE, &count); in ActivatePassiveGrab()
3711 "(%d, %d).\n", device->name, event->any.type, rc); in ActivatePassiveGrab()
3716 (*grabinfo->ActivateGrab) (device, grab, in ActivatePassiveGrab()
3717 ClientTimeToServerTime(event->any.time), TRUE); in ActivatePassiveGrab()
3720 FixUpEventFromWindow(pSprite, xE, grab->window, None, TRUE); in ActivatePassiveGrab()
3728 if (grabinfo->sync.state == FROZEN_NO_EVENT) in ActivatePassiveGrab()
3729 grabinfo->sync.state = FROZEN_WITH_EVENT; in ActivatePassiveGrab()
3730 *grabinfo->sync.event = real_event->device_event; in ActivatePassiveGrab()
3742 for (other = inputInfo.devices; other; other = other->next) { in CoreGrabInterferes()
3743 GrabPtr othergrab = other->deviceGrab.grab; in CoreGrabInterferes()
3745 if (othergrab && othergrab->grabtype == CORE && in CoreGrabInterferes()
3747 ((IsPointerDevice(grab->device) && in CoreGrabInterferes()
3748 IsPointerDevice(othergrab->device)) || in CoreGrabInterferes()
3749 (IsKeyboardDevice(grab->device) && in CoreGrabInterferes()
3750 IsKeyboardDevice(othergrab->device)))) { in CoreGrabInterferes()
3773 * @param event_type Wire protocol event type
3808 tmp->grabtype = grabtype; in MatchForType()
3809 tmp->type = evtype; in MatchForType()
3811 if (tmp->type && GrabMatchesSecond(tmp, grab, ignore_device)) in MatchForType()
3818 * Check an individual grab against an event to determine if a passive grab
3821 * @param device The device of the event to check.
3823 * @param event The current device event.
3825 * @param tempGrab A pre-allocated temporary grab record for matching. This
3828 * @return Whether the grab matches the event.
3831 CheckPassiveGrab(DeviceIntPtr device, GrabPtr grab, InternalEvent *event, in CheckPassiveGrab() argument
3839 gdev = grab->modifierDevice; in CheckPassiveGrab()
3840 if (grab->grabtype == CORE) { in CheckPassiveGrab()
3843 else if (grab->grabtype == XI2) { in CheckPassiveGrab()
3848 if (!IsMaster(grab->device) && !IsFloating(device)) in CheckPassiveGrab()
3852 if (gdev && gdev->key) in CheckPassiveGrab()
3853 xkbi = gdev->key->xkbInfo; in CheckPassiveGrab()
3854 tempGrab->modifierDevice = grab->modifierDevice; in CheckPassiveGrab()
3855 tempGrab->modifiersDetail.exact = xkbi ? xkbi->state.grab_mods : 0; in CheckPassiveGrab()
3858 match = MatchForType(grab, tempGrab, XI2, event->any.type); in CheckPassiveGrab()
3860 if (!match && IsTouchEvent(event) && in CheckPassiveGrab()
3861 (event->device_event.flags & TOUCH_POINTER_EMULATED)) { in CheckPassiveGrab()
3862 emulated_type = TouchGetPointerEventType(event); in CheckPassiveGrab()
3867 match = MatchForType(grab, tempGrab, XI, event->any.type); in CheckPassiveGrab()
3873 match = MatchForType(grab, tempGrab, CORE, event->any.type); in CheckPassiveGrab()
3878 if (!match || (grab->confineTo && in CheckPassiveGrab()
3879 (!grab->confineTo->realized || in CheckPassiveGrab()
3880 !BorderSizeNotEmpty(device, grab->confineTo)))) in CheckPassiveGrab()
3889 if (grab->grabtype == CORE) { in CheckPassiveGrab()
3897 if (grab->type < GenericEvent) { in CheckPassiveGrab()
3898 grab->device = device; in CheckPassiveGrab()
3899 grab->modifierDevice = GetMaster(device, MASTER_KEYBOARD); in CheckPassiveGrab()
3910 * "CheckPassiveGrabsOnWindow" checks to see if the event passed in causes a
3913 * and the event will be delivered to the client.
3916 * @param device Device that caused the event.
3917 * @param event The current device event.
3919 * @param activate If a grab is found, activate it and deliver the event.
3925 InternalEvent *event, BOOL checkCore, BOOL activate) in CheckPassiveGrabsOnWindow() argument
3939 switch (event->any.type) { in CheckPassiveGrabsOnWindow()
3942 tempGrab->detail.exact = event->device_event.detail.key; in CheckPassiveGrabsOnWindow()
3948 tempGrab->detail.exact = event->device_event.detail.button; in CheckPassiveGrabsOnWindow()
3951 tempGrab->detail.exact = 0; in CheckPassiveGrabsOnWindow()
3954 tempGrab->window = pWin; in CheckPassiveGrabsOnWindow()
3955 tempGrab->device = device; in CheckPassiveGrabsOnWindow()
3956 tempGrab->detail.pMask = NULL; in CheckPassiveGrabsOnWindow()
3957 tempGrab->modifiersDetail.pMask = NULL; in CheckPassiveGrabsOnWindow()
3958 tempGrab->next = NULL; in CheckPassiveGrabsOnWindow()
3960 for (; grab; grab = grab->next) { in CheckPassiveGrabsOnWindow()
3961 if (!CheckPassiveGrab(device, grab, event, checkCore, tempGrab)) in CheckPassiveGrabsOnWindow()
3964 if (activate && !ActivatePassiveGrab(device, grab, event, event)) in CheckPassiveGrabsOnWindow()
3978 * If the event is a keyboard event, the ancestors of the focus window are
3984 * If the event is a pointer event, the ancestors of the window that the
3989 * If a grab is activated, the event has been sent to the client already!
3991 * The event we pass in must always be an XI event. From this, we then emulate
3992 * the core event and then check for grabs.
3994 * @param device The device that caused the event.
3995 * @param xE The event to handle (Device{Button|Key}Press).
4001 CheckDeviceGrabs(DeviceIntPtr device, DeviceEvent *event, WindowPtr ancestor) in CheckDeviceGrabs() argument
4006 IsPointerEvent((InternalEvent *) event) ? NULL : device->focus; in CheckDeviceGrabs()
4007 BOOL sendCore = (IsMaster(device) && device->coreEvents); in CheckDeviceGrabs()
4010 if (event->type != ET_ButtonPress && event->type != ET_KeyPress) in CheckDeviceGrabs()
4013 if (event->type == ET_ButtonPress && (device->button->buttonsDown != 1)) in CheckDeviceGrabs()
4016 if (device->deviceGrab.grab) in CheckDeviceGrabs()
4021 while (i < device->spriteInfo->sprite->spriteTraceGood) in CheckDeviceGrabs()
4022 if (device->spriteInfo->sprite->spriteTrace[i++] == ancestor) in CheckDeviceGrabs()
4024 if (i == device->spriteInfo->sprite->spriteTraceGood) in CheckDeviceGrabs()
4029 for (; i < focus->traceGood; i++) { in CheckDeviceGrabs()
4030 pWin = focus->trace[i]; in CheckDeviceGrabs()
4031 if (CheckPassiveGrabsOnWindow(pWin, device, (InternalEvent *) event, in CheckDeviceGrabs()
4038 if ((focus->win == NoneWin) || in CheckDeviceGrabs()
4039 (i >= device->spriteInfo->sprite->spriteTraceGood) || in CheckDeviceGrabs()
4040 (pWin && pWin != device->spriteInfo->sprite->spriteTrace[i - 1])) in CheckDeviceGrabs()
4044 for (; i < device->spriteInfo->sprite->spriteTraceGood; i++) { in CheckDeviceGrabs()
4045 pWin = device->spriteInfo->sprite->spriteTrace[i]; in CheckDeviceGrabs()
4046 if (CheckPassiveGrabsOnWindow(pWin, device, (InternalEvent *) event, in CheckDeviceGrabs()
4054 if (ret == TRUE && event->type == ET_KeyPress) in CheckDeviceGrabs()
4055 device->deviceGrab.activatingKey = event->detail.key; in CheckDeviceGrabs()
4060 * Called for keyboard events to deliver event to whatever client owns the
4063 * The event is delivered to the keyboard's focus window, the root window or
4066 * @param keybd The keyboard originating the event.
4067 * @param event The event, not yet in wire format.
4071 DeliverFocusedEvent(DeviceIntPtr keybd, InternalEvent *event, WindowPtr window) in DeliverFocusedEvent() argument
4074 WindowPtr focus = keybd->focus->win; in DeliverFocusedEvent()
4075 BOOL sendCore = (IsMaster(keybd) && keybd->coreEvents); in DeliverFocusedEvent()
4081 focus = inputInfo.keyboard->focus->win; in DeliverFocusedEvent()
4085 DeliverDeviceEvents(window, event, NullGrab, NullWindow, keybd); in DeliverFocusedEvent()
4089 if (DeliverDeviceEvents(window, event, NullGrab, focus, keybd)) in DeliverFocusedEvent()
4096 rc = EventToXI2(event, &xi2); in DeliverFocusedEvent()
4101 FixUpEventFromWindow(ptr->spriteInfo->sprite, xi2, focus, None, FALSE); in DeliverFocusedEvent()
4110 keybd->name, event->any.type, rc); in DeliverFocusedEvent()
4112 rc = EventToXI(event, &xE, &count); in DeliverFocusedEvent()
4115 FixUpEventFromWindow(ptr->spriteInfo->sprite, xE, focus, None, FALSE); in DeliverFocusedEvent()
4125 keybd->name, event->any.type, rc); in DeliverFocusedEvent()
4128 rc = EventToCore(event, &core, &count); in DeliverFocusedEvent()
4132 FixUpEventFromWindow(keybd->spriteInfo->sprite, core, focus, in DeliverFocusedEvent()
4143 keybd->name, event->any.type, rc); in DeliverFocusedEvent()
4154 DeliverOneGrabbedEvent(InternalEvent *event, DeviceIntPtr dev, in DeliverOneGrabbedEvent() argument
4157 SpritePtr pSprite = dev->spriteInfo->sprite; in DeliverOneGrabbedEvent()
4163 GrabInfoPtr grabinfo = &dev->deviceGrab; in DeliverOneGrabbedEvent()
4164 GrabPtr grab = grabinfo->grab; in DeliverOneGrabbedEvent()
4167 if (grab->grabtype != level) in DeliverOneGrabbedEvent()
4172 rc = EventToXI2(event, &xE); in DeliverOneGrabbedEvent()
4177 mask = GetXI2MaskByte(grab->xi2mask, dev, evtype); in DeliverOneGrabbedEvent()
4182 if (grabinfo->fromPassiveGrab && grabinfo->implicitGrab) in DeliverOneGrabbedEvent()
4183 mask = grab->deviceMask; in DeliverOneGrabbedEvent()
4185 mask = grab->eventMask; in DeliverOneGrabbedEvent()
4186 rc = EventToXI(event, &xE, &count); in DeliverOneGrabbedEvent()
4191 rc = EventToCore(event, &xE, &count); in DeliverOneGrabbedEvent()
4192 mask = grab->eventMask; in DeliverOneGrabbedEvent()
4202 FixUpEventFromWindow(pSprite, xE, grab->window, None, TRUE); in DeliverOneGrabbedEvent()
4204 grab->window, xE, count) || in DeliverOneGrabbedEvent()
4206 grab->window, xE, count)) in DeliverOneGrabbedEvent()
4216 dev->name, level, event->any.type, rc); in DeliverOneGrabbedEvent()
4223 * Deliver an event from a device that is currently grabbed. Uses
4232 DeliverGrabbedEvent(InternalEvent *event, DeviceIntPtr thisDev, in DeliverGrabbedEvent() argument
4239 SpritePtr pSprite = thisDev->spriteInfo->sprite; in DeliverGrabbedEvent()
4242 grabinfo = &thisDev->deviceGrab; in DeliverGrabbedEvent()
4243 grab = grabinfo->grab; in DeliverGrabbedEvent()
4245 if (grab->ownerEvents) { in DeliverGrabbedEvent()
4249 * for the type of event, to see if we really want to deliver it to in DeliverGrabbedEvent()
4252 if (IsPointerEvent(event)) in DeliverGrabbedEvent()
4254 else if (thisDev->focus) { in DeliverGrabbedEvent()
4255 focus = thisDev->focus->win; in DeliverGrabbedEvent()
4257 focus = inputInfo.keyboard->focus->win; in DeliverGrabbedEvent()
4262 deliveries = DeliverDeviceEvents(pSprite->win, event, grab, in DeliverGrabbedEvent()
4264 else if (focus && (focus == pSprite->win || in DeliverGrabbedEvent()
4265 IsParent(focus, pSprite->win))) in DeliverGrabbedEvent()
4266 deliveries = DeliverDeviceEvents(pSprite->win, event, grab, focus, in DeliverGrabbedEvent()
4269 deliveries = DeliverDeviceEvents(focus, event, grab, focus, in DeliverGrabbedEvent()
4273 sendCore = (IsMaster(thisDev) && thisDev->coreEvents); in DeliverGrabbedEvent()
4274 /* try core event */ in DeliverGrabbedEvent()
4275 if ((sendCore && grab->grabtype == CORE) || grab->grabtype != CORE) in DeliverGrabbedEvent()
4276 deliveries = DeliverOneGrabbedEvent(event, thisDev, grab->grabtype); in DeliverGrabbedEvent()
4278 if (deliveries && (event->any.type == ET_Motion)) in DeliverGrabbedEvent()
4279 thisDev->valuator->motionHintWindow = grab->window; in DeliverGrabbedEvent()
4282 (event->any.type == ET_KeyPress || in DeliverGrabbedEvent()
4283 event->any.type == ET_KeyRelease || in DeliverGrabbedEvent()
4284 event->any.type == ET_ButtonPress || in DeliverGrabbedEvent()
4285 event->any.type == ET_ButtonRelease)) { in DeliverGrabbedEvent()
4286 switch (grabinfo->sync.state) { in DeliverGrabbedEvent()
4291 if ((dev->deviceGrab.sync.state == FREEZE_BOTH_NEXT_EVENT) && in DeliverGrabbedEvent()
4292 (CLIENT_BITS(grab->resource) == in DeliverGrabbedEvent()
4293 CLIENT_BITS(dev->deviceGrab.grab->resource))) in DeliverGrabbedEvent()
4294 dev->deviceGrab.sync.state = FROZEN_NO_EVENT; in DeliverGrabbedEvent()
4296 dev->deviceGrab.sync.other = grab; in DeliverGrabbedEvent()
4300 grabinfo->sync.state = FROZEN_WITH_EVENT; in DeliverGrabbedEvent()
4302 *grabinfo->sync.event = event->device_event; in DeliverGrabbedEvent()
4310 /* This function is used to set the key pressed or key released state -
4315 FixKeyState(DeviceEvent *event, DeviceIntPtr keybd) in FixKeyState() argument
4317 int key = event->detail.key; in FixKeyState()
4319 if (event->type == ET_KeyPress) { in FixKeyState()
4321 ((event->type == ET_KeyPress) ? "down" : "up")); in FixKeyState()
4324 if (event->type == ET_KeyPress) in FixKeyState()
4326 else if (event->type == ET_KeyRelease) in FixKeyState()
4329 FatalError("Impossible keyboard event"); in FixKeyState()
4342 * The otherEventMasks on a WindowOptional is the combination of all event
4357 if (pChild->optional) { in RecalculateDeliverableEvents()
4358 pChild->optional->otherEventMasks = 0; in RecalculateDeliverableEvents()
4359 for (others = wOtherClients(pChild); others; others = others->next) { in RecalculateDeliverableEvents()
4360 pChild->optional->otherEventMasks |= others->mask; in RecalculateDeliverableEvents()
4363 pChild->deliverableEvents = pChild->eventMask | in RecalculateDeliverableEvents()
4365 if (pChild->parent) in RecalculateDeliverableEvents()
4366 pChild->deliverableEvents |= in RecalculateDeliverableEvents()
4367 (pChild->parent->deliverableEvents & in RecalculateDeliverableEvents()
4369 if (pChild->firstChild) { in RecalculateDeliverableEvents()
4370 pChild = pChild->firstChild; in RecalculateDeliverableEvents()
4373 while (!pChild->nextSib && (pChild != pWin)) in RecalculateDeliverableEvents()
4374 pChild = pChild->parent; in RecalculateDeliverableEvents()
4377 pChild = pChild->nextSib; in RecalculateDeliverableEvents()
4392 for (other = wOtherClients(pWin); other; other = other->next) { in OtherClientGone()
4393 if (other->resource == id) { in OtherClientGone()
4395 prev->next = other->next; in OtherClientGone()
4397 if (!(pWin->optional->otherClients = other->next)) in OtherClientGone()
4406 FatalError("client not on event list"); in OtherClientGone()
4418 client->errorValue = mask; in EventSelectForWindow()
4423 rc = XaceHook(XACE_RESOURCE_ACCESS, client, pWin->drawable.id, in EventSelectForWindow()
4429 if (check & (pWin->eventMask | wOtherEventMasks(pWin))) { in EventSelectForWindow()
4433 if ((wClient(pWin) != client) && (check & pWin->eventMask)) in EventSelectForWindow()
4435 for (others = wOtherClients(pWin); others; others = others->next) { in EventSelectForWindow()
4436 if (!SameClient(others, client) && (check & others->mask)) in EventSelectForWindow()
4441 check = pWin->eventMask; in EventSelectForWindow()
4442 pWin->eventMask = mask; in EventSelectForWindow()
4445 for (others = wOtherClients(pWin); others; others = others->next) { in EventSelectForWindow()
4447 check = others->mask; in EventSelectForWindow()
4449 FreeResource(others->resource, RT_NONE); in EventSelectForWindow()
4453 others->mask = mask; in EventSelectForWindow()
4458 if (!pWin->optional && !MakeWindowOptional(pWin)) in EventSelectForWindow()
4463 others->mask = mask; in EventSelectForWindow()
4464 others->resource = FakeClientID(client->index); in EventSelectForWindow()
4465 others->next = pWin->optional->otherClients; in EventSelectForWindow()
4466 pWin->optional->otherClients = others; in EventSelectForWindow()
4467 if (!AddResource(others->resource, RT_OTHERCLIENT, (void *) pWin)) in EventSelectForWindow()
4472 for (dev = inputInfo.devices; dev; dev = dev->next) { in EventSelectForWindow()
4473 if (dev->valuator && dev->valuator->motionHintWindow == pWin) in EventSelectForWindow()
4474 dev->valuator->motionHintWindow = NullWindow; in EventSelectForWindow()
4488 client->errorValue = mask; in EventSuppressForWindow()
4491 if (pWin->dontPropagate) in EventSuppressForWindow()
4492 DontPropagateRefCnts[pWin->dontPropagate]--; in EventSuppressForWindow()
4496 for (i = DNPMCOUNT, freed = 0; --i > 0;) { in EventSuppressForWindow()
4508 pWin->dontPropagate = i; in EventSuppressForWindow()
4511 if (pWin->optional) { in EventSuppressForWindow()
4512 pWin->optional->dontPropagateMask = mask; in EventSuppressForWindow()
4517 if (!pWin->optional && !MakeWindowOptional(pWin)) { in EventSuppressForWindow()
4518 if (pWin->dontPropagate) in EventSuppressForWindow()
4519 DontPropagateRefCnts[pWin->dontPropagate]++; in EventSuppressForWindow()
4522 pWin->dontPropagate = 0; in EventSuppressForWindow()
4523 pWin->optional->dontPropagateMask = mask; in EventSuppressForWindow()
4530 * Assembles an EnterNotify or LeaveNotify and sends it event to the client.
4538 xEvent event = { in CoreEnterLeaveEvent() local
4544 GrabPtr grab = mouse->deviceGrab.grab; in CoreEnterLeaveEvent()
4549 if ((pWin == mouse->valuator->motionHintWindow) && in CoreEnterLeaveEvent()
4551 mouse->valuator->motionHintWindow = NullWindow; in CoreEnterLeaveEvent()
4553 mask = (pWin == grab->window) ? grab->eventMask : 0; in CoreEnterLeaveEvent()
4554 if (grab->ownerEvents) in CoreEnterLeaveEvent()
4558 mask = pWin->eventMask | wOtherEventMasks(pWin); in CoreEnterLeaveEvent()
4561 event.u.enterLeave.time = currentTime.milliseconds; in CoreEnterLeaveEvent()
4562 event.u.enterLeave.rootX = mouse->spriteInfo->sprite->hot.x; in CoreEnterLeaveEvent()
4563 event.u.enterLeave.rootY = mouse->spriteInfo->sprite->hot.y; in CoreEnterLeaveEvent()
4565 FixUpEventFromWindow(mouse->spriteInfo->sprite, &event, pWin, None, FALSE); in CoreEnterLeaveEvent()
4567 event.u.enterLeave.child = child; in CoreEnterLeaveEvent()
4568 event.u.enterLeave.flags = event.u.keyButtonPointer.sameScreen ? in CoreEnterLeaveEvent()
4570 event.u.enterLeave.state = in CoreEnterLeaveEvent()
4571 mouse->button ? (mouse->button->state & 0x1f00) : 0; in CoreEnterLeaveEvent()
4573 event.u.enterLeave.state |= in CoreEnterLeaveEvent()
4574 XkbGrabStateFromRec(&keybd->key->xkbInfo->state); in CoreEnterLeaveEvent()
4575 event.u.enterLeave.mode = mode; in CoreEnterLeaveEvent()
4576 focus = (keybd) ? keybd->focus->win : None; in CoreEnterLeaveEvent()
4579 event.u.enterLeave.flags |= ELFlagFocus; in CoreEnterLeaveEvent()
4581 if ((mask & GetEventFilter(mouse, &event))) { in CoreEnterLeaveEvent()
4583 TryClientEvents(rClient(grab), mouse, &event, 1, mask, in CoreEnterLeaveEvent()
4584 GetEventFilter(mouse, &event), grab); in CoreEnterLeaveEvent()
4586 DeliverEventsToWindow(mouse, pWin, &event, 1, in CoreEnterLeaveEvent()
4587 GetEventFilter(mouse, &event), NullGrab); in CoreEnterLeaveEvent()
4599 memcpy((char *) &ke.map[0], (char *) &keybd->key->down[1], 31); in CoreEnterLeaveEvent()
4616 GrabPtr grab = mouse->deviceGrab.grab; in DeviceEnterLeaveEvent()
4617 xXIEnterEvent *event; in DeviceEnterLeaveEvent() local
4627 btlen = (mouse->button) ? bits_to_bytes(mouse->button->numButtons) : 0; in DeviceEnterLeaveEvent()
4631 event = calloc(1, len); in DeviceEnterLeaveEvent()
4632 event->type = GenericEvent; in DeviceEnterLeaveEvent()
4633 event->extension = IReqCode; in DeviceEnterLeaveEvent()
4634 event->evtype = type; in DeviceEnterLeaveEvent()
4635 event->length = (len - sizeof(xEvent)) / 4; in DeviceEnterLeaveEvent()
4636 event->buttons_len = btlen; in DeviceEnterLeaveEvent()
4637 event->detail = detail; in DeviceEnterLeaveEvent()
4638 event->time = currentTime.milliseconds; in DeviceEnterLeaveEvent()
4639 event->deviceid = mouse->id; in DeviceEnterLeaveEvent()
4640 event->sourceid = sourceid; in DeviceEnterLeaveEvent()
4641 event->mode = mode; in DeviceEnterLeaveEvent()
4642 event->root_x = double_to_fp1616(mouse->spriteInfo->sprite->hot.x); in DeviceEnterLeaveEvent()
4643 event->root_y = double_to_fp1616(mouse->spriteInfo->sprite->hot.y); in DeviceEnterLeaveEvent()
4645 for (i = 0; mouse && mouse->button && i < mouse->button->numButtons; i++) in DeviceEnterLeaveEvent()
4646 if (BitIsOn(mouse->button->down, i)) in DeviceEnterLeaveEvent()
4647 SetBit(&event[1], i); in DeviceEnterLeaveEvent()
4650 if (kbd && kbd->key) { in DeviceEnterLeaveEvent()
4651 event->mods.base_mods = kbd->key->xkbInfo->state.base_mods; in DeviceEnterLeaveEvent()
4652 event->mods.latched_mods = kbd->key->xkbInfo->state.latched_mods; in DeviceEnterLeaveEvent()
4653 event->mods.locked_mods = kbd->key->xkbInfo->state.locked_mods; in DeviceEnterLeaveEvent()
4655 event->group.base_group = kbd->key->xkbInfo->state.base_group; in DeviceEnterLeaveEvent()
4656 event->group.latched_group = kbd->key->xkbInfo->state.latched_group; in DeviceEnterLeaveEvent()
4657 event->group.locked_group = kbd->key->xkbInfo->state.locked_group; in DeviceEnterLeaveEvent()
4660 focus = (kbd) ? kbd->focus->win : None; in DeviceEnterLeaveEvent()
4663 event->focus = TRUE; in DeviceEnterLeaveEvent()
4665 FixUpEventFromWindow(mouse->spriteInfo->sprite, (xEvent *) event, pWin, in DeviceEnterLeaveEvent()
4668 filter = GetEventFilter(mouse, (xEvent *) event); in DeviceEnterLeaveEvent()
4670 if (grab && grab->grabtype == XI2) { in DeviceEnterLeaveEvent()
4673 mask = xi2mask_isset(grab->xi2mask, mouse, type); in DeviceEnterLeaveEvent()
4674 TryClientEvents(rClient(grab), mouse, (xEvent *) event, 1, mask, 1, in DeviceEnterLeaveEvent()
4678 if (!WindowXI2MaskIsset(mouse, pWin, (xEvent *) event)) in DeviceEnterLeaveEvent()
4680 DeliverEventsToWindow(mouse, pWin, (xEvent *) event, 1, filter, in DeviceEnterLeaveEvent()
4685 free(event); in DeviceEnterLeaveEvent()
4691 xEvent event = { in CoreFocusEvent() local
4695 event.u.focus.mode = mode; in CoreFocusEvent()
4696 event.u.focus.window = pWin->drawable.id; in CoreFocusEvent()
4698 DeliverEventsToWindow(dev, pWin, &event, 1, in CoreFocusEvent()
4699 GetEventFilter(dev, &event), NullGrab); in CoreFocusEvent()
4701 ((pWin->eventMask | wOtherEventMasks(pWin)) & KeymapStateMask)) { in CoreFocusEvent()
4710 memcpy((char *) &ke.map[0], (char *) &dev->key->down[1], 31); in CoreFocusEvent()
4750 client->errorValue = revertTo; in SetInputFocus()
4760 focusWin = keybd->focus->win; in SetInputFocus()
4768 if (!focusWin->realized) in SetInputFocus()
4775 focus = dev->focus; in SetInputFocus()
4777 (CompareTimeStamps(time, focus->time) == EARLIER)) in SetInputFocus()
4779 mode = (dev->deviceGrab.grab) ? NotifyWhileGrabbed : NotifyNormal; in SetInputFocus()
4780 if (focus->win == FollowKeyboardWin) { in SetInputFocus()
4781 if (!ActivateFocusInGrab(dev, keybd->focus->win, focusWin)) in SetInputFocus()
4782 DoFocusEvents(dev, keybd->focus->win, focusWin, mode); in SetInputFocus()
4785 if (!ActivateFocusInGrab(dev, focus->win, focusWin)) in SetInputFocus()
4786 DoFocusEvents(dev, focus->win, focusWin, mode); in SetInputFocus()
4788 focus->time = time; in SetInputFocus()
4789 focus->revert = revertTo; in SetInputFocus()
4791 focus->win = FollowKeyboardWin; in SetInputFocus()
4793 focus->win = focusWin; in SetInputFocus()
4795 focus->traceGood = 0; in SetInputFocus()
4800 for (pWin = focusWin; pWin; pWin = pWin->parent) in SetInputFocus()
4802 if (depth > focus->traceSize) { in SetInputFocus()
4803 focus->traceSize = depth + 1; in SetInputFocus()
4804 focus->trace = reallocarray(focus->trace, focus->traceSize, in SetInputFocus()
4807 focus->traceGood = depth; in SetInputFocus()
4808 for (pWin = focusWin, depth--; pWin; pWin = pWin->parent, depth--) in SetInputFocus()
4809 focus->trace[depth] = pWin; in SetInputFocus()
4815 * Server-side protocol handling for SetInputFocus request.
4828 return SetInputFocus(client, kbd, stuff->focus, in ProcSetInputFocus()
4829 stuff->revertTo, stuff->time, FALSE); in ProcSetInputFocus()
4833 * Server-side protocol handling for GetInputFocus request.
4843 FocusClassPtr focus = kbd->focus; in ProcGetInputFocus()
4856 .sequenceNumber = client->sequence, in ProcGetInputFocus()
4857 .revertTo = focus->revert in ProcGetInputFocus()
4860 if (focus->win == NoneWin) in ProcGetInputFocus()
4862 else if (focus->win == PointerRootWin) in ProcGetInputFocus()
4865 rep.focus = focus->win->drawable.id; in ProcGetInputFocus()
4872 * Server-side protocol handling for GrabPointer request.
4893 if (stuff->eventMask & ~PointerGrabMask) { in ProcGrabPointer()
4894 client->errorValue = stuff->eventMask; in ProcGrabPointer()
4898 if (stuff->confineTo == None) in ProcGrabPointer()
4901 rc = dixLookupWindow(&confineTo, stuff->confineTo, client, in ProcGrabPointer()
4907 grab = device->deviceGrab.grab; in ProcGrabPointer()
4909 if (grab && grab->confineTo && !confineTo) in ProcGrabPointer()
4912 mask.core = stuff->eventMask; in ProcGrabPointer()
4914 rc = GrabDevice(client, device, stuff->pointerMode, stuff->keyboardMode, in ProcGrabPointer()
4915 stuff->grabWindow, stuff->ownerEvents, stuff->time, in ProcGrabPointer()
4916 &mask, CORE, stuff->cursor, stuff->confineTo, &status); in ProcGrabPointer()
4923 .sequenceNumber = client->sequence, in ProcGrabPointer()
4931 * Server-side protocol handling for ChangeActivePointerGrab request.
4947 if (stuff->eventMask & ~PointerGrabMask) { in ProcChangeActivePointerGrab()
4948 client->errorValue = stuff->eventMask; in ProcChangeActivePointerGrab()
4951 if (stuff->cursor == None) in ProcChangeActivePointerGrab()
4954 int rc = dixLookupResourceByType((void **) &newCursor, stuff->cursor, in ProcChangeActivePointerGrab()
4958 client->errorValue = stuff->cursor; in ProcChangeActivePointerGrab()
4964 grab = device->deviceGrab.grab; in ProcChangeActivePointerGrab()
4971 time = ClientTimeToServerTime(stuff->time); in ProcChangeActivePointerGrab()
4973 (CompareTimeStamps(time, device->deviceGrab.grabTime) == EARLIER)) in ProcChangeActivePointerGrab()
4975 oldCursor = grab->cursor; in ProcChangeActivePointerGrab()
4976 grab->cursor = RefCursor(newCursor); in ProcChangeActivePointerGrab()
4980 grab->eventMask = stuff->eventMask; in ProcChangeActivePointerGrab()
4985 * Server-side protocol handling for UngrabPointer request.
5000 grab = device->deviceGrab.grab; in ProcUngrabPointer()
5002 time = ClientTimeToServerTime(stuff->id); in ProcUngrabPointer()
5004 (CompareTimeStamps(time, device->deviceGrab.grabTime) != EARLIER) && in ProcUngrabPointer()
5006 (*device->deviceGrab.DeactivateGrab) (device); in ProcUngrabPointer()
5039 GrabInfoPtr grabInfo = &dev->deviceGrab; in GrabDevice()
5044 client->errorValue = keyboard_mode; in GrabDevice()
5048 client->errorValue = pointer_mode; in GrabDevice()
5052 client->errorValue = ownerEvents; in GrabDevice()
5075 client->errorValue = curs; in GrabDevice()
5088 grab = grabInfo->grab; in GrabDevice()
5089 if (grab && grab->grabtype != grabtype) in GrabDevice()
5093 else if ((!pWin->realized) || in GrabDevice()
5095 !(confineTo->realized && BorderSizeNotEmpty(dev, confineTo)))) in GrabDevice()
5098 (CompareTimeStamps(time, grabInfo->grabTime) == EARLIER)) in GrabDevice()
5100 else if (grabInfo->sync.frozen && in GrabDevice()
5101 grabInfo->sync.other && !SameClient(grabInfo->sync.other, client)) in GrabDevice()
5110 tempGrab->next = NULL; in GrabDevice()
5111 tempGrab->window = pWin; in GrabDevice()
5112 tempGrab->resource = client->clientAsMask; in GrabDevice()
5113 tempGrab->ownerEvents = ownerEvents; in GrabDevice()
5114 tempGrab->keyboardMode = keyboard_mode; in GrabDevice()
5115 tempGrab->pointerMode = pointer_mode; in GrabDevice()
5117 tempGrab->eventMask = mask->core; in GrabDevice()
5119 tempGrab->eventMask = mask->xi; in GrabDevice()
5121 xi2mask_merge(tempGrab->xi2mask, mask->xi2mask); in GrabDevice()
5122 tempGrab->device = dev; in GrabDevice()
5123 tempGrab->cursor = RefCursor(cursor); in GrabDevice()
5124 tempGrab->confineTo = confineTo; in GrabDevice()
5125 tempGrab->grabtype = grabtype; in GrabDevice()
5126 (*grabInfo->ActivateGrab) (dev, tempGrab, time, FALSE); in GrabDevice()
5135 * Server-side protocol handling for GrabKeyboard request.
5155 result = GrabDevice(client, keyboard, stuff->pointerMode, in ProcGrabKeyboard()
5156 stuff->keyboardMode, stuff->grabWindow, in ProcGrabKeyboard()
5157 stuff->ownerEvents, stuff->time, &mask, CORE, None, in ProcGrabKeyboard()
5166 .sequenceNumber = client->sequence, in ProcGrabKeyboard()
5174 * Server-side protocol handling for UngrabKeyboard request.
5190 grab = device->deviceGrab.grab; in ProcUngrabKeyboard()
5192 time = ClientTimeToServerTime(stuff->id); in ProcUngrabKeyboard()
5194 (CompareTimeStamps(time, device->deviceGrab.grabTime) != EARLIER) && in ProcUngrabKeyboard()
5195 (grab) && SameClient(grab, client) && grab->grabtype == CORE) in ProcUngrabKeyboard()
5196 (*device->deviceGrab.DeactivateGrab) (device); in ProcUngrabKeyboard()
5201 * Server-side protocol handling for QueryPointer request.
5219 rc = dixLookupWindow(&pWin, stuff->id, client, DixGetAttrAccess); in ProcQueryPointer()
5228 pSprite = mouse->spriteInfo->sprite; in ProcQueryPointer()
5229 if (mouse->valuator->motionHintWindow) in ProcQueryPointer()
5233 .sequenceNumber = client->sequence, in ProcQueryPointer()
5236 .root = (GetCurrentRootWindow(mouse))->drawable.id, in ProcQueryPointer()
5237 .rootX = pSprite->hot.x, in ProcQueryPointer()
5238 .rootY = pSprite->hot.y, in ProcQueryPointer()
5241 if (pSprite->hot.pScreen == pWin->drawable.pScreen) { in ProcQueryPointer()
5243 rep.winX = pSprite->hot.x - pWin->drawable.x; in ProcQueryPointer()
5244 rep.winY = pSprite->hot.y - pWin->drawable.y; in ProcQueryPointer()
5245 for (t = pSprite->win; t; t = t->parent) in ProcQueryPointer()
5246 if (t->parent == pWin) { in ProcQueryPointer()
5247 rep.child = t->drawable.id; in ProcQueryPointer()
5259 rep.rootX += screenInfo.screens[0]->x; in ProcQueryPointer()
5260 rep.rootY += screenInfo.screens[0]->y; in ProcQueryPointer()
5261 if (stuff->id == rep.root) { in ProcQueryPointer()
5262 rep.winX += screenInfo.screens[0]->x; in ProcQueryPointer()
5263 rep.winY += screenInfo.screens[0]->y; in ProcQueryPointer()
5325 FatalError("[dix] Failed to allocate input event list.\n"); in InitEvents()
5338 * Server-side protocol handling for SendEvent request.
5340 * Locates the window to send the event to and forwards the event.
5349 SpritePtr pSprite = dev->spriteInfo->sprite; in ProcSendEvent()
5356 * that this event came from a SendEvent request so remove it in ProcSendEvent()
5357 * since otherwise the event type may fail the range checks in ProcSendEvent()
5361 * back in once we send the event to the client */ in ProcSendEvent()
5363 stuff->event.u.u.type &= ~(SEND_EVENT_BIT); in ProcSendEvent()
5365 /* The client's event type must be a core event type or one defined by an in ProcSendEvent()
5368 if (!((stuff->event.u.u.type > X_Reply && in ProcSendEvent()
5369 stuff->event.u.u.type < LASTEvent) || in ProcSendEvent()
5370 (stuff->event.u.u.type >= EXTENSION_EVENT_BASE && in ProcSendEvent()
5371 stuff->event.u.u.type < (unsigned) lastEvent))) { in ProcSendEvent()
5372 client->errorValue = stuff->event.u.u.type; in ProcSendEvent()
5376 exactly 32B of event data. */ in ProcSendEvent()
5377 if (stuff->event.u.u.type == GenericEvent) { in ProcSendEvent()
5378 client->errorValue = stuff->event.u.u.type; in ProcSendEvent()
5381 if (stuff->event.u.u.type == ClientMessage && in ProcSendEvent()
5382 stuff->event.u.u.detail != 8 && in ProcSendEvent()
5383 stuff->event.u.u.detail != 16 && stuff->event.u.u.detail != 32) { in ProcSendEvent()
5384 client->errorValue = stuff->event.u.u.detail; in ProcSendEvent()
5387 if (stuff->eventMask & ~AllEventMasks) { in ProcSendEvent()
5388 client->errorValue = stuff->eventMask; in ProcSendEvent()
5392 if (stuff->destination == PointerWindow) in ProcSendEvent()
5393 pWin = pSprite->win; in ProcSendEvent()
5394 else if (stuff->destination == InputFocus) { in ProcSendEvent()
5395 WindowPtr inputFocus = (keybd) ? keybd->focus->win : NoneWin; in ProcSendEvent()
5400 /* If the input focus is PointerRootWin, send the event to where in ProcSendEvent()
5405 if (IsParent(inputFocus, pSprite->win)) { in ProcSendEvent()
5407 pWin = pSprite->win; in ProcSendEvent()
5413 dixLookupWindow(&pWin, stuff->destination, client, DixSendAccess); in ProcSendEvent()
5417 if ((stuff->propagate != xFalse) && (stuff->propagate != xTrue)) { in ProcSendEvent()
5418 client->errorValue = stuff->propagate; in ProcSendEvent()
5421 stuff->event.u.u.type |= SEND_EVENT_BIT; in ProcSendEvent()
5422 if (stuff->propagate) { in ProcSendEvent()
5423 for (; pWin; pWin = pWin->parent) { in ProcSendEvent()
5425 &stuff->event, 1)) in ProcSendEvent()
5428 &stuff->event, 1, stuff->eventMask, in ProcSendEvent()
5433 stuff->eventMask &= ~wDontPropagateMask(pWin); in ProcSendEvent()
5434 if (!stuff->eventMask) in ProcSendEvent()
5438 else if (!XaceHook(XACE_SEND_ACCESS, client, NULL, pWin, &stuff->event, 1)) in ProcSendEvent()
5439 DeliverEventsToWindow(dev, pWin, &stuff->event, in ProcSendEvent()
5440 1, stuff->eventMask, NullGrab); in ProcSendEvent()
5445 * Server-side protocol handling for UngrabKey request.
5460 rc = dixLookupWindow(&pWin, stuff->grabWindow, client, DixGetAttrAccess); in ProcUngrabKey()
5464 if (((stuff->key > keybd->key->xkbInfo->desc->max_key_code) || in ProcUngrabKey()
5465 (stuff->key < keybd->key->xkbInfo->desc->min_key_code)) in ProcUngrabKey()
5466 && (stuff->key != AnyKey)) { in ProcUngrabKey()
5467 client->errorValue = stuff->key; in ProcUngrabKey()
5470 if ((stuff->modifiers != AnyModifier) && in ProcUngrabKey()
5471 (stuff->modifiers & ~AllModifiersMask)) { in ProcUngrabKey()
5472 client->errorValue = stuff->modifiers; in ProcUngrabKey()
5478 tempGrab->resource = client->clientAsMask; in ProcUngrabKey()
5479 tempGrab->device = keybd; in ProcUngrabKey()
5480 tempGrab->window = pWin; in ProcUngrabKey()
5481 tempGrab->modifiersDetail.exact = stuff->modifiers; in ProcUngrabKey()
5482 tempGrab->modifiersDetail.pMask = NULL; in ProcUngrabKey()
5483 tempGrab->modifierDevice = keybd; in ProcUngrabKey()
5484 tempGrab->type = KeyPress; in ProcUngrabKey()
5485 tempGrab->grabtype = CORE; in ProcUngrabKey()
5486 tempGrab->detail.exact = stuff->key; in ProcUngrabKey()
5487 tempGrab->detail.pMask = NULL; in ProcUngrabKey()
5488 tempGrab->next = NULL; in ProcUngrabKey()
5499 * Server-side protocol handling for GrabKey request.
5520 .ownerEvents = stuff->ownerEvents, in ProcGrabKey()
5521 .this_device_mode = stuff->keyboardMode, in ProcGrabKey()
5522 .other_devices_mode = stuff->pointerMode, in ProcGrabKey()
5523 .modifiers = stuff->modifiers in ProcGrabKey()
5530 if (((stuff->key > keybd->key->xkbInfo->desc->max_key_code) || in ProcGrabKey()
5531 (stuff->key < keybd->key->xkbInfo->desc->min_key_code)) in ProcGrabKey()
5532 && (stuff->key != AnyKey)) { in ProcGrabKey()
5533 client->errorValue = stuff->key; in ProcGrabKey()
5536 rc = dixLookupWindow(&pWin, stuff->grabWindow, client, DixSetAttrAccess); in ProcGrabKey()
5542 grab = CreateGrab(client->index, keybd, keybd, pWin, CORE, &mask, in ProcGrabKey()
5543 &param, KeyPress, stuff->key, NullWindow, NullCursor); in ProcGrabKey()
5550 * Server-side protocol handling for GrabButton request.
5571 if ((stuff->pointerMode != GrabModeSync) && in ProcGrabButton()
5572 (stuff->pointerMode != GrabModeAsync)) { in ProcGrabButton()
5573 client->errorValue = stuff->pointerMode; in ProcGrabButton()
5576 if ((stuff->keyboardMode != GrabModeSync) && in ProcGrabButton()
5577 (stuff->keyboardMode != GrabModeAsync)) { in ProcGrabButton()
5578 client->errorValue = stuff->keyboardMode; in ProcGrabButton()
5581 if ((stuff->modifiers != AnyModifier) && in ProcGrabButton()
5582 (stuff->modifiers & ~AllModifiersMask)) { in ProcGrabButton()
5583 client->errorValue = stuff->modifiers; in ProcGrabButton()
5586 if ((stuff->ownerEvents != xFalse) && (stuff->ownerEvents != xTrue)) { in ProcGrabButton()
5587 client->errorValue = stuff->ownerEvents; in ProcGrabButton()
5590 if (stuff->eventMask & ~PointerGrabMask) { in ProcGrabButton()
5591 client->errorValue = stuff->eventMask; in ProcGrabButton()
5594 rc = dixLookupWindow(&pWin, stuff->grabWindow, client, DixSetAttrAccess); in ProcGrabButton()
5597 if (stuff->confineTo == None) in ProcGrabButton()
5600 rc = dixLookupWindow(&confineTo, stuff->confineTo, client, in ProcGrabButton()
5605 if (stuff->cursor == None) in ProcGrabButton()
5608 rc = dixLookupResourceByType((void **) &cursor, stuff->cursor, in ProcGrabButton()
5611 client->errorValue = stuff->cursor; in ProcGrabButton()
5619 if (stuff->pointerMode == GrabModeSync || in ProcGrabButton()
5620 stuff->keyboardMode == GrabModeSync) in ProcGrabButton()
5628 .ownerEvents = stuff->ownerEvents, in ProcGrabButton()
5629 .this_device_mode = stuff->keyboardMode, in ProcGrabButton()
5630 .other_devices_mode = stuff->pointerMode, in ProcGrabButton()
5631 .modifiers = stuff->modifiers in ProcGrabButton()
5634 mask.core = stuff->eventMask; in ProcGrabButton()
5636 grab = CreateGrab(client->index, ptr, modifierDevice, pWin, in ProcGrabButton()
5638 stuff->button, confineTo, cursor); in ProcGrabButton()
5645 * Server-side protocol handling for UngrabButton request.
5660 if ((stuff->modifiers != AnyModifier) && in ProcUngrabButton()
5661 (stuff->modifiers & ~AllModifiersMask)) { in ProcUngrabButton()
5662 client->errorValue = stuff->modifiers; in ProcUngrabButton()
5665 rc = dixLookupWindow(&pWin, stuff->grabWindow, client, DixReadAccess); in ProcUngrabButton()
5674 tempGrab->resource = client->clientAsMask; in ProcUngrabButton()
5675 tempGrab->device = ptr; in ProcUngrabButton()
5676 tempGrab->window = pWin; in ProcUngrabButton()
5677 tempGrab->modifiersDetail.exact = stuff->modifiers; in ProcUngrabButton()
5678 tempGrab->modifiersDetail.pMask = NULL; in ProcUngrabButton()
5679 tempGrab->modifierDevice = GetMaster(ptr, MASTER_KEYBOARD); in ProcUngrabButton()
5680 tempGrab->type = ButtonPress; in ProcUngrabButton()
5681 tempGrab->detail.exact = stuff->button; in ProcUngrabButton()
5682 tempGrab->grabtype = CORE; in ProcUngrabButton()
5683 tempGrab->detail.pMask = NULL; in ProcUngrabButton()
5684 tempGrab->next = NULL; in ProcUngrabButton()
5717 grab = mouse->deviceGrab.grab; in DeleteWindowFromAnyEvents()
5718 if (grab && ((grab->window == pWin) || (grab->confineTo == pWin))) in DeleteWindowFromAnyEvents()
5719 (*mouse->deviceGrab.DeactivateGrab) (mouse); in DeleteWindowFromAnyEvents()
5722 grab = keybd->deviceGrab.grab; in DeleteWindowFromAnyEvents()
5723 if (grab && (grab->window == pWin)) in DeleteWindowFromAnyEvents()
5724 (*keybd->deviceGrab.DeactivateGrab) (keybd); in DeleteWindowFromAnyEvents()
5727 for (mouse = inputInfo.devices; mouse; mouse = mouse->next) { in DeleteWindowFromAnyEvents()
5728 grab = mouse->deviceGrab.grab; in DeleteWindowFromAnyEvents()
5729 if (grab && ((grab->window == pWin) || (grab->confineTo == pWin))) in DeleteWindowFromAnyEvents()
5730 (*mouse->deviceGrab.DeactivateGrab) (mouse); in DeleteWindowFromAnyEvents()
5733 for (keybd = inputInfo.devices; keybd; keybd = keybd->next) { in DeleteWindowFromAnyEvents()
5735 focus = keybd->focus; in DeleteWindowFromAnyEvents()
5740 if ((pWin == focus->win) && (pWin->parent != NullWindow)) { in DeleteWindowFromAnyEvents()
5745 if (keybd->deviceGrab.grab) in DeleteWindowFromAnyEvents()
5748 switch (focus->revert) { in DeleteWindowFromAnyEvents()
5751 focus->win = NoneWin; in DeleteWindowFromAnyEvents()
5752 focus->traceGood = 0; in DeleteWindowFromAnyEvents()
5757 parent = parent->parent; in DeleteWindowFromAnyEvents()
5758 focus->traceGood--; in DeleteWindowFromAnyEvents()
5759 } while (!parent->realized in DeleteWindowFromAnyEvents()
5760 /* This would be a good protocol change -- windows being in DeleteWindowFromAnyEvents()
5767 || wClient(parent)->clientGone in DeleteWindowFromAnyEvents()
5772 focus->win = parent; in DeleteWindowFromAnyEvents()
5773 focus->revert = RevertToNone; in DeleteWindowFromAnyEvents()
5779 focus->win = PointerRootWin; in DeleteWindowFromAnyEvents()
5780 focus->traceGood = 0; in DeleteWindowFromAnyEvents()
5787 if (keybd->valuator->motionHintWindow == pWin) in DeleteWindowFromAnyEvents()
5788 keybd->valuator->motionHintWindow = NullWindow; in DeleteWindowFromAnyEvents()
5793 if (pWin->dontPropagate) in DeleteWindowFromAnyEvents()
5794 DontPropagateRefCnts[pWin->dontPropagate]--; in DeleteWindowFromAnyEvents()
5796 FreeResource(oc->resource, RT_NONE); in DeleteWindowFromAnyEvents()
5798 FreeResource(passive->resource, RT_NONE); in DeleteWindowFromAnyEvents()
5806 * there is a grab on the window, the cursor will be re-confined into the
5817 if (!noPanoramiXExtension && pWin->drawable.pScreen->myNum) in CheckCursorConfinement()
5821 for (pDev = inputInfo.devices; pDev; pDev = pDev->next) { in CheckCursorConfinement()
5823 grab = pDev->deviceGrab.grab; in CheckCursorConfinement()
5824 if (grab && (confineTo = grab->confineTo)) { in CheckCursorConfinement()
5826 (*pDev->deviceGrab.DeactivateGrab) (pDev); in CheckCursorConfinement()
5840 return pWin->eventMask; in EventMaskForClient()
5841 for (other = wOtherClients(pWin); other; other = other->next) { in EventMaskForClient()
5843 return other->mask; in EventMaskForClient()
5849 * Server-side protocol handling for RecolorCursor request.
5858 SpritePtr pSprite = PickPointer(client)->spriteInfo->sprite; in ProcRecolorCursor()
5863 rc = dixLookupResourceByType((void **) &pCursor, stuff->cursor, RT_CURSOR, in ProcRecolorCursor()
5866 client->errorValue = stuff->cursor; in ProcRecolorCursor()
5870 pCursor->foreRed = stuff->foreRed; in ProcRecolorCursor()
5871 pCursor->foreGreen = stuff->foreGreen; in ProcRecolorCursor()
5872 pCursor->foreBlue = stuff->foreBlue; in ProcRecolorCursor()
5874 pCursor->backRed = stuff->backRed; in ProcRecolorCursor()
5875 pCursor->backGreen = stuff->backGreen; in ProcRecolorCursor()
5876 pCursor->backBlue = stuff->backBlue; in ProcRecolorCursor()
5882 displayed = (pscr == pSprite->screen); in ProcRecolorCursor()
5885 displayed = (pscr == pSprite->hotPhys.pScreen); in ProcRecolorCursor()
5886 (*pscr->RecolorCursor) (PickPointer(client), pscr, pCursor, in ProcRecolorCursor()
5887 (pCursor == pSprite->current) && displayed); in ProcRecolorCursor()
5895 * the given event type.
5898 * can be more than one. Usually it's just one event.
5900 * Do not modify the event structure passed in. See comment below.
5904 * @param events The event list.
5915 if (!pClient || pClient == serverClient || pClient->clientGone) in WriteEventsToClient()
5920 events[i].u.u.sequenceNumber = pClient->sequence; in WriteEventsToClient()
5927 (screenInfo.screens[0]->x || screenInfo.screens[0]->y)) { in WriteEventsToClient()
5928 switch (events->u.u.type) { in WriteEventsToClient()
5937 When multiple clients want the same event DeliverEventsToWindow in WriteEventsToClient()
5938 passes the same event structure multiple times so we can't in WriteEventsToClient()
5943 eventCopy.u.keyButtonPointer.rootX += screenInfo.screens[0]->x; in WriteEventsToClient()
5944 eventCopy.u.keyButtonPointer.rootY += screenInfo.screens[0]->y; in WriteEventsToClient()
5945 if (eventCopy.u.keyButtonPointer.event == in WriteEventsToClient()
5947 eventCopy.u.keyButtonPointer.eventX += screenInfo.screens[0]->x; in WriteEventsToClient()
5948 eventCopy.u.keyButtonPointer.eventY += screenInfo.screens[0]->y; in WriteEventsToClient()
5969 XSERVER_SEND_EVENT(pClient->index, events[i].u.u.type, &events[i]); in WriteEventsToClient()
5982 if (events->u.u.type == GenericEvent) { in WriteEventsToClient()
5983 eventlength += ((xGenericEvent *) events)->length * 4; in WriteEventsToClient()
5986 if (pClient->swapped) { in WriteEventsToClient()
6001 this event was sent with "SendEvent." */ in WriteEventsToClient()
6002 (*EventSwapVector[eventFrom->u.u.type & 0177]) in WriteEventsToClient()
6020 * request/reply/event is processed and the choice of devices is ambiguous
6037 else if (!device->spriteInfo->spriteOwner) { in SetClientPointer()
6039 "Cannot be ClientPointer\n", device->id); in SetClientPointer()
6042 client->clientPtr = device; in SetClientPointer()
6060 for (it = inputInfo.devices; it; it = it->next) { in PickPointer()
6061 GrabPtr grab = it->deviceGrab.grab; in PickPointer()
6063 if (grab && grab->grabtype == CORE && SameClient(grab, client)) { in PickPointer()
6069 if (!client->clientPtr) { in PickPointer()
6072 if (IsMaster(it) && it->spriteInfo->spriteOwner) { in PickPointer()
6073 client->clientPtr = it; in PickPointer()
6076 it = it->next; in PickPointer()
6079 return client->clientPtr; in PickPointer()
6105 * Return true if a core event from the device would interfere and should not
6109 IsInterferingGrab(ClientPtr client, DeviceIntPtr dev, xEvent *event) in IsInterferingGrab() argument
6113 switch (event->u.u.type) { in IsInterferingGrab()
6126 if (dev->deviceGrab.grab && SameClient(dev->deviceGrab.grab, client)) in IsInterferingGrab()
6131 if (it->deviceGrab.grab && SameClient(it->deviceGrab.grab, client) in IsInterferingGrab()
6132 && !it->deviceGrab.fromPassiveGrab) { in IsInterferingGrab()
6138 it = it->next; in IsInterferingGrab()
6147 IsWrongPointerBarrierClient(ClientPtr client, DeviceIntPtr dev, xEvent *event) in IsWrongPointerBarrierClient() argument
6149 xXIBarrierEvent *ev = (xXIBarrierEvent*)event; in IsWrongPointerBarrierClient()
6151 if (ev->type != GenericEvent || ev->extension != IReqCode) in IsWrongPointerBarrierClient()
6154 if (ev->evtype != XI_BarrierHit && ev->evtype != XI_BarrierLeave) in IsWrongPointerBarrierClient()
6157 return client->index != CLIENT_ID(ev->barrier); in IsWrongPointerBarrierClient()