📄 window.c
字号:
pParent->lastChild->nextSib = pWin; pWin->prevSib = pParent->lastChild; pWin->nextSib = NullWindow; pParent->lastChild = pWin; } else if (pParent->firstChild == pNextSib) /* move to top */ { pFirstChange = pWin; if (pParent->lastChild == pWin) pParent->lastChild = pWin->prevSib; if (pWin->nextSib) pWin->nextSib->prevSib = pWin->prevSib; if (pWin->prevSib) pWin->prevSib->nextSib = pWin->nextSib; pWin->nextSib = pParent->firstChild; pWin->prevSib = (WindowPtr ) NULL; pNextSib->prevSib = pWin; pParent->firstChild = pWin; } else /* move in middle of list */ { WindowPtr pOldNext = pWin->nextSib; pFirstChange = NullWindow; if (pParent->firstChild == pWin) pFirstChange = pParent->firstChild = pWin->nextSib; if (pParent->lastChild == pWin) { pFirstChange = pWin; pParent->lastChild = pWin->prevSib; } if (pWin->nextSib) pWin->nextSib->prevSib = pWin->prevSib; if (pWin->prevSib) pWin->prevSib->nextSib = pWin->nextSib; pWin->nextSib = pNextSib; pWin->prevSib = pNextSib->prevSib; if (pNextSib->prevSib) pNextSib->prevSib->nextSib = pWin; pNextSib->prevSib = pWin; if (!pFirstChange) { /* do we know it yet? */ pFirstChange = pParent->firstChild; /* no, search from top */ while ((pFirstChange != pWin) && (pFirstChange != pOldNext)) pFirstChange = pFirstChange->nextSib; } } } return( pFirstChange );}RegionPtrCreateUnclippedWinSize (pWin) register WindowPtr pWin;{ RegionPtr pRgn; BoxRec box; box.x1 = pWin->drawable.x; box.y1 = pWin->drawable.y; box.x2 = pWin->drawable.x + (int) pWin->drawable.width; box.y2 = pWin->drawable.y + (int) pWin->drawable.height; pRgn = REGION_CREATE(pWin->drawable.pScreen, &box, 1);#ifdef SHAPE if (wBoundingShape (pWin) || wClipShape (pWin)) { REGION_PTR(pScreen, pWin) REGION_TRANSLATE(pScreen, pRgn, - pWin->drawable.x, - pWin->drawable.y); if (wBoundingShape (pWin)) REGION_INTERSECT(pScreen, pRgn, pRgn, wBoundingShape (pWin)); if (wClipShape (pWin)) REGION_INTERSECT(pScreen, pRgn, pRgn, wClipShape (pWin)); REGION_TRANSLATE(pScreen, pRgn, pWin->drawable.x, pWin->drawable.y); }#endif return pRgn;}voidSetWinSize (pWin) register WindowPtr pWin;{ ClippedRegionFromBox(pWin->parent, &pWin->winSize, pWin->drawable.x, pWin->drawable.y, (int)pWin->drawable.width, (int)pWin->drawable.height);#ifdef SHAPE if (wBoundingShape (pWin) || wClipShape (pWin)) { REGION_PTR(pScreen, pWin) REGION_TRANSLATE(pScreen, &pWin->winSize, - pWin->drawable.x, - pWin->drawable.y); if (wBoundingShape (pWin)) REGION_INTERSECT(pScreen, &pWin->winSize, &pWin->winSize, wBoundingShape (pWin)); if (wClipShape (pWin)) REGION_INTERSECT(pScreen, &pWin->winSize, &pWin->winSize, wClipShape (pWin)); REGION_TRANSLATE(pScreen, &pWin->winSize, pWin->drawable.x, pWin->drawable.y); }#endif}voidSetBorderSize (pWin) register WindowPtr pWin;{ int bw; if (HasBorder (pWin)) { bw = wBorderWidth (pWin); ClippedRegionFromBox(pWin->parent, &pWin->borderSize, pWin->drawable.x - bw, pWin->drawable.y - bw, (int)(pWin->drawable.width + (bw<<1)), (int)(pWin->drawable.height + (bw<<1)));#ifdef SHAPE if (wBoundingShape (pWin)) { REGION_PTR(pScreen, pWin) REGION_TRANSLATE(pScreen, &pWin->borderSize, - pWin->drawable.x, - pWin->drawable.y); REGION_INTERSECT(pScreen, &pWin->borderSize, &pWin->borderSize, wBoundingShape (pWin)); REGION_TRANSLATE(pScreen, &pWin->borderSize, pWin->drawable.x, pWin->drawable.y); REGION_UNION(pScreen, &pWin->borderSize, &pWin->borderSize, &pWin->winSize); }#endif } else { REGION_COPY(pWin->drawable.pScreen, &pWin->borderSize, &pWin->winSize); }}voidGravityTranslate (x, y, oldx, oldy, dw, dh, gravity, destx, desty) register int x, y; /* new window position */ int oldx, oldy; /* old window position */ int dw, dh; unsigned gravity; register int *destx, *desty; /* position relative to gravity */{ switch (gravity) { case NorthGravity: *destx = x + dw / 2; *desty = y; break; case NorthEastGravity: *destx = x + dw; *desty = y; break; case WestGravity: *destx = x; *desty = y + dh / 2; break; case CenterGravity: *destx = x + dw / 2; *desty = y + dh / 2; break; case EastGravity: *destx = x + dw; *desty = y + dh / 2; break; case SouthWestGravity: *destx = x; *desty = y + dh; break; case SouthGravity: *destx = x + dw / 2; *desty = y + dh; break; case SouthEastGravity: *destx = x + dw; *desty = y + dh; break; case StaticGravity: *destx = oldx; *desty = oldy; break; default: *destx = x; *desty = y; break; }}/* XXX need to retile border on each window with ParentRelative origin */voidResizeChildrenWinSize(pWin, dx, dy, dw, dh) register WindowPtr pWin; int dx, dy, dw, dh;{ register ScreenPtr pScreen; register WindowPtr pSib, pChild; Bool resized = (dw || dh); pScreen = pWin->drawable.pScreen; for (pSib = pWin->firstChild; pSib; pSib = pSib->nextSib) { if (resized && (pSib->winGravity > NorthWestGravity)) { int cwsx, cwsy; cwsx = pSib->origin.x; cwsy = pSib->origin.y; GravityTranslate (cwsx, cwsy, cwsx - dx, cwsy - dy, dw, dh, pSib->winGravity, &cwsx, &cwsy); if (cwsx != pSib->origin.x || cwsy != pSib->origin.y) { xEvent event; event.u.u.type = GravityNotify; event.u.gravity.window = pSib->drawable.id; event.u.gravity.x = cwsx - wBorderWidth (pSib); event.u.gravity.y = cwsy - wBorderWidth (pSib); DeliverEvents (pSib, &event, 1, NullWindow); pSib->origin.x = cwsx; pSib->origin.y = cwsy; } } pSib->drawable.x = pWin->drawable.x + pSib->origin.x; pSib->drawable.y = pWin->drawable.y + pSib->origin.y; SetWinSize (pSib); SetBorderSize (pSib); (*pScreen->PositionWindow)(pSib, pSib->drawable.x, pSib->drawable.y); if ( (pChild = pSib->firstChild) ) { while (1) { pChild->drawable.x = pChild->parent->drawable.x + pChild->origin.x; pChild->drawable.y = pChild->parent->drawable.y + pChild->origin.y; SetWinSize (pChild); SetBorderSize (pChild); (*pScreen->PositionWindow)(pChild, pChild->drawable.x, pChild->drawable.y); if (pChild->firstChild) { pChild = pChild->firstChild; continue; } while (!pChild->nextSib && (pChild != pSib)) pChild = pChild->parent; if (pChild == pSib) break; pChild = pChild->nextSib; } } }}#define GET_INT16(m, f) \ if (m & mask) \ { \ f = (INT16) *pVlist;\ pVlist++; \ }#define GET_CARD16(m, f) \ if (m & mask) \ { \ f = (CARD16) *pVlist;\ pVlist++;\ }#define GET_CARD8(m, f) \ if (m & mask) \ { \ f = (CARD8) *pVlist;\ pVlist++;\ }#define ChangeMask ((Mask)(CWX | CWY | CWWidth | CWHeight))#define IllegalInputOnlyConfigureMask (CWBorderWidth)/* * IsSiblingAboveMe * returns Above if pSib above pMe in stack or Below otherwise */static int#if NeedFunctionPrototypesIsSiblingAboveMe( register WindowPtr pMe, register WindowPtr pSib)#elseIsSiblingAboveMe(pMe, pSib) register WindowPtr pMe, pSib;#endif{ register WindowPtr pWin; pWin = pMe->parent->firstChild; while (pWin) { if (pWin == pSib) return(Above); else if (pWin == pMe) return(Below); pWin = pWin->nextSib; } return(Below);}static BoxPtr#if NeedFunctionPrototypesWindowExtents( register WindowPtr pWin, register BoxPtr pBox)#elseWindowExtents(pWin, pBox) register WindowPtr pWin; register BoxPtr pBox;#endif{ pBox->x1 = pWin->drawable.x - wBorderWidth (pWin); pBox->y1 = pWin->drawable.y - wBorderWidth (pWin); pBox->x2 = pWin->drawable.x + (int)pWin->drawable.width + wBorderWidth (pWin); pBox->y2 = pWin->drawable.y + (int)pWin->drawable.height + wBorderWidth (pWin); return(pBox);}#ifdef SHAPE#define IS_SHAPED(pWin) (wBoundingShape (pWin) != (RegionPtr) NULL)static RegionPtr#if NeedFunctionPrototypesMakeBoundingRegion ( register WindowPtr pWin, BoxPtr pBox)#elseMakeBoundingRegion (pWin, pBox) register WindowPtr pWin; BoxPtr pBox;#endif{ RegionPtr pRgn; REGION_PTR(pScreen, pWin) pRgn = REGION_CREATE(pScreen, pBox, 1); if (wBoundingShape (pWin)) { REGION_TRANSLATE(pScreen, pRgn, -pWin->origin.x, -pWin->origin.y); REGION_INTERSECT(pScreen, pRgn, pRgn, wBoundingShape (pWin)); REGION_TRANSLATE(pScreen, pRgn, pWin->origin.x, pWin->origin.y); } return pRgn;}static Bool#if NeedFunctionPrototypesShapeOverlap ( WindowPtr pWin, BoxPtr pWinBox, WindowPtr pSib, BoxPtr pSibBox)#elseShapeOverlap (pWin, pWinBox, pSib, pSibBox) WindowPtr pWin, pSib; BoxPtr pWinBox, pSibBox;#endif{ RegionPtr pWinRgn, pSibRgn; register ScreenPtr pScreen; Bool ret; if (!IS_SHAPED(pWin) && !IS_SHAPED(pSib)) return TRUE; pScreen = pWin->drawable.pScreen; pWinRgn = MakeBoundingRegion (pWin, pWinBox); pSibRgn = MakeBoundingRegion (pSib, pSibBox); REGION_INTERSECT(pScreen, pWinRgn, pWinRgn, pSibRgn); ret = REGION_NOTEMPTY(pScreen, pWinRgn); REGION_DESTROY(pScreen, pWinRgn); REGION_DESTROY(pScreen, pSibRgn); return ret;}#endifstatic Bool#if NeedFunctionPrototypesAnyWindowOverlapsMe( WindowPtr pWin, WindowPtr pHead, register BoxPtr box)#elseAnyWindowOverlapsMe(pWin, pHead, box) WindowPtr pWin, pHead; register BoxPtr box;#endif{ register WindowPtr pSib; BoxRec sboxrec; register BoxPtr sbox; for (pSib = pWin->prevSib; pSib != pHead; pSib = pSib->prevSib) { if (pSib->mapped) { sbox = WindowExtents(pSib, &sboxrec); if (BOXES_OVERLAP(sbox, box)#ifdef SHAPE && ShapeOverlap (pWin, box, pSib, sbox)#endif ) return(TRUE); } } return(FALSE);}static Bool#if NeedFunctionPrototypesIOverlapAnyWindow( WindowPtr pWin, register BoxPtr box)#elseIOverlapAnyWindow(pWin, box) WindowPtr pWin; register BoxPtr box;#endif{ register WindowPtr pSib; BoxRec sboxrec; register BoxPtr sbox; for (pSib = pWin->nextSib; pSib; pSib = pSib->nextSib) { if (pSib->mapped) { sbox = WindowExtents(pSib, &sboxrec); if (BOXES_OVERLAP(sbox, box)#ifdef SHAPE && ShapeOverlap (pWin, box, pSib, sbox)#endif ) return(TRUE); } } return(FALSE);}/* * WhereDoIGoInTheStack() * Given pWin and pSib and the relationshipe smode, return * the window that pWin should go ABOVE. * If a pSib is specified: * Above: pWin is placed just above pSib * Below: pWin is placed just below pSib * TopIf: if pSib occludes pWin, then pWin is placed * at the top of the stack * BottomIf: if pWin occludes pSib, then pWin is * placed at the bottom of the stack * Opposite: if pSib occludes pWin, then pWin is placed at the * top of the stack, else if pWin occludes pSib, then * pWin is placed at the bottom of the stack * * If pSib is NULL: * Above: pWin is placed at the top of the stack * Below: pWin is placed at the bottom of the stack * TopIf: if any sibling occludes pWin, then pWin is placed at * the top of the stack * BottomIf: if pWin occludes any sibline, then pWin is placed at * the bottom of the stack * Opposite: if any sibling occludes pWin, then pWin is placed at * the top of the stack, else if pWin occludes any * sibling, then pWin is placed at the bottom of the stack * */static WindowPtr#if NeedFunctionPrototypesWhereDoIGoInTheStack( register WindowPtr pWin, register WindowPtr pSib, short x, short y, unsigned short w, unsigned short h, int smode)#elseWhereDoIGoInTheStack(pWin, pSib, x, y, w, h, smode) register WindowPtr pWin, pSib; short x, y; unsigned short w, h; int smode;#endif{ BoxRec box; register ScreenPtr pScreen; WindowPtr pHead, pFirst; if ((pWin == pWin->parent->firstChild) && (pWin == pWin->parent->lastChild)) return((WindowPtr ) NULL); pHead = RealChildHead(pWin->parent); pFirst = pHead ? pHead->nextSib : pWin->parent->firstChild; pScreen = pWin->drawable.pScreen; box.x1 = x; box.y1 = y; box.x2 = x + (int)w; box.y2 = y + (int)h; switch (smode) { case Above: if (pSib) return(pSib); else if (pWin == pFirst) return(pWin->nextSib); else return(pFirst);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -