📄 mbufpx.c
字号:
{ r.x = r.y = 0; r.width = pWin->drawable.width; r.height = pWin->drawable.height; MultibufferPaintBackgroundRectangles(pWin, (DrawablePtr)pWin, 1, &r); } } else /* different buffer is being displayed */ { /* perform update action */ switch (ppMBWindow[i]->updateAction) { case MultibufferUpdateActionUndefined: break; case MultibufferUpdateActionBackground: r.x = r.y = 0; r.width = pPrevPixmap->drawable.width; r.height = pPrevPixmap->drawable.height; MultibufferPaintBackgroundRectangles(pWin, (DrawablePtr)pPrevPixmap, 1, &r); break; case MultibufferUpdateActionUntouched: /* copy the window to the pixmap that represents the * currently displayed buffer */ if (pPrevMBBuffer->eventMask & ExposureMask) { bool = TRUE; DoChangeGC (pGC, GCGraphicsExposures, &bool, FALSE); } ValidateGC ((DrawablePtr)pPrevPixmap, pGC); pExposed = (*pGC->ops->CopyArea)((DrawablePtr) pWin, (DrawablePtr) pPrevPixmap, pGC, 0, 0, pWin->drawable.width, pWin->drawable.height, 0, 0); /* if we couldn't copy the whole window to the buffer, * send expose events (if any client wants them) */ if (pPrevMBBuffer->eventMask & ExposureMask) { /* some client wants expose events */ if (pExposed) { RegionPtr pWinSize; extern RegionPtr CreateUnclippedWinSize(); ScreenPtr pScreen = pWin->drawable.pScreen; pWinSize = CreateUnclippedWinSize (pWin); /* * pExposed is window-relative, but at this point * pWinSize is screen-relative. Make pWinSize be * window-relative so that region ops involving * pExposed and pWinSize behave sensibly. */ REGION_TRANSLATE(pScreen, pWinSize, -pWin->drawable.x, -pWin->drawable.y); REGION_INTERSECT(pScreen, pExposed, pExposed, pWinSize); REGION_DESTROY(pScreen, pWinSize); MultibufferExpose (pPrevMBBuffer, pExposed); REGION_DESTROY(pScreen, pExposed); } bool = FALSE; DoChangeGC (pGC, GCGraphicsExposures, &bool, FALSE); } /* end some client wants expose events */ break; /* end case MultibufferUpdateActionUntouched */ case MultibufferUpdateActionCopied: ValidateGC ((DrawablePtr)pPrevPixmap, pGC); (*pGC->ops->CopyArea) ((DrawablePtr)pNewPixmap, (DrawablePtr)pPrevPixmap, pGC, 0, 0, pWin->drawable.width, pWin->drawable.height, 0, 0); break; } /* end switch on update action */ /* display the new buffer */ ValidateGC ((DrawablePtr)pWin, pGC); (*pGC->ops->CopyArea) ((DrawablePtr)pNewPixmap, (DrawablePtr)pWin, pGC, 0, 0, pWin->drawable.width, pWin->drawable.height, 0, 0); } ppMBWindow[i]->lastUpdate = currentTime; } if (pGC) FreeScratchGC (pGC); return;}/* * resize the buffers when the window is resized */ static BoolpixPositionWindow (pWin, x, y) WindowPtr pWin; int x, y;{ ScreenPtr pScreen; mbufPixmapPrivPtr pMBPriv; mbufWindowPtr pMBWindow; mbufBufferPtr pMBBuffer; int width, height; int i; int dx, dy, dw, dh; int sourcex, sourcey; int destx, desty; PixmapPtr pPixmap; GCPtr pGC; int savewidth, saveheight; Bool clear; RegionRec exposedRegion; Bool ret; pScreen = pWin->drawable.pScreen; pMBPriv = MB_SCREEN_PRIV_PIXMAP(pScreen); UNWRAP_SCREEN_FUNC(pScreen, pMBPriv, Bool, PositionWindow); ret = (* pScreen->PositionWindow) (pWin, x, y); REWRAP_SCREEN_FUNC(pScreen, pMBPriv, Bool, PositionWindow); if (!(pMBWindow = MB_WINDOW_PRIV(pWin))) return ret; /* if new size is same as old, we're done */ if (pMBWindow->width == pWin->drawable.width && pMBWindow->height == pWin->drawable.height) return ret; width = pWin->drawable.width; height = pWin->drawable.height; dx = pWin->drawable.x - pMBWindow->x; dy = pWin->drawable.x - pMBWindow->y; dw = width - pMBWindow->width; dh = height - pMBWindow->height; GravityTranslate (0, 0, -dx, -dy, dw, dh, pWin->bitGravity, &destx, &desty); /* if the window grew, remember to paint the window background, * and maybe send expose events, for the new areas of the buffers */ clear = pMBWindow->width < width || pMBWindow->height < height || pWin->bitGravity == ForgetGravity; sourcex = 0; sourcey = 0; savewidth = pMBWindow->width; saveheight = pMBWindow->height; /* clip rectangle to source and destination */ if (destx < 0) { savewidth += destx; sourcex -= destx; destx = 0; } if (destx + savewidth > width) savewidth = width - destx; if (desty < 0) { saveheight += desty; sourcey -= desty; desty = 0; } if (desty + saveheight > height) saveheight = height - desty; pMBWindow->width = width; pMBWindow->height = height; pMBWindow->x = pWin->drawable.x; pMBWindow->y = pWin->drawable.y; if (clear) { BoxRec box; box.x1 = box.y1 = 0; box.x2 = width; box.y2 = height; REGION_INIT(pScreen, &exposedRegion, &box, 1); if (pWin->bitGravity != ForgetGravity) { RegionRec preservedRegion; box.x1 = destx; box.y1 = desty; box.x2 = destx + savewidth; box.y2 = desty + saveheight; REGION_INIT(pScreen, &preservedRegion, &box, 1); REGION_SUBTRACT(pScreen, &exposedRegion, &exposedRegion, &preservedRegion); REGION_UNINIT(pScreen, &preservedRegion); } } /* end if (clear) */ pGC = GetScratchGC (pWin->drawable.depth, pScreen); /* create buffers with new window size */ for (i = 0; i < pMBWindow->numMultibuffer; i++) { pMBBuffer = &pMBWindow->buffers[i]; pPixmap = (*pScreen->CreatePixmap) (pScreen, width, height, pWin->drawable.depth); if (!pPixmap) { (* MB_SCREEN_PRIV(pScreen)->DestroyImageBuffers)(pWin); break; } if (clear) { MultibufferPaintBackgroundRegion(pWin, (DrawablePtr)pPixmap, &exposedRegion); MultibufferExpose(pMBBuffer, &exposedRegion); } if (pWin->bitGravity != ForgetGravity) { ValidateGC ((DrawablePtr)pPixmap, pGC); (*pGC->ops->CopyArea) (pMBBuffer->pDrawable, (DrawablePtr)pPixmap, pGC, sourcex, sourcey, savewidth, saveheight, destx, desty); } pPixmap->drawable.id = pMBBuffer->pDrawable->id; (*pScreen->DestroyPixmap) ((PixmapPtr) pMBBuffer->pDrawable); pMBBuffer->pDrawable = (DrawablePtr) pPixmap; if (i != pMBWindow->displayedMultibuffer) { ChangeResourceValue (pPixmap->drawable.id, MultibufferDrawableResType, (pointer) pPixmap); } } FreeScratchGC (pGC); if (clear) REGION_UNINIT(pScreen, &exposedRegion); return TRUE;}static voidpixWrapScreenFuncs(pScreen) ScreenPtr pScreen;{ mbufPixmapPrivPtr pMBPriv = MB_SCREEN_PRIV_PIXMAP(pScreen); WRAP_SCREEN_FUNC(pScreen, pMBPriv, PositionWindow, pixPositionWindow);}static voidpixResetProc(pScreen) ScreenPtr pScreen;{ mbufScreenPtr pMBScreen = MB_SCREEN_PRIV(pScreen); mbufPixmapPrivPtr pMBPriv = MB_SCREEN_PRIV_PIXMAP(pScreen); xfree(pMBScreen->pInfo); xfree(pMBPriv);}static voidpixClearImageBufferArea(pMBBuffer, x,y, width,height, exposures) mbufBufferPtr pMBBuffer; short x, y; unsigned short width, height; Bool exposures;{ WindowPtr pWin; ScreenPtr pScreen; BoxRec box; RegionRec region; int w_width, w_height; DrawablePtr pDrawable; pWin = pMBBuffer->pMBWindow->pWindow; pScreen = pWin->drawable.pScreen; w_width = pWin->drawable.width; w_height = pWin->drawable.height; box.x1 = x; box.y1 = y; box.x2 = width ? (box.x1 + width) : w_width; box.y2 = height ? (box.y1 + height) : w_height; if (box.x1 < 0) box.x1 = 0; if (box.y1 < 0) box.y1 = 0; if (box.x2 > w_width) box.x2 = w_width; if (box.y2 > w_height) box.y2 = w_height; REGION_INIT(pScreen, ®ion, &box, 1); if (pMBBuffer->number == pMBBuffer->pMBWindow->displayedMultibuffer) pDrawable = (DrawablePtr) pWin; else pDrawable = pMBBuffer->pDrawable; MultibufferPaintBackgroundRegion(pWin, pDrawable, ®ion); if (exposures) MultibufferExpose(pMBBuffer, ®ion); REGION_UNINIT(pScreen, ®ion);}static voidpixDeleteBufferDrawable(pDrawable) DrawablePtr pDrawable;{ (* pDrawable->pScreen->DestroyPixmap)((PixmapPtr) pDrawable);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -