⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mbufpx.c

📁 远程桌面连接工具
💻 C
📖 第 1 页 / 共 2 页
字号:
/************************************************************Copyright (c) 1989  X ConsortiumPermission is hereby granted, free of charge, to any person obtaining a copyof this software and associated documentation files (the "Software"), to dealin the Software without restriction, including without limitation the rightsto use, copy, modify, merge, publish, distribute, sublicense, and/or sellcopies of the Software, and to permit persons to whom the Software isfurnished to do so, subject to the following conditions:The above copyright notice and this permission notice shall be included inall copies or substantial portions of the Software.THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS ORIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THEX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER INAN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR INCONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.Except as contained in this notice, the name of the X Consortium shall not beused in advertising or otherwise to promote the sale, use or other dealingsin this Software without prior written authorization from the X Consortium.********************************************************//* $XConsortium: mbufpx.c,v 1.5 94/04/17 20:32:54 dpw Exp $ *//* $XFree86: xc/programs/Xserver/Xext/mbufpx.c,v 3.0 1994/05/08 05:17:32 dawes Exp $ */#define NEED_REPLIES#define NEED_EVENTS#include <stdio.h>#include "X.h"#include "Xproto.h"#include "misc.h"#include "os.h"#include "windowstr.h"#include "scrnintstr.h"#include "pixmapstr.h"#include "extnsionst.h"#include "dixstruct.h"#include "resource.h"#include "opaque.h"#include "regionstr.h"#include "gcstruct.h"#include "inputstr.h"#ifndef MINIX#include <sys/time.h>#endif#define _MULTIBUF_SERVER_	/* don't want Xlib structures */#define _MULTIBUF_PIXMAP_#include "multibufst.h"static Bool NoopDDA_True() { return TRUE; }static Bool pixPositionWindow();static int  pixCreateImageBuffers();static void pixDisplayImageBuffers();static void pixClearImageBufferArea();static void pixDeleteBufferDrawable();static void pixWrapScreenFuncs();static void pixResetProc();BoolpixMultibufferInit(pScreen, pMBScreen)    ScreenPtr pScreen;    mbufScreenPtr pMBScreen;{    int			i, j, k;    xMbufBufferInfo	*pInfo;    int			nInfo;    DepthPtr		pDepth;    mbufPixmapPrivPtr	pMBPriv;    pMBScreen->CreateImageBuffers = pixCreateImageBuffers;    pMBScreen->DestroyImageBuffers = (void (*)())NoopDDA;    pMBScreen->DisplayImageBuffers = pixDisplayImageBuffers;    pMBScreen->ClearImageBufferArea = pixClearImageBufferArea;    pMBScreen->ChangeMBufferAttributes = NoopDDA_True;    pMBScreen->ChangeBufferAttributes = NoopDDA_True;    pMBScreen->DeleteBufferDrawable = pixDeleteBufferDrawable;    pMBScreen->WrapScreenFuncs = pixWrapScreenFuncs;    pMBScreen->ResetProc = pixResetProc;    /* Support every depth and visual combination that the screen does */    nInfo = 0;    for (i = 0; i < pScreen->numDepths; i++)    {	pDepth = &pScreen->allowedDepths[i];	nInfo += pDepth->numVids;    }    pInfo = (xMbufBufferInfo *) xalloc (nInfo * sizeof (xMbufBufferInfo));    if (!pInfo)	return FALSE;    k = 0;    for (i = 0; i < pScreen->numDepths; i++)    {	pDepth = &pScreen->allowedDepths[i];	for (j = 0; j < pDepth->numVids; j++)	{	    pInfo[k].visualID = pDepth->vids[j];	    pInfo[k].maxBuffers = 0;	    pInfo[k].depth = pDepth->depth;	    k++;	}    }    pMBScreen->nInfo = nInfo;    pMBScreen->pInfo = pInfo;    /*     * Setup the devPrivate to mbufScreenRec     */    pMBPriv = (mbufPixmapPrivPtr) xalloc(sizeof(* pMBPriv));    if (!pMBPriv)    {	xfree(pInfo);	return (FALSE);    }    pMBScreen->devPrivate.ptr = (pointer) pMBPriv;    pMBPriv->PositionWindow = NULL;    pMBPriv->funcsWrapped = 0;    return TRUE;}/*ARGSUSED*/static intpixCreateImageBuffers (pWin, nbuf, ids, action, hint)    WindowPtr	pWin;    int		nbuf;    XID		*ids;    int		action;    int		hint;{    mbufWindowPtr	pMBWindow;    mbufBufferPtr	pMBBuffer;    ScreenPtr		pScreen;    int			width, height, depth;    int			i;    pMBWindow = MB_WINDOW_PRIV(pWin);    width = pWin->drawable.width;    height = pWin->drawable.height;    depth = pWin->drawable.depth;    pScreen = pWin->drawable.pScreen;    for (i = 0; i < nbuf; i++)    {	pMBBuffer = &pMBWindow->buffers[i];	pMBBuffer->pDrawable = (DrawablePtr)	    (*pScreen->CreatePixmap) (pScreen, width, height, depth);	if (!pMBBuffer->pDrawable)	    break;	if (!AddResource (ids[i], MultibufferDrawableResType,			  (pointer) pMBBuffer->pDrawable))	{	    (*pScreen->DestroyPixmap) ((PixmapPtr) pMBBuffer->pDrawable);	    break;	}	pMBBuffer->pDrawable->id = ids[i];	/*	 * In the description of the CreateImageBuffers request:         * "If the window is mapped, or if these image buffers have         *  backing store, their contents will be tiled with the window         *  background, and zero or more expose events will be generated         *  for each of these buffers."	 */	(* MB_SCREEN_PRIV(pScreen)->ClearImageBufferArea)	    (pMBBuffer, 0,0, 0,0, TRUE);    }    return i;}/* * set up the gc to clear the pixmaps; */static BoolSetupBackgroundPainter (pWin, pGC)    WindowPtr	pWin;    GCPtr	pGC;{    XID		    gcvalues[4];    int		    ts_x_origin, ts_y_origin;    PixUnion	    background;    int		    backgroundState;    Mask	    gcmask;    /*     * First take care of any ParentRelative stuff by altering the     * tile/stipple origin to match the coordinates of the upper-left     * corner of the first ancestor without a ParentRelative background.     * This coordinate is, of course, negative.     */    ts_x_origin = ts_y_origin = 0;    while (pWin->backgroundState == ParentRelative) {	ts_x_origin -= pWin->origin.x;	ts_y_origin -= pWin->origin.y;	pWin = pWin->parent;    }    backgroundState = pWin->backgroundState;    background = pWin->background;    switch (backgroundState)    {    case BackgroundPixel:	gcvalues[0] = (XID) background.pixel;	gcvalues[1] = FillSolid;	gcmask = GCForeground|GCFillStyle;	break;    case BackgroundPixmap:	gcvalues[0] = FillTiled;	gcvalues[1] = (XID) background.pixmap;	gcvalues[2] = ts_x_origin;	gcvalues[3] = ts_y_origin;	gcmask = GCFillStyle|GCTile|GCTileStipXOrigin|GCTileStipYOrigin;	break;    default:	return FALSE;    }    DoChangeGC(pGC, gcmask, gcvalues, TRUE);    return TRUE;}static voidMultibufferPaintBackgroundRectangles(pWin, pDrawable, nrects, pRects)    WindowPtr pWin;    DrawablePtr pDrawable;    int nrects;    xRectangle *pRects;{    GCPtr      pGC;    pGC = GetScratchGC (pWin->drawable.depth, pWin->drawable.pScreen);    if (SetupBackgroundPainter(pWin, pGC))    {	ValidateGC(pDrawable, pGC);	(*pGC->ops->PolyFillRect) (pDrawable, pGC, nrects, pRects);    }    FreeScratchGC(pGC);}static voidMultibufferPaintBackgroundRegion(pWin, pDrawable, pRegion)    WindowPtr pWin;    DrawablePtr pDrawable;    RegionPtr pRegion;{    xRectangle *pRects;    int nrects  = REGION_NUM_RECTS(pRegion);    BoxPtr pbox = REGION_RECTS(pRegion);    pRects = (xRectangle *)ALLOCATE_LOCAL(nrects * sizeof(xRectangle));    if (pRects)    {	int i;	for (i = 0; i < nrects; i++)	{	    pRects[i].x = pbox->x1;	    pRects[i].y = pbox->y1;	    pRects[i].width  = pbox->x2 - pbox->x1;	    pRects[i].height = pbox->y2 - pbox->y1;	}	MultibufferPaintBackgroundRectangles(pWin, pDrawable, nrects, pRects);	DEALLOCATE_LOCAL(pRects);    }}static voidpixDisplayImageBuffers(pScreen, ppMBWindow, ppMBBuffer, nbuf)    mbufBufferPtr	    *ppMBBuffer;    mbufWindowPtr	    *ppMBWindow;    int		    nbuf;{    GCPtr	    pGC = NULL;    PixmapPtr	    pPrevPixmap, pNewPixmap;    WindowPtr	    pWin;    RegionPtr	    pExposed;    int		    i;    mbufBufferPtr  pPrevMBBuffer;    XID		    bool;    xRectangle      r;    UpdateCurrentTime ();    for (i = 0; i < nbuf; i++)    {	pWin = ppMBWindow[i]->pWindow;	/* Time to get a different scratch GC? */	if (!pGC	    || pGC->depth   != pWin->drawable.depth	    || pGC->pScreen != pWin->drawable.pScreen)	{	    if (pGC) FreeScratchGC(pGC);	    pGC = GetScratchGC (pWin->drawable.depth, pWin->drawable.pScreen);	}	pPrevMBBuffer = MB_DISPLAYED_BUFFER(ppMBWindow[i]);	pPrevPixmap = (PixmapPtr) pPrevMBBuffer->pDrawable;	pNewPixmap = (PixmapPtr) ppMBBuffer[i]->pDrawable;	if (pPrevPixmap == pNewPixmap)	{	  /* "If a specified buffer is already displayed, any delays and	   *  update action will still be performed for that buffer."	   *	   *  We special-case this because applications do occasionally	   *  request a redundant DisplayImageBuffers, and we can save	   *  strokes by recognizing that the only update action that will	   *  change the buffer contents in this case is Background.	   */	    if (ppMBWindow[i]->updateAction == MultibufferUpdateActionBackground)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -