📄 events.c
字号:
(y >= pWin->drawable.y - wBorderWidth (pWin)) && (y < pWin->drawable.y + (int)pWin->drawable.height + wBorderWidth (pWin))#ifdef SHAPE /* When a window is shaped, a further check * is made to see if the point is inside * borderSize */ && (!wBoundingShape(pWin) || POINT_IN_REGION(pWin->drawable.pScreen, &pWin->borderSize, x, y, &box))#endif ) { if (spriteTraceGood >= spriteTraceSize) { spriteTraceSize += 10; Must_have_memory = TRUE; /* XXX */ spriteTrace = (WindowPtr *)xrealloc( spriteTrace, spriteTraceSize*sizeof(WindowPtr)); Must_have_memory = FALSE; /* XXX */ } spriteTrace[spriteTraceGood++] = pWin; pWin = pWin->firstChild; } else pWin = pWin->nextSib; } return spriteTrace[spriteTraceGood-1];}static Bool#if NeedFunctionPrototypesCheckMotion(xEvent *xE)#elseCheckMotion(xE) xEvent *xE;#endif{ WindowPtr prevSpriteWin = sprite.win; if (xE && !syncEvents.playingEvents) { if (sprite.hot.pScreen != sprite.hotPhys.pScreen) { sprite.hot.pScreen = sprite.hotPhys.pScreen; ROOT = WindowTable[sprite.hot.pScreen->myNum]; } sprite.hot.x = xE->u.keyButtonPointer.rootX; sprite.hot.y = xE->u.keyButtonPointer.rootY; if (sprite.hot.x < sprite.physLimits.x1) sprite.hot.x = sprite.physLimits.x1; else if (sprite.hot.x >= sprite.physLimits.x2) sprite.hot.x = sprite.physLimits.x2 - 1; if (sprite.hot.y < sprite.physLimits.y1) sprite.hot.y = sprite.physLimits.y1; else if (sprite.hot.y >= sprite.physLimits.y2) sprite.hot.y = sprite.physLimits.y2 - 1;#ifdef SHAPE if (sprite.hotShape) ConfineToShape(sprite.hotShape, &sprite.hot.x, &sprite.hot.y);#endif sprite.hotPhys = sprite.hot; if ((sprite.hotPhys.x != xE->u.keyButtonPointer.rootX) || (sprite.hotPhys.y != xE->u.keyButtonPointer.rootY)) (*sprite.hotPhys.pScreen->SetCursorPosition)( sprite.hotPhys.pScreen, sprite.hotPhys.x, sprite.hotPhys.y, FALSE); xE->u.keyButtonPointer.rootX = sprite.hot.x; xE->u.keyButtonPointer.rootY = sprite.hot.y; } sprite.win = XYToWindow(sprite.hot.x, sprite.hot.y);#ifdef notyet if (!(sprite.win->deliverableEvents & Motion_Filter(inputInfo.pointer->button)) !syncEvents.playingEvents) { /* XXX Do PointerNonInterestBox here */ }#endif if (sprite.win != prevSpriteWin) { if (prevSpriteWin != NullWindow) { if (!xE) UpdateCurrentTimeIf(); DoEnterLeaveEvents(prevSpriteWin, sprite.win, NotifyNormal); } PostNewCursor(); return FALSE; } return TRUE;}voidWindowsRestructured(){ (void) CheckMotion((xEvent *)NULL);}voidDefineInitialRootWindow(win) register WindowPtr win;{ register ScreenPtr pScreen = win->drawable.pScreen; sprite.hotPhys.pScreen = pScreen; sprite.hotPhys.x = pScreen->width / 2; sprite.hotPhys.y = pScreen->height / 2; sprite.hot = sprite.hotPhys; sprite.hotLimits.x2 = pScreen->width; sprite.hotLimits.y2 = pScreen->height; sprite.win = win; sprite.current = wCursor (win); spriteTraceGood = 1; ROOT = win; (*pScreen->CursorLimits) ( pScreen, sprite.current, &sprite.hotLimits, &sprite.physLimits); sprite.confined = FALSE; (*pScreen->ConstrainCursor) (pScreen, &sprite.physLimits); (*pScreen->SetCursorPosition) (pScreen, sprite.hot.x, sprite.hot.y, FALSE); (*pScreen->DisplayCursor) (pScreen, sprite.current);}/* * This does not take any shortcuts, and even ignores its argument, since * it does not happen very often, and one has to walk up the tree since * this might be a newly instantiated cursor for an intermediate window * between the one the pointer is in and the one that the last cursor was * instantiated from. *//*ARGSUSED*/voidWindowHasNewCursor(pWin) WindowPtr pWin;{ PostNewCursor();}voidNewCurrentScreen(newScreen, x, y) ScreenPtr newScreen; int x,y;{ sprite.hotPhys.x = x; sprite.hotPhys.y = y; if (newScreen != sprite.hotPhys.pScreen) ConfineCursorToWindow(WindowTable[newScreen->myNum], TRUE, FALSE);}intProcWarpPointer(client) ClientPtr client;{ WindowPtr dest = NULL; int x, y; ScreenPtr newScreen; REQUEST(xWarpPointerReq); REQUEST_SIZE_MATCH(xWarpPointerReq); if (stuff->dstWid != None) { dest = SecurityLookupWindow(stuff->dstWid, client, SecurityReadAccess); if (!dest) return BadWindow; } x = sprite.hotPhys.x; y = sprite.hotPhys.y; if (stuff->srcWid != None) { int winX, winY; WindowPtr source = SecurityLookupWindow(stuff->srcWid, client, SecurityReadAccess); if (!source) return BadWindow; winX = source->drawable.x; winY = source->drawable.y; if (source->drawable.pScreen != sprite.hotPhys.pScreen || x < winX + stuff->srcX || y < winY + stuff->srcY || (stuff->srcWidth != 0 && winX + stuff->srcX + (int)stuff->srcWidth < x) || (stuff->srcHeight != 0 && winY + stuff->srcY + (int)stuff->srcHeight < y) || !PointInWindowIsVisible(source, x, y)) return Success; } if (dest) { x = dest->drawable.x; y = dest->drawable.y; newScreen = dest->drawable.pScreen; } else newScreen = sprite.hotPhys.pScreen; x += stuff->dstX; y += stuff->dstY; if (x < 0) x = 0; else if (x >= newScreen->width) x = newScreen->width - 1; if (y < 0) y = 0; else if (y >= newScreen->height) y = newScreen->height - 1; if (newScreen == sprite.hotPhys.pScreen) { if (x < sprite.physLimits.x1) x = sprite.physLimits.x1; else if (x >= sprite.physLimits.x2) x = sprite.physLimits.x2 - 1; if (y < sprite.physLimits.y1) y = sprite.physLimits.y1; else if (y >= sprite.physLimits.y2) y = sprite.physLimits.y2 - 1;#ifdef SHAPE if (sprite.hotShape) ConfineToShape(sprite.hotShape, &x, &y);#endif (*newScreen->SetCursorPosition)(newScreen, x, y, TRUE); } else if (!PointerConfinedToScreen()) { NewCurrentScreen(newScreen, x, y); } return Success;}/* "CheckPassiveGrabsOnWindow" checks to see if the event passed in causes a passive grab set on the window to be activated. */static Bool#if NeedFunctionPrototypesCheckPassiveGrabsOnWindow( WindowPtr pWin, register DeviceIntPtr device, register xEvent *xE, int count)#elseCheckPassiveGrabsOnWindow(pWin, device, xE, count) WindowPtr pWin; register DeviceIntPtr device; register xEvent *xE; int count;#endif{ register GrabPtr grab = wPassiveGrabs(pWin); GrabRec tempGrab; register xEvent *dxE; if (!grab) return FALSE; tempGrab.window = pWin; tempGrab.device = device; tempGrab.type = xE->u.u.type; tempGrab.detail.exact = xE->u.u.detail; tempGrab.detail.pMask = NULL; tempGrab.modifiersDetail.pMask = NULL; for (; grab; grab = grab->next) {#ifdef XKB DeviceIntPtr gdev; XkbSrvInfoPtr xkbi; gdev= grab->modifierDevice; xkbi= gdev->key->xkbInfo;#endif tempGrab.modifierDevice = grab->modifierDevice; if (device == grab->modifierDevice && (xE->u.u.type == KeyPress#ifdef XINPUT || xE->u.u.type == DeviceKeyPress#endif )) tempGrab.modifiersDetail.exact =#ifdef XKB (noXkbExtension?gdev->key->prev_state:xkbi->state.grab_mods);#else grab->modifierDevice->key->prev_state;#endif else tempGrab.modifiersDetail.exact =#ifdef XKB (noXkbExtension ? gdev->key->state : xkbi->state.grab_mods);#else grab->modifierDevice->key->state;#endif if (GrabMatchesSecond(&tempGrab, grab) && (!grab->confineTo || (grab->confineTo->realized && REGION_NOTEMPTY( grab->confineTo->drawable.pScreen, &grab->confineTo->borderSize)))) {#ifdef XCSECURITY if (!SecurityCheckDeviceAccess(wClient(pWin), device, FALSE)) return FALSE;#endif#ifdef XKB if (!noXkbExtension) { xE->u.keyButtonPointer.state &= 0x1f00; xE->u.keyButtonPointer.state |= tempGrab.modifiersDetail.exact&(~0x1f00); }#endif (*device->ActivateGrab)(device, grab, currentTime, TRUE); FixUpEventFromWindow(xE, grab->window, None, TRUE); (void) TryClientEvents(rClient(grab), xE, count, filters[xE->u.u.type], filters[xE->u.u.type], grab); if (device->sync.state == FROZEN_NO_EVENT) { if (device->sync.evcount < count) { Must_have_memory = TRUE; /* XXX */ device->sync.event = (xEvent *)xrealloc(device->sync.event, count* sizeof(xEvent)); Must_have_memory = FALSE; /* XXX */ } device->sync.evcount = count; for (dxE = device->sync.event; --count >= 0; dxE++, xE++) *dxE = *xE; device->sync.state = FROZEN_WITH_EVENT; } return TRUE; } } return FALSE;}/*"CheckDeviceGrabs" handles both keyboard and pointer events that may causea passive grab to be activated. If the event is a keyboard event, theancestors of the focus window are traced down and tried to see if they haveany passive grabs to be activated. If the focus window itself is reached andit's descendants contain they pointer, the ancestors of the window that thepointer is in are then traced down starting at the focus window, otherwise nograbs are activated. If the event is a pointer event, the ancestors of thewindow that the pointer is in are traced down starting at the root untilCheckPassiveGrabs causes a passive grab to activate or all the windows aretried. PRH*/BoolCheckDeviceGrabs(device, xE, checkFirst, count) register DeviceIntPtr device; register xEvent *xE; int checkFirst; int count;{ register int i; register WindowPtr pWin; register FocusClassPtr focus = device->focus; if ((xE->u.u.type == ButtonPress#ifdef XINPUT || xE->u.u.type == DeviceButtonPress#endif ) && device->button->buttonsDown != 1) return FALSE; i = checkFirst; if (focus) { for (; i < focus->traceGood; i++) { pWin = focus->trace[i]; if (pWin->optional && CheckPassiveGrabsOnWindow(pWin, device, xE, count)) return TRUE; } if ((focus->win == NoneWin) || (i >= spriteTraceGood) || ((i > checkFirst) && (pWin != spriteTrace[i-1]))) return FALSE; } for (; i < spriteTraceGood; i++) { pWin = spriteTrace[i]; if (pWin->optional && CheckPassiveGrabsOnWindow(pWin, device, xE, count)) return TRUE; } return FALSE;}voidDeliverFocusedEvent(keybd, xE, window, count) xEvent *xE; DeviceIntPtr keybd; WindowPtr window; int count;{ WindowPtr focus = keybd->focus->win; int mskidx = 0; if (focus == FollowKeyboardWin) focus = inputInfo.keyboard->focus->win; if (!focus) return; if (focus == PointerRootWin) { DeliverDeviceEvents(window, xE, NullGrab, NullWindow, keybd, count); return; } if ((focus == window) || IsParent(focus, window)) { if (DeliverDeviceEvents(window, xE, NullGrab, focus, keybd, count)) return; } /* just deliver it to the focus window */ FixUpEventFromWindow(xE, focus, None, FALSE); if (xE->u.u.type & EXTENSION_EVENT_BASE) mskidx = keybd->id; (void)DeliverEventsToWindow(focus, xE, count, filters[xE->u.u.type], NullGrab, mskidx);}voidDeliverGrabbedEvent(xE, thisDev, deactivateGrab, count) register xEvent *xE; register DeviceIntPtr thisDev; Bool deactivateGrab; int count;{ register GrabPtr grab = thisDev->grab; int deliveries = 0; register DeviceIntPtr dev; register xEvent *dxE; if (grab->ownerEvents) { WindowPtr focus; if (thisDev->focus) { focus = thisDev->focus->win; if (focus == FollowKeyboardWin) focus = inputInfo.keyboard->focus->win; } else focus = PointerRootWin; if (focus == PointerRootWin) deliveries = DeliverDeviceEvents(sprite.win, xE, grab, NullWindow, thisDev, count); else if (focus && (focus == sprite.win || IsParent(focus, sprite.win))) deliveries = DeliverDeviceEvents(sprite.win, xE, grab, focus, thisDev, count); else if (focus) deliveries = DeliverDeviceEvents(focus, xE, grab, focus, thisDev, count); } if (!deliveries) { FixUpEventFromWindow(xE, grab->window, None, TRUE); deliveries = TryClientEvents(rClient(grab), xE, count, (Mask)grab->eventMask, filters[xE->u.u.type], grab); if (deliveries && (xE->u.u.type == MotionNotify#ifdef XINPUT || xE->u.u.type == DeviceMotionNotify#endif )) thisDev->valuator->motionHintWindow = grab->window; } if (deliveries && !deactivateGrab && (xE->u.u.type != MotionNotify#ifdef XINPUT && xE->u.u.type != DeviceMotionNotify#endif )) switch (thisDev->sync.state) { case FREEZE_BOTH_NEXT_EVENT: for (dev = inputInfo.devices; dev; dev = dev->next) { if (dev == thisDev) continue; FreezeThaw(dev, TRUE); if ((dev->sync.state == FREEZE_BOTH_NEXT_EVENT) && (CLIENT_BITS(dev->grab->resource) == CLIENT_BITS(thisDev->grab->resource))) dev->sync.state = FROZEN_NO_EVENT; else dev->sync.other = thisDev->grab; } /* fall through */ case FREEZE_NEXT_EVENT: thisDev->sync.state = FROZEN_WITH_EVENT; FreezeThaw(thisDev, TRUE); if (thisDev->sync.evcount < count)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -