📄 miexpose.c
字号:
/***********************************************************Copyright (c) 1987 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.Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. All Rights ReservedPermission to use, copy, modify, and distribute this software and its documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies and thatboth that copyright notice and this permission notice appear in supporting documentation, and that the name of Digital not beused in advertising or publicity pertaining to distribution of thesoftware without specific, written prior permission. DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDINGALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALLDIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES ORANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THISSOFTWARE.******************************************************************//* $XConsortium: miexpose.c /main/43 1996/08/01 19:25:26 dpw $ *//* $XFree86: xc/programs/Xserver/mi/miexpose.c,v 3.1 1996/12/23 07:09:44 dawes Exp $ */#include "X.h"#define NEED_EVENTS#include "Xproto.h"#include "Xprotostr.h"#include "misc.h"#include "regionstr.h"#include "scrnintstr.h"#include "gcstruct.h"#include "windowstr.h"#include "pixmap.h"#include "input.h"#include "dixstruct.h"#include "mi.h"#include "Xmd.h"extern WindowPtr *WindowTable;/* machine-independent graphics exposure code. any device that usesthe region package can call this.*/#ifndef RECTLIMIT#define RECTLIMIT 25 /* pick a number, any number > 8 */#endif/* miHandleExposures generate a region for exposures for areas that were copied from obscured ornon-existent areas to non-obscured areas of the destination. Paint thebackground for the region, if the destination is a window.NOTE: this should generally be called, even if graphicsExposures is false,because this is where bits get recovered from backing store.NOTE: added argument 'plane' is used to indicate how exposures from backingstore should be accomplished. If plane is 0 (i.e. no bit plane), CopyAreashould be used, else a CopyPlane of the indicated plane will be used. Theexposing is done by the backing store's GraphicsExpose function, of course.*/RegionPtrmiHandleExposures(pSrcDrawable, pDstDrawable, pGC, srcx, srcy, width, height, dstx, dsty, plane) register DrawablePtr pSrcDrawable; register DrawablePtr pDstDrawable; GCPtr pGC; int srcx, srcy; int width, height; int dstx, dsty; unsigned long plane;{ register ScreenPtr pscr = pGC->pScreen; RegionPtr prgnSrcClip; /* drawable-relative source clip */ RegionRec rgnSrcRec; RegionPtr prgnDstClip; /* drawable-relative dest clip */ RegionRec rgnDstRec; BoxRec srcBox; /* unclipped source */ RegionRec rgnExposed; /* exposed region, calculated source- relative, made dst relative to intersect with visible parts of dest and send events to client, and then screen relative to paint the window background */ WindowPtr pSrcWin; BoxRec expBox; Bool extents; /* avoid work if we can */ if (!pGC->graphicsExposures && (pDstDrawable->type == DRAWABLE_PIXMAP) && ((pSrcDrawable->type == DRAWABLE_PIXMAP) || (((WindowPtr)pSrcDrawable)->backStorage == NULL))) return NULL; srcBox.x1 = srcx; srcBox.y1 = srcy; srcBox.x2 = srcx+width; srcBox.y2 = srcy+height; if (pSrcDrawable->type != DRAWABLE_PIXMAP) { BoxRec TsrcBox; TsrcBox.x1 = srcx + pSrcDrawable->x; TsrcBox.y1 = srcy + pSrcDrawable->y; TsrcBox.x2 = TsrcBox.x1 + width; TsrcBox.y2 = TsrcBox.y1 + height; pSrcWin = (WindowPtr) pSrcDrawable; if (pGC->subWindowMode == IncludeInferiors) { prgnSrcClip = NotClippedByChildren (pSrcWin); if ((RECT_IN_REGION(pscr, prgnSrcClip, &TsrcBox)) == rgnIN) { REGION_DESTROY(pscr, prgnSrcClip); return NULL; } } else { if ((RECT_IN_REGION(pscr, &pSrcWin->clipList, &TsrcBox)) == rgnIN) return NULL; prgnSrcClip = &rgnSrcRec; REGION_INIT(pscr, prgnSrcClip, NullBox, 0); REGION_COPY(pscr, prgnSrcClip, &pSrcWin->clipList); } REGION_TRANSLATE(pscr, prgnSrcClip, -pSrcDrawable->x, -pSrcDrawable->y); } else { BoxRec box; if ((srcBox.x1 >= 0) && (srcBox.y1 >= 0) && (srcBox.x2 <= pSrcDrawable->width) && (srcBox.y2 <= pSrcDrawable->height)) return NULL; box.x1 = 0; box.y1 = 0; box.x2 = pSrcDrawable->width; box.y2 = pSrcDrawable->height; prgnSrcClip = &rgnSrcRec; REGION_INIT(pscr, prgnSrcClip, &box, 1); pSrcWin = (WindowPtr)NULL; } if (pDstDrawable == pSrcDrawable) { prgnDstClip = prgnSrcClip; } else if (pDstDrawable->type != DRAWABLE_PIXMAP) { if (pGC->subWindowMode == IncludeInferiors) { prgnDstClip = NotClippedByChildren((WindowPtr)pDstDrawable); } else { prgnDstClip = &rgnDstRec; REGION_INIT(pscr, prgnDstClip, NullBox, 0); REGION_COPY(pscr, prgnDstClip, &((WindowPtr)pDstDrawable)->clipList); } REGION_TRANSLATE(pscr, prgnDstClip, -pDstDrawable->x, -pDstDrawable->y); } else { BoxRec box; box.x1 = 0; box.y1 = 0; box.x2 = pDstDrawable->width; box.y2 = pDstDrawable->height; prgnDstClip = &rgnDstRec; REGION_INIT(pscr, prgnDstClip, &box, 1); } /* drawable-relative source region */ REGION_INIT(pscr, &rgnExposed, &srcBox, 1); /* now get the hidden parts of the source box*/ REGION_SUBTRACT(pscr, &rgnExposed, &rgnExposed, prgnSrcClip); if (pSrcWin && pSrcWin->backStorage) { /* * Copy any areas from the source backing store. Modifies * rgnExposed. */ (* pSrcWin->drawable.pScreen->ExposeCopy) ((WindowPtr)pSrcDrawable, pDstDrawable, pGC, &rgnExposed, srcx, srcy, dstx, dsty, plane); } /* move them over the destination */ REGION_TRANSLATE(pscr, &rgnExposed, dstx-srcx, dsty-srcy); /* intersect with visible areas of dest */ REGION_INTERSECT(pscr, &rgnExposed, &rgnExposed, prgnDstClip); /* * If we have LOTS of rectangles, we decide to take the extents * and force an exposure on that. This should require much less * work overall, on both client and server. This is cheating, but * isn't prohibited by the protocol ("spontaneous combustion" :-) * for windows. */ extents = pGC->graphicsExposures && (REGION_NUM_RECTS(&rgnExposed) > RECTLIMIT) && (pDstDrawable->type != DRAWABLE_PIXMAP);#ifdef SHAPE if (pSrcWin) { RegionPtr region; if (!(region = wClipShape (pSrcWin))) region = wBoundingShape (pSrcWin); /* * If you try to CopyArea the extents of a shaped window, compacting the * exposed region will undo all our work! */ if (extents && pSrcWin && region && (RECT_IN_REGION(pscr, region, &srcBox) != rgnIN)) extents = FALSE; }#endif if (extents) { WindowPtr pWin = (WindowPtr)pDstDrawable; expBox = *REGION_EXTENTS(pscr, &rgnExposed); REGION_RESET(pscr, &rgnExposed, &expBox); /* need to clear out new areas of backing store */ if (pWin->backStorage) (void) (* pWin->drawable.pScreen->ClearBackingStore)( pWin, expBox.x1, expBox.y1, expBox.x2 - expBox.x1, expBox.y2 - expBox.y1, FALSE); } if ((pDstDrawable->type != DRAWABLE_PIXMAP) && (((WindowPtr)pDstDrawable)->backgroundState != None)) { WindowPtr pWin = (WindowPtr)pDstDrawable; /* make the exposed area screen-relative */ REGION_TRANSLATE(pscr, &rgnExposed, pDstDrawable->x, pDstDrawable->y); if (extents) { /* PaintWindowBackground doesn't clip, so we have to */ REGION_INTERSECT(pscr, &rgnExposed, &rgnExposed, &pWin->clipList); } (*pWin->drawable.pScreen->PaintWindowBackground)( (WindowPtr)pDstDrawable, &rgnExposed, PW_BACKGROUND); if (extents) { REGION_RESET(pscr, &rgnExposed, &expBox); } else REGION_TRANSLATE(pscr, &rgnExposed, -pDstDrawable->x, -pDstDrawable->y); } if (prgnDstClip == &rgnDstRec) { REGION_UNINIT(pscr, prgnDstClip); } else if (prgnDstClip != prgnSrcClip) { REGION_DESTROY(pscr, prgnDstClip); } if (prgnSrcClip == &rgnSrcRec) { REGION_UNINIT(pscr, prgnSrcClip); } else { REGION_DESTROY(pscr, prgnSrcClip); } if (pGC->graphicsExposures) { /* don't look */ RegionPtr exposed = REGION_CREATE(pscr, NullBox, 0); *exposed = rgnExposed; return exposed; } else { REGION_UNINIT(pscr, &rgnExposed); return NULL; }}/* send GraphicsExpose events, or a NoExpose event, based on the region */voidmiSendGraphicsExpose (client, pRgn, drawable, major, minor) ClientPtr client; RegionPtr pRgn; XID drawable; int major; int minor;{ if (pRgn && !REGION_NIL(pRgn)) { xEvent *pEvent; register xEvent *pe; register BoxPtr pBox; register int i; int numRects; numRects = REGION_NUM_RECTS(pRgn); pBox = REGION_RECTS(pRgn); if(!(pEvent = (xEvent *)ALLOCATE_LOCAL(numRects * sizeof(xEvent)))) return; pe = pEvent; for (i=1; i<=numRects; i++, pe++, pBox++) { pe->u.u.type = GraphicsExpose; pe->u.graphicsExposure.drawable = drawable; pe->u.graphicsExposure.x = pBox->x1; pe->u.graphicsExposure.y = pBox->y1; pe->u.graphicsExposure.width = pBox->x2 - pBox->x1; pe->u.graphicsExposure.height = pBox->y2 - pBox->y1; pe->u.graphicsExposure.count = numRects - i; pe->u.graphicsExposure.majorEvent = major; pe->u.graphicsExposure.minorEvent = minor; } TryClientEvents(client, pEvent, numRects, (Mask)0, NoEventMask, NullGrab); DEALLOCATE_LOCAL(pEvent); } else { xEvent event; event.u.u.type = NoExpose; event.u.noExposure.drawable = drawable; event.u.noExposure.majorEvent = major; event.u.noExposure.minorEvent = minor; TryClientEvents(client, &event, 1, (Mask)0, NoEventMask, NullGrab); }}voidmiSendExposures(pWin, pRgn, dx, dy) WindowPtr pWin; RegionPtr pRgn; register int dx, dy;{ register BoxPtr pBox; int numRects; register xEvent *pEvent, *pe; register int i; pBox = REGION_RECTS(pRgn); numRects = REGION_NUM_RECTS(pRgn); if(!(pEvent = (xEvent *) ALLOCATE_LOCAL(numRects * sizeof(xEvent)))) return; for (i=numRects, pe = pEvent; --i >= 0; pe++, pBox++) { pe->u.u.type = Expose; pe->u.expose.window = pWin->drawable.id; pe->u.expose.x = pBox->x1 - dx; pe->u.expose.y = pBox->y1 - dy; pe->u.expose.width = pBox->x2 - pBox->x1; pe->u.expose.height = pBox->y2 - pBox->y1;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -