xfree86: respect EXEEXT in relink target
[xserver/hramrach.git] / mi / miexpose.c
blobdbb29ca4ae60c649d127a7d77aec5748dead003d
1 /***********************************************************
3 Copyright 1987, 1998 The Open Group
5 Permission to use, copy, modify, distribute, and sell this software and its
6 documentation for any purpose is hereby granted without fee, provided that
7 the above copyright notice appear in all copies and that both that
8 copyright notice and this permission notice appear in supporting
9 documentation.
11 The above copyright notice and this permission notice shall be included in
12 all copies or substantial portions of the Software.
14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
18 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 Except as contained in this notice, the name of The Open Group shall not be
22 used in advertising or otherwise to promote the sale, use or other dealings
23 in this Software without prior written authorization from The Open Group.
25 Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
27 All Rights Reserved
29 Permission to use, copy, modify, and distribute this software and its
30 documentation for any purpose and without fee is hereby granted,
31 provided that the above copyright notice appear in all copies and that
32 both that copyright notice and this permission notice appear in
33 supporting documentation, and that the name of Digital not be
34 used in advertising or publicity pertaining to distribution of the
35 software without specific, written prior permission.
37 DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
38 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
39 DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
40 ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
41 WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
42 ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
43 SOFTWARE.
45 ******************************************************************/
46 /*****************************************************************
48 Copyright (c) 1991, 1997 Digital Equipment Corporation, Maynard, Massachusetts.
50 Permission is hereby granted, free of charge, to any person obtaining a copy
51 of this software and associated documentation files (the "Software"), to deal
52 in the Software without restriction, including without limitation the rights
53 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
54 copies of the Software.
56 The above copyright notice and this permission notice shall be included in
57 all copies or substantial portions of the Software.
59 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
60 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
61 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
62 DIGITAL EQUIPMENT CORPORATION BE LIABLE FOR ANY CLAIM, DAMAGES, INCLUDING,
63 BUT NOT LIMITED TO CONSEQUENTIAL OR INCIDENTAL DAMAGES, OR OTHER LIABILITY,
64 WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
65 IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
67 Except as contained in this notice, the name of Digital Equipment Corporation
68 shall not be used in advertising or otherwise to promote the sale, use or other
69 dealings in this Software without prior written authorization from Digital
70 Equipment Corporation.
72 ******************************************************************/
74 #ifdef HAVE_DIX_CONFIG_H
75 #include <dix-config.h>
76 #endif
78 #include <X11/X.h>
79 #include <X11/Xproto.h>
80 #include <X11/Xprotostr.h>
82 #include "misc.h"
83 #include "regionstr.h"
84 #include "scrnintstr.h"
85 #include "gcstruct.h"
86 #include "windowstr.h"
87 #include "pixmap.h"
88 #include "input.h"
90 #include "dixstruct.h"
91 #include "mi.h"
92 #include <X11/Xmd.h>
94 #include "globals.h"
96 #ifdef PANORAMIX
97 #include "panoramiX.h"
98 #include "panoramiXsrv.h"
99 #endif
102 machine-independent graphics exposure code. any device that uses
103 the region package can call this.
106 #ifndef RECTLIMIT
107 #define RECTLIMIT 25 /* pick a number, any number > 8 */
108 #endif
110 /* miHandleExposures
111 generate a region for exposures for areas that were copied from obscured or
112 non-existent areas to non-obscured areas of the destination. Paint the
113 background for the region, if the destination is a window.
115 NOTE:
116 this should generally be called, even if graphicsExposures is false,
117 because this is where bits get recovered from backing store.
119 NOTE:
120 added argument 'plane' is used to indicate how exposures from backing
121 store should be accomplished. If plane is 0 (i.e. no bit plane), CopyArea
122 should be used, else a CopyPlane of the indicated plane will be used. The
123 exposing is done by the backing store's GraphicsExpose function, of course.
127 RegionPtr
128 miHandleExposures(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable,
129 GCPtr pGC, int srcx, int srcy, int width, int height,
130 int dstx, int dsty, unsigned long plane)
132 RegionPtr prgnSrcClip; /* drawable-relative source clip */
133 RegionRec rgnSrcRec;
134 RegionPtr prgnDstClip; /* drawable-relative dest clip */
135 RegionRec rgnDstRec;
136 BoxRec srcBox; /* unclipped source */
137 RegionRec rgnExposed; /* exposed region, calculated source-
138 relative, made dst relative to
139 intersect with visible parts of
140 dest and send events to client,
141 and then screen relative to paint
142 the window background
144 WindowPtr pSrcWin;
145 BoxRec expBox;
146 Bool extents;
148 /* avoid work if we can */
149 if (!pGC->graphicsExposures &&
150 (pDstDrawable->type == DRAWABLE_PIXMAP) &&
151 ((pSrcDrawable->type == DRAWABLE_PIXMAP) ||
152 (((WindowPtr) pSrcDrawable)->backStorage == NULL)))
153 return NULL;
155 srcBox.x1 = srcx;
156 srcBox.y1 = srcy;
157 srcBox.x2 = srcx + width;
158 srcBox.y2 = srcy + height;
160 if (pSrcDrawable->type != DRAWABLE_PIXMAP) {
161 BoxRec TsrcBox;
163 TsrcBox.x1 = srcx + pSrcDrawable->x;
164 TsrcBox.y1 = srcy + pSrcDrawable->y;
165 TsrcBox.x2 = TsrcBox.x1 + width;
166 TsrcBox.y2 = TsrcBox.y1 + height;
167 pSrcWin = (WindowPtr) pSrcDrawable;
168 if (pGC->subWindowMode == IncludeInferiors) {
169 prgnSrcClip = NotClippedByChildren(pSrcWin);
170 if ((RegionContainsRect(prgnSrcClip, &TsrcBox)) == rgnIN) {
171 RegionDestroy(prgnSrcClip);
172 return NULL;
175 else {
176 if ((RegionContainsRect(&pSrcWin->clipList, &TsrcBox)) == rgnIN)
177 return NULL;
178 prgnSrcClip = &rgnSrcRec;
179 RegionNull(prgnSrcClip);
180 RegionCopy(prgnSrcClip, &pSrcWin->clipList);
182 RegionTranslate(prgnSrcClip, -pSrcDrawable->x, -pSrcDrawable->y);
184 else {
185 BoxRec box;
187 if ((srcBox.x1 >= 0) && (srcBox.y1 >= 0) &&
188 (srcBox.x2 <= pSrcDrawable->width) &&
189 (srcBox.y2 <= pSrcDrawable->height))
190 return NULL;
192 box.x1 = 0;
193 box.y1 = 0;
194 box.x2 = pSrcDrawable->width;
195 box.y2 = pSrcDrawable->height;
196 prgnSrcClip = &rgnSrcRec;
197 RegionInit(prgnSrcClip, &box, 1);
198 pSrcWin = NULL;
201 if (pDstDrawable == pSrcDrawable) {
202 prgnDstClip = prgnSrcClip;
204 else if (pDstDrawable->type != DRAWABLE_PIXMAP) {
205 if (pGC->subWindowMode == IncludeInferiors) {
206 prgnDstClip = NotClippedByChildren((WindowPtr) pDstDrawable);
208 else {
209 prgnDstClip = &rgnDstRec;
210 RegionNull(prgnDstClip);
211 RegionCopy(prgnDstClip, &((WindowPtr) pDstDrawable)->clipList);
213 RegionTranslate(prgnDstClip, -pDstDrawable->x, -pDstDrawable->y);
215 else {
216 BoxRec box;
218 box.x1 = 0;
219 box.y1 = 0;
220 box.x2 = pDstDrawable->width;
221 box.y2 = pDstDrawable->height;
222 prgnDstClip = &rgnDstRec;
223 RegionInit(prgnDstClip, &box, 1);
226 /* drawable-relative source region */
227 RegionInit(&rgnExposed, &srcBox, 1);
229 /* now get the hidden parts of the source box */
230 RegionSubtract(&rgnExposed, &rgnExposed, prgnSrcClip);
232 /* move them over the destination */
233 RegionTranslate(&rgnExposed, dstx - srcx, dsty - srcy);
235 /* intersect with visible areas of dest */
236 RegionIntersect(&rgnExposed, &rgnExposed, prgnDstClip);
238 /* intersect with client clip region. */
239 if (pGC->clientClipType == CT_REGION)
240 RegionIntersect(&rgnExposed, &rgnExposed, pGC->clientClip);
243 * If we have LOTS of rectangles, we decide to take the extents
244 * and force an exposure on that. This should require much less
245 * work overall, on both client and server. This is cheating, but
246 * isn't prohibited by the protocol ("spontaneous combustion" :-)
247 * for windows.
249 extents = pGC->graphicsExposures &&
250 (RegionNumRects(&rgnExposed) > RECTLIMIT) &&
251 (pDstDrawable->type != DRAWABLE_PIXMAP);
252 if (pSrcWin) {
253 RegionPtr region;
255 if (!(region = wClipShape(pSrcWin)))
256 region = wBoundingShape(pSrcWin);
258 * If you try to CopyArea the extents of a shaped window, compacting the
259 * exposed region will undo all our work!
261 if (extents && pSrcWin && region &&
262 (RegionContainsRect(region, &srcBox) != rgnIN))
263 extents = FALSE;
265 if (extents) {
266 expBox = *RegionExtents(&rgnExposed);
267 RegionReset(&rgnExposed, &expBox);
269 if ((pDstDrawable->type != DRAWABLE_PIXMAP) &&
270 (((WindowPtr) pDstDrawable)->backgroundState != None)) {
271 WindowPtr pWin = (WindowPtr) pDstDrawable;
273 /* make the exposed area screen-relative */
274 RegionTranslate(&rgnExposed, pDstDrawable->x, pDstDrawable->y);
276 if (extents) {
277 /* miPaintWindow doesn't clip, so we have to */
278 RegionIntersect(&rgnExposed, &rgnExposed, &pWin->clipList);
280 miPaintWindow((WindowPtr) pDstDrawable, &rgnExposed, PW_BACKGROUND);
282 if (extents) {
283 RegionReset(&rgnExposed, &expBox);
285 else
286 RegionTranslate(&rgnExposed, -pDstDrawable->x, -pDstDrawable->y);
288 if (prgnDstClip == &rgnDstRec) {
289 RegionUninit(prgnDstClip);
291 else if (prgnDstClip != prgnSrcClip) {
292 RegionDestroy(prgnDstClip);
295 if (prgnSrcClip == &rgnSrcRec) {
296 RegionUninit(prgnSrcClip);
298 else {
299 RegionDestroy(prgnSrcClip);
302 if (pGC->graphicsExposures) {
303 /* don't look */
304 RegionPtr exposed = RegionCreate(NullBox, 0);
306 *exposed = rgnExposed;
307 return exposed;
309 else {
310 RegionUninit(&rgnExposed);
311 return NULL;
315 /* send GraphicsExpose events, or a NoExpose event, based on the region */
317 void
318 miSendGraphicsExpose(ClientPtr client, RegionPtr pRgn, XID drawable,
319 int major, int minor)
321 if (pRgn && !RegionNil(pRgn)) {
322 xEvent *pEvent;
323 xEvent *pe;
324 BoxPtr pBox;
325 int i;
326 int numRects;
328 numRects = RegionNumRects(pRgn);
329 pBox = RegionRects(pRgn);
330 if (!(pEvent = malloc(numRects * sizeof(xEvent))))
331 return;
332 pe = pEvent;
334 for (i = 1; i <= numRects; i++, pe++, pBox++) {
335 pe->u.u.type = GraphicsExpose;
336 pe->u.graphicsExposure.drawable = drawable;
337 pe->u.graphicsExposure.x = pBox->x1;
338 pe->u.graphicsExposure.y = pBox->y1;
339 pe->u.graphicsExposure.width = pBox->x2 - pBox->x1;
340 pe->u.graphicsExposure.height = pBox->y2 - pBox->y1;
341 pe->u.graphicsExposure.count = numRects - i;
342 pe->u.graphicsExposure.majorEvent = major;
343 pe->u.graphicsExposure.minorEvent = minor;
345 /* GraphicsExpose is a "critical event", which TryClientEvents
346 * handles specially. */
347 TryClientEvents(client, NULL, pEvent, numRects,
348 (Mask) 0, NoEventMask, NullGrab);
349 free(pEvent);
351 else {
352 xEvent event;
354 memset(&event, 0, sizeof(xEvent));
355 event.u.u.type = NoExpose;
356 event.u.noExposure.drawable = drawable;
357 event.u.noExposure.majorEvent = major;
358 event.u.noExposure.minorEvent = minor;
359 WriteEventsToClient(client, 1, &event);
363 void
364 miSendExposures(WindowPtr pWin, RegionPtr pRgn, int dx, int dy)
366 BoxPtr pBox;
367 int numRects;
368 xEvent *pEvent, *pe;
369 int i;
371 pBox = RegionRects(pRgn);
372 numRects = RegionNumRects(pRgn);
373 if (!(pEvent = calloc(1, numRects * sizeof(xEvent))))
374 return;
376 for (i = numRects, pe = pEvent; --i >= 0; pe++, pBox++) {
377 pe->u.u.type = Expose;
378 pe->u.expose.window = pWin->drawable.id;
379 pe->u.expose.x = pBox->x1 - dx;
380 pe->u.expose.y = pBox->y1 - dy;
381 pe->u.expose.width = pBox->x2 - pBox->x1;
382 pe->u.expose.height = pBox->y2 - pBox->y1;
383 pe->u.expose.count = i;
386 #ifdef PANORAMIX
387 if (!noPanoramiXExtension) {
388 int scrnum = pWin->drawable.pScreen->myNum;
389 int x = 0, y = 0;
390 XID realWin = 0;
392 if (!pWin->parent) {
393 x = screenInfo.screens[scrnum]->x;
394 y = screenInfo.screens[scrnum]->y;
395 pWin = screenInfo.screens[0]->root;
396 realWin = pWin->drawable.id;
398 else if (scrnum) {
399 PanoramiXRes *win;
401 win = PanoramiXFindIDByScrnum(XRT_WINDOW,
402 pWin->drawable.id, scrnum);
403 if (!win) {
404 free(pEvent);
405 return;
407 realWin = win->info[0].id;
408 dixLookupWindow(&pWin, realWin, serverClient, DixSendAccess);
410 if (x || y || scrnum)
411 for (i = 0; i < numRects; i++) {
412 pEvent[i].u.expose.window = realWin;
413 pEvent[i].u.expose.x += x;
414 pEvent[i].u.expose.y += y;
417 #endif
419 DeliverEvents(pWin, pEvent, numRects, NullWindow);
421 free(pEvent);
424 void
425 miWindowExposures(WindowPtr pWin, RegionPtr prgn, RegionPtr other_exposed)
427 RegionPtr exposures = prgn;
429 if ((prgn && !RegionNil(prgn)) ||
430 (exposures && !RegionNil(exposures)) || other_exposed) {
431 RegionRec expRec;
432 int clientInterested;
435 * Restore from backing-store FIRST.
437 clientInterested =
438 (pWin->eventMask | wOtherEventMasks(pWin)) & ExposureMask;
439 if (other_exposed) {
440 if (exposures) {
441 RegionUnion(other_exposed, exposures, other_exposed);
442 if (exposures != prgn)
443 RegionDestroy(exposures);
445 exposures = other_exposed;
447 if (clientInterested && exposures &&
448 (RegionNumRects(exposures) > RECTLIMIT)) {
450 * If we have LOTS of rectangles, we decide to take the extents
451 * and force an exposure on that. This should require much less
452 * work overall, on both client and server. This is cheating, but
453 * isn't prohibited by the protocol ("spontaneous combustion" :-).
455 BoxRec box;
457 box = *RegionExtents(exposures);
458 if (exposures == prgn) {
459 exposures = &expRec;
460 RegionInit(exposures, &box, 1);
461 RegionReset(prgn, &box);
463 else {
464 RegionReset(exposures, &box);
465 RegionUnion(prgn, prgn, exposures);
467 /* miPaintWindow doesn't clip, so we have to */
468 RegionIntersect(prgn, prgn, &pWin->clipList);
470 if (prgn && !RegionNil(prgn))
471 miPaintWindow(pWin, prgn, PW_BACKGROUND);
472 if (clientInterested && exposures && !RegionNil(exposures))
473 miSendExposures(pWin, exposures,
474 pWin->drawable.x, pWin->drawable.y);
475 if (exposures == &expRec) {
476 RegionUninit(exposures);
478 else if (exposures && exposures != prgn && exposures != other_exposed)
479 RegionDestroy(exposures);
480 if (prgn)
481 RegionEmpty(prgn);
483 else if (exposures && exposures != prgn)
484 RegionDestroy(exposures);
487 #ifdef ROOTLESS
488 /* Ugly, ugly, but we lost our hooks into miPaintWindow... =/ */
489 void RootlessSetPixmapOfAncestors(WindowPtr pWin);
490 void RootlessStartDrawing(WindowPtr pWin);
491 void RootlessDamageRegion(WindowPtr pWin, RegionPtr prgn);
492 Bool IsFramedWindow(WindowPtr pWin);
493 #endif
495 void
496 miPaintWindow(WindowPtr pWin, RegionPtr prgn, int what)
498 ScreenPtr pScreen = pWin->drawable.pScreen;
499 ChangeGCVal gcval[6];
500 BITS32 gcmask;
501 GCPtr pGC;
502 int i;
503 BoxPtr pbox;
504 xRectangle *prect;
505 int numRects;
508 * Distance from screen to destination drawable, use this
509 * to adjust rendering coordinates which come in in screen space
511 int draw_x_off, draw_y_off;
514 * Tile offset for drawing; these need to align the tile
515 * to the appropriate window origin
517 int tile_x_off, tile_y_off;
518 PixUnion fill;
519 Bool solid = TRUE;
520 DrawablePtr drawable = &pWin->drawable;
522 #ifdef ROOTLESS
523 if (!drawable || drawable->type == UNDRAWABLE_WINDOW)
524 return;
526 if (IsFramedWindow(pWin)) {
527 RootlessStartDrawing(pWin);
528 RootlessDamageRegion(pWin, prgn);
530 if (pWin->backgroundState == ParentRelative) {
531 if ((what == PW_BACKGROUND) ||
532 (what == PW_BORDER && !pWin->borderIsPixel))
533 RootlessSetPixmapOfAncestors(pWin);
536 #endif
538 if (what == PW_BACKGROUND) {
539 while (pWin->backgroundState == ParentRelative)
540 pWin = pWin->parent;
542 draw_x_off = drawable->x;
543 draw_y_off = drawable->y;
545 tile_x_off = pWin->drawable.x - draw_x_off;
546 tile_y_off = pWin->drawable.y - draw_y_off;
547 fill = pWin->background;
548 #ifdef COMPOSITE
549 if (pWin->inhibitBGPaint)
550 return;
551 #endif
552 switch (pWin->backgroundState) {
553 case None:
554 return;
555 case BackgroundPixmap:
556 solid = FALSE;
557 break;
560 else {
561 PixmapPtr pixmap;
563 tile_x_off = drawable->x;
564 tile_y_off = drawable->y;
566 /* servers without pixmaps draw their own borders */
567 if (!pScreen->GetWindowPixmap)
568 return;
569 pixmap = (*pScreen->GetWindowPixmap) ((WindowPtr) drawable);
570 drawable = &pixmap->drawable;
571 #ifdef COMPOSITE
572 draw_x_off = pixmap->screen_x;
573 draw_y_off = pixmap->screen_y;
574 tile_x_off -= draw_x_off;
575 tile_y_off -= draw_y_off;
576 #else
577 draw_x_off = 0;
578 draw_y_off = 0;
579 #endif
580 fill = pWin->border;
581 solid = pWin->borderIsPixel;
584 gcval[0].val = GXcopy;
585 gcmask = GCFunction;
587 #ifdef ROOTLESS_SAFEALPHA
588 /* Bit mask for alpha channel with a particular number of bits per
589 * pixel. Note that we only care for 32bpp data. Mac OS X uses planar
590 * alpha for 16bpp.
592 #define RootlessAlphaMask(bpp) ((bpp) == 32 ? 0xFF000000 : 0)
593 #endif
595 if (solid) {
596 #ifdef ROOTLESS_SAFEALPHA
597 gcval[1].val =
598 fill.pixel | RootlessAlphaMask(pWin->drawable.bitsPerPixel);
599 #else
600 gcval[1].val = fill.pixel;
601 #endif
602 gcval[2].val = FillSolid;
603 gcmask |= GCForeground | GCFillStyle;
605 else {
606 int c = 1;
608 #ifdef ROOTLESS_SAFEALPHA
609 gcval[c++].val =
610 ((CARD32) -1) & ~RootlessAlphaMask(pWin->drawable.bitsPerPixel);
611 gcmask |= GCPlaneMask;
612 #endif
613 gcval[c++].val = FillTiled;
614 gcval[c++].ptr = (pointer) fill.pixmap;
615 gcval[c++].val = tile_x_off;
616 gcval[c++].val = tile_y_off;
617 gcmask |= GCFillStyle | GCTile | GCTileStipXOrigin | GCTileStipYOrigin;
620 prect = malloc(RegionNumRects(prgn) * sizeof(xRectangle));
621 if (!prect)
622 return;
624 pGC = GetScratchGC(drawable->depth, drawable->pScreen);
625 if (!pGC) {
626 free(prect);
627 return;
630 ChangeGC(NullClient, pGC, gcmask, gcval);
631 ValidateGC(drawable, pGC);
633 numRects = RegionNumRects(prgn);
634 pbox = RegionRects(prgn);
635 for (i = numRects; --i >= 0; pbox++, prect++) {
636 prect->x = pbox->x1 - draw_x_off;
637 prect->y = pbox->y1 - draw_y_off;
638 prect->width = pbox->x2 - pbox->x1;
639 prect->height = pbox->y2 - pbox->y1;
641 prect -= numRects;
642 (*pGC->ops->PolyFillRect) (drawable, pGC, numRects, prect);
643 free(prect);
645 FreeScratchGC(pGC);
648 /* MICLEARDRAWABLE -- sets the entire drawable to the background color of
649 * the GC. Useful when we have a scratch drawable and need to initialize
650 * it. */
651 void
652 miClearDrawable(DrawablePtr pDraw, GCPtr pGC)
654 ChangeGCVal fg, bg;
655 xRectangle rect;
657 fg.val = pGC->fgPixel;
658 bg.val = pGC->bgPixel;
659 rect.x = 0;
660 rect.y = 0;
661 rect.width = pDraw->width;
662 rect.height = pDraw->height;
663 ChangeGC(NullClient, pGC, GCForeground, &bg);
664 ValidateGC(pDraw, pGC);
665 (*pGC->ops->PolyFillRect) (pDraw, pGC, 1, &rect);
666 ChangeGC(NullClient, pGC, GCForeground, &fg);
667 ValidateGC(pDraw, pGC);