📄 window.c
字号:
case Below: if (pSib) if (pSib->nextSib != pWin) return(pSib->nextSib); else return(pWin->nextSib); else return NullWindow; case TopIf: if ((!pWin->mapped || (pSib && !pSib->mapped)) && !permitOldBugs) return(pWin->nextSib); else if (pSib) { if ((IsSiblingAboveMe(pWin, pSib) == Above) && (RECT_IN_REGION(pScreen, &pSib->borderSize, &box) != rgnOUT)) return(pFirst); else return(pWin->nextSib); } else if (AnyWindowOverlapsMe(pWin, pHead, &box)) return(pFirst); else return(pWin->nextSib); case BottomIf: if ((!pWin->mapped || (pSib && !pSib->mapped)) && !permitOldBugs) return(pWin->nextSib); else if (pSib) { if ((IsSiblingAboveMe(pWin, pSib) == Below) && (RECT_IN_REGION(pScreen, &pSib->borderSize, &box) != rgnOUT)) return NullWindow; else return(pWin->nextSib); } else if (IOverlapAnyWindow(pWin, &box)) return NullWindow; else return(pWin->nextSib); case Opposite: if ((!pWin->mapped || (pSib && !pSib->mapped)) && !permitOldBugs) return(pWin->nextSib); else if (pSib) { if (RECT_IN_REGION(pScreen, &pSib->borderSize, &box) != rgnOUT) { if (IsSiblingAboveMe(pWin, pSib) == Above) return(pFirst); else return NullWindow; } else return(pWin->nextSib); } else if (AnyWindowOverlapsMe(pWin, pHead, &box)) { /* If I'm occluded, I can't possibly be the first child * if (pWin == pWin->parent->firstChild) * return pWin->nextSib; */ return(pFirst); } else if (IOverlapAnyWindow(pWin, &box)) return NullWindow; else return pWin->nextSib; default: { ErrorF("Internal error in ConfigureWindow, smode == %d\n",smode ); return pWin->nextSib; } }}static void#if NeedFunctionPrototypesReflectStackChange( register WindowPtr pWin, register WindowPtr pSib, VTKind kind)#elseReflectStackChange(pWin, pSib, kind) register WindowPtr pWin, pSib; VTKind kind;#endif{/* Note that pSib might be NULL */ Bool WasViewable = (Bool)pWin->viewable; WindowPtr pParent; Bool anyMarked; WindowPtr pFirstChange;#ifdef DO_SAVE_UNDERS Bool dosave = FALSE;#endif WindowPtr pLayerWin; ScreenPtr pScreen = pWin->drawable.pScreen; /* if this is a root window, can't be restacked */ if (!(pParent = pWin->parent)) return ; pFirstChange = MoveWindowInStack(pWin, pSib); if (WasViewable) { anyMarked = (*pScreen->MarkOverlappedWindows)(pWin, pFirstChange, &pLayerWin); if (pLayerWin != pWin) pFirstChange = pLayerWin;#ifdef DO_SAVE_UNDERS if (DO_SAVE_UNDERS(pWin)) { dosave = (*pScreen->ChangeSaveUnder)(pLayerWin, pFirstChange); }#endif /* DO_SAVE_UNDERS */ if (anyMarked) { (*pScreen->ValidateTree)(pLayerWin->parent, pFirstChange, kind); (*pScreen->HandleExposures)(pLayerWin->parent); }#ifdef DO_SAVE_UNDERS if (dosave) (*pScreen->PostChangeSaveUnder)(pLayerWin, pFirstChange);#endif /* DO_SAVE_UNDERS */ if (anyMarked && pWin->drawable.pScreen->PostValidateTree) (*pScreen->PostValidateTree)(pLayerWin->parent, pFirstChange, kind); } if (pWin->realized) WindowsRestructured ();}/***** * ConfigureWindow *****/intConfigureWindow(pWin, mask, vlist, client) register WindowPtr pWin; register Mask mask; XID *vlist; ClientPtr client;{#define RESTACK_WIN 0#define MOVE_WIN 1#define RESIZE_WIN 2#define REBORDER_WIN 3 register WindowPtr pSib = NullWindow; register WindowPtr pParent = pWin->parent; Window sibwid; Mask index2, tmask; register XID *pVlist; short x, y, beforeX, beforeY; unsigned short w = pWin->drawable.width, h = pWin->drawable.height, bw = pWin->borderWidth; int action, smode = Above;#ifdef XAPPGROUP ClientPtr win_owner; ClientPtr ag_leader = NULL;#endif xEvent event; if ((pWin->drawable.class == InputOnly) && (mask & IllegalInputOnlyConfigureMask)) return(BadMatch); if ((mask & CWSibling) && !(mask & CWStackMode)) return(BadMatch); pVlist = vlist; if (pParent) { x = pWin->drawable.x - pParent->drawable.x - (int)bw; y = pWin->drawable.y - pParent->drawable.y - (int)bw; } else { x = pWin->drawable.x; y = pWin->drawable.y; } beforeX = x; beforeY = y; action = RESTACK_WIN; if ((mask & (CWX | CWY)) && (!(mask & (CWHeight | CWWidth)))) { GET_INT16(CWX, x); GET_INT16(CWY, y); action = MOVE_WIN; } /* or should be resized */ else if (mask & (CWX | CWY | CWWidth | CWHeight)) { GET_INT16(CWX, x); GET_INT16(CWY, y); GET_CARD16(CWWidth, w); GET_CARD16 (CWHeight, h); if (!w || !h) { client->errorValue = 0; return BadValue; } action = RESIZE_WIN; } tmask = mask & ~ChangeMask; while (tmask) { index2 = (Mask)lowbit (tmask); tmask &= ~index2; switch (index2) { case CWBorderWidth: GET_CARD16(CWBorderWidth, bw); break; case CWSibling: sibwid = (Window ) *pVlist; pVlist++; pSib = (WindowPtr )SecurityLookupIDByType(client, sibwid, RT_WINDOW, SecurityReadAccess); if (!pSib) { client->errorValue = sibwid; return(BadWindow); } if (pSib->parent != pParent) return(BadMatch); if (pSib == pWin) return(BadMatch); break; case CWStackMode: GET_CARD8(CWStackMode, smode); if ((smode != TopIf) && (smode != BottomIf) && (smode != Opposite) && (smode != Above) && (smode != Below)) { client->errorValue = smode; return(BadValue); } break; default: client->errorValue = mask; return(BadValue); } } /* root really can't be reconfigured, so just return */ if (!pParent) return Success; /* Figure out if the window should be moved. Doesnt make the changes to the window if event sent */ if (mask & CWStackMode) pSib = WhereDoIGoInTheStack(pWin, pSib, pParent->drawable.x + x, pParent->drawable.y + y, w + (bw << 1), h + (bw << 1), smode); else pSib = pWin->nextSib;#ifdef XAPPGROUP win_owner = clients[CLIENT_ID(pWin->drawable.id)]; ag_leader = XagLeader (win_owner);#endif if ((!pWin->overrideRedirect) && (RedirectSend(pParent)#ifdef XAPPGROUP || (win_owner->appgroup && ag_leader && XagIsControlledRoot (client, pParent))#endif )) { event.u.u.type = ConfigureRequest; event.u.configureRequest.window = pWin->drawable.id; if (mask & CWSibling) event.u.configureRequest.sibling = sibwid; else event.u.configureRequest.sibling = None; if (mask & CWStackMode) event.u.u.detail = smode; else event.u.u.detail = Above; event.u.configureRequest.x = x; event.u.configureRequest.y = y; event.u.configureRequest.width = w; event.u.configureRequest.height = h; event.u.configureRequest.borderWidth = bw; event.u.configureRequest.valueMask = mask;#ifdef XAPPGROUP /* make sure if the ag_leader maps the window it goes to the wm */ if (ag_leader && ag_leader != client && XagIsControlledRoot (client, pParent)) { event.u.configureRequest.parent = XagId (win_owner); (void) TryClientEvents (ag_leader, &event, 1, NoEventMask, NoEventMask, NullGrab); return Success; }#endif event.u.configureRequest.parent = pParent->drawable.id; if (MaybeDeliverEventsToClient(pParent, &event, 1, SubstructureRedirectMask, client) == 1) return(Success); } if (action == RESIZE_WIN) { Bool size_change = (w != pWin->drawable.width) || (h != pWin->drawable.height); if (size_change && ((pWin->eventMask|wOtherEventMasks(pWin)) & ResizeRedirectMask)) { xEvent eventT; eventT.u.u.type = ResizeRequest; eventT.u.resizeRequest.window = pWin->drawable.id; eventT.u.resizeRequest.width = w; eventT.u.resizeRequest.height = h; if (MaybeDeliverEventsToClient(pWin, &eventT, 1, ResizeRedirectMask, client) == 1) { /* if event is delivered, leave the actual size alone. */ w = pWin->drawable.width; h = pWin->drawable.height; size_change = FALSE; } } if (!size_change) { if (mask & (CWX | CWY)) action = MOVE_WIN; else if (mask & (CWStackMode | CWBorderWidth)) action = RESTACK_WIN; else /* really nothing to do */ return(Success) ; } } if (action == RESIZE_WIN) /* we've already checked whether there's really a size change */ goto ActuallyDoSomething; if ((mask & CWX) && (x != beforeX)) goto ActuallyDoSomething; if ((mask & CWY) && (y != beforeY)) goto ActuallyDoSomething; if ((mask & CWBorderWidth) && (bw != wBorderWidth (pWin))) goto ActuallyDoSomething; if (mask & CWStackMode) { if (pWin->nextSib != pSib) goto ActuallyDoSomething; } return(Success);ActuallyDoSomething: if (SubStrSend(pWin, pParent)) { event.u.u.type = ConfigureNotify; event.u.configureNotify.window = pWin->drawable.id; if (pSib) event.u.configureNotify.aboveSibling = pSib->drawable.id; else event.u.configureNotify.aboveSibling = None; event.u.configureNotify.x = x; event.u.configureNotify.y = y; event.u.configureNotify.width = w; event.u.configureNotify.height = h; event.u.configureNotify.borderWidth = bw; event.u.configureNotify.override = pWin->overrideRedirect; DeliverEvents(pWin, &event, 1, NullWindow); } if (mask & CWBorderWidth) { if (action == RESTACK_WIN) { action = MOVE_WIN; pWin->borderWidth = bw; } else if ((action == MOVE_WIN) && (beforeX + wBorderWidth (pWin) == x + (int)bw) && (beforeY + wBorderWidth (pWin) == y + (int)bw)) { action = REBORDER_WIN; (*pWin->drawable.pScreen->ChangeBorderWidth)(pWin, bw); } else pWin->borderWidth = bw; } if (action == MOVE_WIN) (*pWin->drawable.pScreen->MoveWindow)(pWin, x, y, pSib, (mask & CWBorderWidth) ? VTOther : VTMove); else if (action == RESIZE_WIN) (*pWin->drawable.pScreen->ResizeWindow)(pWin, x, y, w, h, pSib); else if (mask & CWStackMode) ReflectStackChange(pWin, pSib, VTOther); if (action != RESTACK_WIN) CheckCursorConfinement(pWin); return(Success);#undef RESTACK_WIN#undef MOVE_WIN#undef RESIZE_WIN#undef REBORDER_WIN}/****** * * CirculateWindow * For RaiseLowest, raises the lowest mapped child (if any) that is * obscured by another child to the top of the stack. For LowerHighest, * lowers the highest mapped child (if any) that is obscuring another * child to the bottom of the stack. Exposure processing is performed * ******/intCirculateWindow(pParent, direction, client) WindowPtr pParent; int direction; ClientPtr client;{ register WindowPtr pWin, pHead, pFirst; xEvent event; BoxRec box; pHead = RealChildHead(pParent); pFirst = pHead ? pHead->nextSib : pParent->firstChild; if (direction == RaiseLowest) { for (pWin = pParent->lastChild; (pWin != pHead) && !(pWin->mapped && AnyWindowOverlapsMe(pWin, pHead, WindowExtents(pWin, &box))); pWin = pWin->prevSib) ; if (pWin == pHead) return Success; } else { for (pWin = pFirst; pWin && !(pWin->mapped && IOverlapAnyWindow(pWin, WindowExtents(pWin, &box))); pWin = pWin->nextSib) ; if (!pWin) return Success; } event.u.circulate.window = pWin->drawable.id; event.u.circulate.parent = pParent->drawable.id; event.u.circulate.event = pParent->drawable.id; if (direction == RaiseLowest) event.u.circulate.place = PlaceOnTop; else event.u.circulate.place = PlaceOnBottom; if (RedirectSend(pParent)) { event.u.u.type = CirculateRequest; if (MaybeDeliverEventsToClient(pParent, &event, 1, SubstructureRedirectMask, client) == 1) return(Success); } event.u.u.type = CirculateNotify; DeliverEvents(pWin, &event, 1, NullWindow); ReflectStackChange(pWin, (direction == RaiseLowest) ? pFirst : NullWindow, VTStack); return(Success);}static int#if NeedFunctionPrototypesCompareWIDs( WindowPtr pWin, pointer value) /* must conform to VisitWindowProcPtr */#elseCompareWIDs(pWin, value) WindowPtr pWin; pointer value; /* must conform to VisitWindowProcPtr */#endif{ Window *wid = (Window *)value; if (pWin->drawable.id == *wid) return(WT_STOPWALKING); else return(WT_WALKCHILDREN);}/***** * ReparentWindow *****/intReparentWindow(pWin, pParent, x, y, client) register WindowPtr pWin, pParent; int x,y; ClientPtr client;{ WindowPtr pPrev, pPriorParent; Bool WasMapped = (Bool)(pWin->mapped); xEvent event; int bw = wBorderWidth (pWin); register ScreenPtr pScreen; pScreen = pWin->drawable.pScreen; if (TraverseTree(pWin, CompareWIDs, (pointer)&pParent->drawable.id) == WT_STOPWALKING) return(BadMatch); if (!MakeWindowOptional(pWin)) return(BadAlloc); if (WasMapped) UnmapWindow(pWin, FALSE); event.u.u.type = ReparentNotify; event.u.reparent.window = pWin->drawable.id; event.u.reparent.parent = pParent->drawable.id;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -