~ubuntu-branches/ubuntu/intrepid/xserver-xgl/intrepid

« back to all changes in this revision

Viewing changes to hw/xwin/winwindow.c

  • Committer: Bazaar Package Importer
  • Author(s): Matthew Garrett
  • Date: 2006-02-13 14:21:43 UTC
  • Revision ID: james.westby@ubuntu.com-20060213142143-mad6z9xzem7hzxz9
Tags: upstream-7.0.0
ImportĀ upstreamĀ versionĀ 7.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 *Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved.
 
3
 *
 
4
 *Permission is hereby granted, free of charge, to any person obtaining
 
5
 * a copy of this software and associated documentation files (the
 
6
 *"Software"), to deal in the Software without restriction, including
 
7
 *without limitation the rights to use, copy, modify, merge, publish,
 
8
 *distribute, sublicense, and/or sell copies of the Software, and to
 
9
 *permit persons to whom the Software is furnished to do so, subject to
 
10
 *the following conditions:
 
11
 *
 
12
 *The above copyright notice and this permission notice shall be
 
13
 *included in all copies or substantial portions of the Software.
 
14
 *
 
15
 *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 
16
 *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 
17
 *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 
18
 *NONINFRINGEMENT. IN NO EVENT SHALL THE XFREE86 PROJECT BE LIABLE FOR
 
19
 *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
 
20
 *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 
21
 *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
22
 *
 
23
 *Except as contained in this notice, the name of the XFree86 Project
 
24
 *shall not be used in advertising or otherwise to promote the sale, use
 
25
 *or other dealings in this Software without prior written authorization
 
26
 *from the XFree86 Project.
 
27
 *
 
28
 * Authors:     Harold L Hunt II
 
29
 *              Kensuke Matsuzaki
 
30
 */
 
31
/* $XFree86: xc/programs/Xserver/hw/xwin/winwindow.c,v 1.9 2003/11/10 18:22:44 tsi Exp $ */
 
32
 
 
33
#ifdef HAVE_XWIN_CONFIG_H
 
34
#include <xwin-config.h>
 
35
#endif
 
36
#include "win.h"
 
37
 
 
38
 
 
39
/*
 
40
 * Prototypes for local functions
 
41
 */
 
42
 
 
43
static int
 
44
winAddRgn (WindowPtr pWindow, pointer data);
 
45
 
 
46
static
 
47
void
 
48
winUpdateRgnRootless (WindowPtr pWindow);
 
49
 
 
50
#ifdef SHAPE
 
51
static
 
52
void
 
53
winReshapeRootless (WindowPtr pWin);
 
54
#endif
 
55
 
 
56
 
 
57
#ifdef XWIN_NATIVEGDI
 
58
/* See Porting Layer Definition - p. 37 */
 
59
/* See mfb/mfbwindow.c - mfbCreateWindow() */
 
60
 
 
61
Bool
 
62
winCreateWindowNativeGDI (WindowPtr pWin)
 
63
{
 
64
  ScreenPtr             pScreen = pWin->drawable.pScreen;
 
65
  winWindowPriv(pWin);
 
66
  winScreenPriv(pScreen);
 
67
 
 
68
#if CYGDEBUG
 
69
  winTrace ("winCreateWindowNativeGDI (%p)\n", pWin);
 
70
#endif
 
71
 
 
72
  WIN_UNWRAP(CreateWindow);
 
73
  fResult = (*pScreen->CreateWindow) (pWin);
 
74
  WIN_WRAP(CreateWindow, winCreateWindowNativeGDI);
 
75
 
 
76
  return fResult;
 
77
}
 
78
 
 
79
 
 
80
/* See Porting Layer Definition - p. 37 */
 
81
/* See mfb/mfbwindow.c - mfbDestroyWindow() */
 
82
 
 
83
Bool
 
84
winDestroyWindowNativeGDI (WindowPtr pWin)
 
85
{
 
86
  Bool                  fResult = TRUE;
 
87
  ScreenPtr             pScreen = pWin->drawable.pScreen;
 
88
  winWindowPriv(pWin);
 
89
  winScreenPriv(pScreen);
 
90
 
 
91
#if CYGDEBUG
 
92
  winTrace ("winDestroyWindowNativeGDI (%p)\n", pWin);
 
93
#endif
 
94
 
 
95
  WIN_UNWRAP(DestroyWindow); 
 
96
  fResult = (*pScreen->DestroyWindow)(pWin);
 
97
  WIN_WRAP(DestroyWindow, winDestroyWindowNativeGDI);
 
98
 
 
99
  return fResult;
 
100
}
 
101
 
 
102
 
 
103
/* See Porting Layer Definition - p. 37 */
 
104
/* See mfb/mfbwindow.c - mfbPositionWindow() */
 
105
 
 
106
Bool
 
107
winPositionWindowNativeGDI (WindowPtr pWin, int x, int y)
 
108
{
 
109
  Bool                  fResult = TRUE;
 
110
  ScreenPtr             pScreen = pWin->drawable.pScreen;
 
111
  winWindowPriv(pWin);
 
112
  winScreenPriv(pScreen);
 
113
 
 
114
#if CYGDEBUG
 
115
  winTrace ("winPositionWindowNativeGDI (%p)\n", pWin);
 
116
#endif
 
117
 
 
118
  WIN_UNWRAP(PositionWindow);
 
119
  fResult = (*pScreen->PositionWindow)(pWin, x, y);
 
120
  WIN_WRAP(PositionWindow, winPositionWindowNativeGDI);
 
121
 
 
122
  return fResult;
 
123
}
 
124
 
 
125
 
 
126
/* See Porting Layer Definition - p. 39 */
 
127
/* See mfb/mfbwindow.c - mfbCopyWindow() */
 
128
 
 
129
void 
 
130
winCopyWindowNativeGDI (WindowPtr pWin,
 
131
                        DDXPointRec ptOldOrg,
 
132
                        RegionPtr prgnSrc)
 
133
{
 
134
  DDXPointPtr           pptSrc;
 
135
  DDXPointPtr           ppt;
 
136
  RegionPtr             prgnDst;
 
137
  BoxPtr                pBox;
 
138
  int                   dx, dy;
 
139
  int                   i, nbox;
 
140
  WindowPtr             pwinRoot;
 
141
  BoxPtr                pBoxDst;
 
142
  ScreenPtr             pScreen = pWin->drawable.pScreen;
 
143
  winScreenPriv(pScreen);
 
144
 
 
145
#if 0
 
146
  ErrorF ("winCopyWindow\n");
 
147
#endif
 
148
 
 
149
  /* Get a pointer to the root window */
 
150
  pwinRoot = WindowTable[pWin->drawable.pScreen->myNum];
 
151
 
 
152
  /* Create a region for the destination */
 
153
  prgnDst = REGION_CREATE(pWin->drawable.pScreen, NULL, 1);
 
154
 
 
155
  /* Calculate the shift from the source to the destination */
 
156
  dx = ptOldOrg.x - pWin->drawable.x;
 
157
  dy = ptOldOrg.y - pWin->drawable.y;
 
158
 
 
159
  /* Translate the region from the destination to the source? */
 
160
  REGION_TRANSLATE(pWin->drawable.pScreen, prgnSrc, -dx, -dy);
 
161
  REGION_INTERSECT(pWin->drawable.pScreen, prgnDst, &pWin->borderClip,
 
162
                   prgnSrc);
 
163
 
 
164
  /* Get a pointer to the first box in the region to be copied */
 
165
  pBox = REGION_RECTS(prgnDst);
 
166
  
 
167
  /* Get the number of boxes in the region */
 
168
  nbox = REGION_NUM_RECTS(prgnDst);
 
169
 
 
170
  /* Allocate source points for each box */
 
171
  if(!(pptSrc = (DDXPointPtr )ALLOCATE_LOCAL(nbox * sizeof(DDXPointRec))))
 
172
    return;
 
173
 
 
174
  /* Set an iterator pointer */
 
175
  ppt = pptSrc;
 
176
 
 
177
  /* Calculate the source point of each box? */
 
178
  for (i = nbox; --i >= 0; ppt++, pBox++)
 
179
    {
 
180
      ppt->x = pBox->x1 + dx;
 
181
      ppt->y = pBox->y1 + dy;
 
182
    }
 
183
 
 
184
  /* Setup loop pointers again */
 
185
  pBoxDst = REGION_RECTS(prgnDst);
 
186
  ppt = pptSrc;
 
187
 
 
188
#if 0
 
189
  ErrorF ("winCopyWindow - x1\tx2\ty1\ty2\tx\ty\n");
 
190
#endif
 
191
 
 
192
  /* BitBlt each source to the destination point */
 
193
  for (i = nbox; --i >= 0; pBoxDst++, ppt++)
 
194
    {
 
195
#if 0
 
196
      ErrorF ("winCopyWindow - %d\t%d\t%d\t%d\t%d\t%d\n",
 
197
              pBoxDst->x1, pBoxDst->x2, pBoxDst->y1, pBoxDst->y2,
 
198
              ppt->x, ppt->y);
 
199
#endif
 
200
 
 
201
      BitBlt (pScreenPriv->hdcScreen,
 
202
              pBoxDst->x1, pBoxDst->y1,
 
203
              pBoxDst->x2 - pBoxDst->x1, pBoxDst->y2 - pBoxDst->y1,
 
204
              pScreenPriv->hdcScreen,
 
205
              ppt->x, ppt->y,
 
206
              SRCCOPY);
 
207
    }
 
208
 
 
209
  /* Cleanup the regions, etc. */
 
210
  DEALLOCATE_LOCAL(pptSrc);
 
211
  REGION_DESTROY(pWin->drawable.pScreen, prgnDst);
 
212
}
 
213
 
 
214
 
 
215
/* See Porting Layer Definition - p. 37 */
 
216
/* See mfb/mfbwindow.c - mfbChangeWindowAttributes() */
 
217
 
 
218
Bool
 
219
winChangeWindowAttributesNativeGDI (WindowPtr pWin, unsigned long mask)
 
220
{
 
221
  Bool                  fResult = TRUE;
 
222
  ScreenPtr             pScreen = pWin->drawable.pScreen;
 
223
  winWindowPriv(pWin);
 
224
  winScreenPriv(pScreen);
 
225
 
 
226
#if CYGDEBUG
 
227
  winTrace ("winChangeWindowAttributesNativeGDI (%p)\n", pWin);
 
228
#endif
 
229
  
 
230
  WIN_UNWRAP(ChangeWindowAttributes); 
 
231
  fResult = (*pScreen->ChangeWindowAttributes)(pWin, mask);
 
232
  WIN_WRAP(ChangeWindowAttributes, winChangeWindowAttributesNativeGDI);
 
233
  
 
234
  /*
 
235
   * NOTE: We do not currently need to do anything here.
 
236
   */
 
237
 
 
238
  return fResult;
 
239
}
 
240
 
 
241
 
 
242
/* See Porting Layer Definition - p. 37
 
243
 * Also referred to as UnrealizeWindow
 
244
 */
 
245
 
 
246
Bool
 
247
winUnmapWindowNativeGDI (WindowPtr pWin)
 
248
{
 
249
  Bool                  fResult = TRUE;
 
250
  ScreenPtr             pScreen = pWin->drawable.pScreen;
 
251
  winWindowPriv(pWin);
 
252
  winScreenPriv(pScreen);
 
253
 
 
254
#if CYGDEBUG
 
255
  winTrace ("winUnmapWindowNativeGDI (%p)\n", pWin);
 
256
#endif
 
257
 
 
258
  WIN_UNWRAP(UnrealizeWindow); 
 
259
  fResult = (*pScreen->UnrealizeWindow)(pWin);
 
260
  WIN_WRAP(UnrealizeWindow, winUnmapWindowNativeGDI);
 
261
  
 
262
  return fResult;
 
263
}
 
264
 
 
265
 
 
266
/* See Porting Layer Definition - p. 37
 
267
 * Also referred to as RealizeWindow
 
268
 */
 
269
 
 
270
Bool
 
271
winMapWindowNativeGDI (WindowPtr pWin)
 
272
{
 
273
  Bool                  fResult = TRUE;
 
274
  ScreenPtr             pScreen = pWin->drawable.pScreen;
 
275
  winWindowPriv(pWin);
 
276
  winScreenPriv(pScreen);
 
277
 
 
278
#if CYGDEBUG
 
279
  winTrace ("winMapWindowNativeGDI (%p)\n", pWin);
 
280
#endif
 
281
 
 
282
  WIN_UNWRAP(RealizeWindow); 
 
283
  fResult = (*pScreen->RealizeWindow)(pWin);
 
284
  WIN_WRAP(RealizeWindow, winMapWindowMultiWindow);
 
285
  
 
286
  return fResult;
 
287
 
 
288
}
 
289
#endif
 
290
 
 
291
 
 
292
/* See Porting Layer Definition - p. 37 */
 
293
/* See mfb/mfbwindow.c - mfbCreateWindow() */
 
294
 
 
295
Bool
 
296
winCreateWindowRootless (WindowPtr pWin)
 
297
{
 
298
  Bool                  fResult = FALSE;
 
299
  ScreenPtr             pScreen = pWin->drawable.pScreen;
 
300
  winWindowPriv(pWin);
 
301
  winScreenPriv(pScreen);
 
302
 
 
303
#if CYGDEBUG
 
304
  winTrace ("winCreateWindowRootless (%p)\n", pWin);
 
305
#endif
 
306
 
 
307
  WIN_UNWRAP(CreateWindow);
 
308
  fResult = (*pScreen->CreateWindow) (pWin);
 
309
  WIN_WRAP(CreateWindow, winCreateWindowRootless);
 
310
  
 
311
  pWinPriv->hRgn = NULL;
 
312
  
 
313
  return fResult;
 
314
}
 
315
 
 
316
 
 
317
/* See Porting Layer Definition - p. 37 */
 
318
/* See mfb/mfbwindow.c - mfbDestroyWindow() */
 
319
 
 
320
Bool
 
321
winDestroyWindowRootless (WindowPtr pWin)
 
322
{
 
323
  Bool                  fResult = FALSE;
 
324
  ScreenPtr             pScreen = pWin->drawable.pScreen;
 
325
  winWindowPriv(pWin);
 
326
  winScreenPriv(pScreen);
 
327
 
 
328
#if CYGDEBUG
 
329
  winTrace ("winDestroyWindowRootless (%p)\n", pWin);
 
330
#endif
 
331
 
 
332
  WIN_UNWRAP(DestroyWindow); 
 
333
  fResult = (*pScreen->DestroyWindow)(pWin);
 
334
  WIN_WRAP(DestroyWindow, winDestroyWindowRootless);
 
335
  
 
336
  if (pWinPriv->hRgn != NULL)
 
337
    {
 
338
      DeleteObject(pWinPriv->hRgn);
 
339
      pWinPriv->hRgn = NULL;
 
340
    }
 
341
  
 
342
  winUpdateRgnRootless (pWin);
 
343
  
 
344
  return fResult;
 
345
}
 
346
 
 
347
 
 
348
/* See Porting Layer Definition - p. 37 */
 
349
/* See mfb/mfbwindow.c - mfbPositionWindow() */
 
350
 
 
351
Bool
 
352
winPositionWindowRootless (WindowPtr pWin, int x, int y)
 
353
{
 
354
  Bool                  fResult = FALSE;
 
355
  ScreenPtr             pScreen = pWin->drawable.pScreen;
 
356
  winWindowPriv(pWin);
 
357
  winScreenPriv(pScreen);
 
358
 
 
359
 
 
360
#if CYGDEBUG
 
361
  winTrace ("winPositionWindowRootless (%p)\n", pWin);
 
362
#endif
 
363
 
 
364
  WIN_UNWRAP(PositionWindow);
 
365
  fResult = (*pScreen->PositionWindow)(pWin, x, y);
 
366
  WIN_WRAP(PositionWindow, winPositionWindowRootless);
 
367
  
 
368
  winUpdateRgnRootless (pWin);
 
369
  
 
370
  return fResult;
 
371
}
 
372
 
 
373
 
 
374
/* See Porting Layer Definition - p. 37 */
 
375
/* See mfb/mfbwindow.c - mfbChangeWindowAttributes() */
 
376
 
 
377
Bool
 
378
winChangeWindowAttributesRootless (WindowPtr pWin, unsigned long mask)
 
379
{
 
380
  Bool                  fResult = FALSE;
 
381
  ScreenPtr             pScreen = pWin->drawable.pScreen;
 
382
  winWindowPriv(pWin);
 
383
  winScreenPriv(pScreen);
 
384
 
 
385
#if CYGDEBUG
 
386
  winTrace ("winChangeWindowAttributesRootless (%p)\n", pWin);
 
387
#endif
 
388
 
 
389
  WIN_UNWRAP(ChangeWindowAttributes); 
 
390
  fResult = (*pScreen->ChangeWindowAttributes)(pWin, mask);
 
391
  WIN_WRAP(ChangeWindowAttributes, winChangeWindowAttributesRootless);
 
392
 
 
393
  winUpdateRgnRootless (pWin);
 
394
  
 
395
  return fResult;
 
396
}
 
397
 
 
398
 
 
399
/* See Porting Layer Definition - p. 37
 
400
 * Also referred to as UnrealizeWindow
 
401
 */
 
402
 
 
403
Bool
 
404
winUnmapWindowRootless (WindowPtr pWin)
 
405
{
 
406
  Bool                  fResult = FALSE;
 
407
  ScreenPtr             pScreen = pWin->drawable.pScreen;
 
408
  winWindowPriv(pWin);
 
409
  winScreenPriv(pScreen);
 
410
 
 
411
#if CYGDEBUG
 
412
  winTrace ("winUnmapWindowRootless (%p)\n", pWin);
 
413
#endif
 
414
 
 
415
  WIN_UNWRAP(UnrealizeWindow); 
 
416
  fResult = (*pScreen->UnrealizeWindow)(pWin);
 
417
  WIN_WRAP(UnrealizeWindow, winUnmapWindowRootless);
 
418
  
 
419
  if (pWinPriv->hRgn != NULL)
 
420
    {
 
421
      DeleteObject(pWinPriv->hRgn);
 
422
      pWinPriv->hRgn = NULL;
 
423
    }
 
424
  
 
425
  winUpdateRgnRootless (pWin);
 
426
  
 
427
  return fResult;
 
428
}
 
429
 
 
430
 
 
431
/* See Porting Layer Definition - p. 37
 
432
 * Also referred to as RealizeWindow
 
433
 */
 
434
 
 
435
Bool
 
436
winMapWindowRootless (WindowPtr pWin)
 
437
{
 
438
  Bool                  fResult = FALSE;
 
439
  ScreenPtr             pScreen = pWin->drawable.pScreen;
 
440
  winWindowPriv(pWin);
 
441
  winScreenPriv(pScreen);
 
442
 
 
443
#if CYGDEBUG
 
444
  winTrace ("winMapWindowRootless (%p)\n", pWin);
 
445
#endif
 
446
 
 
447
  WIN_UNWRAP(RealizeWindow); 
 
448
  fResult = (*pScreen->RealizeWindow)(pWin);
 
449
  WIN_WRAP(RealizeWindow, winMapWindowRootless);
 
450
 
 
451
#ifdef SHAPE
 
452
  winReshapeRootless (pWin);
 
453
#endif
 
454
  
 
455
  winUpdateRgnRootless (pWin);
 
456
  
 
457
  return fResult;
 
458
}
 
459
 
 
460
 
 
461
#ifdef SHAPE
 
462
void
 
463
winSetShapeRootless (WindowPtr pWin)
 
464
{
 
465
  ScreenPtr             pScreen = pWin->drawable.pScreen;
 
466
  winWindowPriv(pWin);
 
467
  winScreenPriv(pScreen);
 
468
 
 
469
#if CYGDEBUG
 
470
  winTrace ("winSetShapeRootless (%p)\n", pWin);
 
471
#endif
 
472
 
 
473
  WIN_UNWRAP(SetShape); 
 
474
  (*pScreen->SetShape)(pWin);
 
475
  WIN_WRAP(SetShape, winSetShapeRootless);
 
476
  
 
477
  winReshapeRootless (pWin);
 
478
  winUpdateRgnRootless (pWin);
 
479
  
 
480
  return;
 
481
}
 
482
#endif
 
483
 
 
484
 
 
485
/*
 
486
 * Local function for adding a region to the Windows window region
 
487
 */
 
488
 
 
489
static
 
490
int
 
491
winAddRgn (WindowPtr pWin, pointer data)
 
492
{
 
493
  int           iX, iY, iWidth, iHeight, iBorder;
 
494
  HRGN          hRgn = *(HRGN*)data;
 
495
  HRGN          hRgnWin;
 
496
  winWindowPriv(pWin);
 
497
  
 
498
  /* If pWin is not Root */
 
499
  if (pWin->parent != NULL) 
 
500
    {
 
501
#if CYGDEBUG
 
502
      winDebug ("winAddRgn ()\n");
 
503
#endif
 
504
      if (pWin->mapped)
 
505
        {
 
506
          iBorder = wBorderWidth (pWin);
 
507
          
 
508
          iX = pWin->drawable.x - iBorder;
 
509
          iY = pWin->drawable.y - iBorder;
 
510
          
 
511
          iWidth = pWin->drawable.width + iBorder * 2;
 
512
          iHeight = pWin->drawable.height + iBorder * 2;
 
513
          
 
514
          hRgnWin = CreateRectRgn (0, 0, iWidth, iHeight);
 
515
          
 
516
          if (hRgnWin == NULL)
 
517
            {
 
518
              ErrorF ("winAddRgn - CreateRectRgn () failed\n");
 
519
              ErrorF ("  Rect %d %d %d %d\n",
 
520
                      iX, iY, iX + iWidth, iY + iHeight);
 
521
            }
 
522
          
 
523
          if (pWinPriv->hRgn)
 
524
            {
 
525
              if (CombineRgn (hRgnWin, hRgnWin, pWinPriv->hRgn, RGN_AND)
 
526
                  == ERROR)
 
527
                {
 
528
                  ErrorF ("winAddRgn - CombineRgn () failed\n");
 
529
                }
 
530
            }
 
531
          
 
532
          OffsetRgn (hRgnWin, iX, iY);
 
533
 
 
534
          if (CombineRgn (hRgn, hRgn, hRgnWin, RGN_OR) == ERROR)
 
535
            {
 
536
              ErrorF ("winAddRgn - CombineRgn () failed\n");
 
537
            }
 
538
          
 
539
          DeleteObject (hRgnWin);
 
540
        }
 
541
      return WT_DONTWALKCHILDREN;
 
542
    }
 
543
  else
 
544
    {
 
545
      return WT_WALKCHILDREN;
 
546
    }
 
547
}
 
548
 
 
549
 
 
550
/*
 
551
 * Local function to update the Windows window's region
 
552
 */
 
553
 
 
554
static
 
555
void
 
556
winUpdateRgnRootless (WindowPtr pWin)
 
557
{
 
558
  HRGN          hRgn = CreateRectRgn (0, 0, 0, 0);
 
559
  
 
560
  if (hRgn != NULL)
 
561
    {
 
562
      WalkTree (pWin->drawable.pScreen, winAddRgn, &hRgn);
 
563
      SetWindowRgn (winGetScreenPriv(pWin->drawable.pScreen)->hwndScreen,
 
564
                    hRgn, TRUE);
 
565
    }
 
566
  else
 
567
    {
 
568
      ErrorF ("winUpdateRgnRootless - CreateRectRgn failed.\n");
 
569
    }
 
570
}
 
571
 
 
572
 
 
573
#ifdef SHAPE
 
574
static
 
575
void
 
576
winReshapeRootless (WindowPtr pWin)
 
577
{
 
578
  int           nRects;
 
579
  /* ScreenPtr  pScreen = pWin->drawable.pScreen;*/
 
580
  RegionRec     rrNewShape;
 
581
  BoxPtr        pShape, pRects, pEnd;
 
582
  HRGN          hRgn, hRgnRect;
 
583
  winWindowPriv(pWin);
 
584
 
 
585
#if CYGDEBUG
 
586
  winDebug ("winReshapeRootless ()\n");
 
587
#endif
 
588
 
 
589
  /* Bail if the window is the root window */
 
590
  if (pWin->parent == NULL)
 
591
    return;
 
592
 
 
593
  /* Bail if the window is not top level */
 
594
  if (pWin->parent->parent != NULL)
 
595
    return;
 
596
 
 
597
  /* Free any existing window region stored in the window privates */
 
598
  if (pWinPriv->hRgn != NULL)
 
599
    {
 
600
      DeleteObject (pWinPriv->hRgn);
 
601
      pWinPriv->hRgn = NULL;
 
602
    }
 
603
  
 
604
  /* Bail if the window has no bounding region defined */
 
605
  if (!wBoundingShape (pWin))
 
606
    return;
 
607
 
 
608
  REGION_NULL(pScreen, &rrNewShape);
 
609
  REGION_COPY(pScreen, &rrNewShape, wBoundingShape(pWin));
 
610
  REGION_TRANSLATE(pScreen, &rrNewShape, pWin->borderWidth,
 
611
                   pWin->borderWidth);
 
612
  
 
613
  nRects = REGION_NUM_RECTS(&rrNewShape);
 
614
  pShape = REGION_RECTS(&rrNewShape);
 
615
  
 
616
  if (nRects > 0)
 
617
    {
 
618
      /* Create initial empty Windows region */
 
619
      hRgn = CreateRectRgn (0, 0, 0, 0);
 
620
 
 
621
      /* Loop through all rectangles in the X region */
 
622
      for (pRects = pShape, pEnd = pShape + nRects; pRects < pEnd; pRects++)
 
623
        {
 
624
          /* Create a Windows region for the X rectangle */
 
625
          hRgnRect = CreateRectRgn (pRects->x1, pRects->y1,
 
626
                                    pRects->x2, pRects->y2);
 
627
          if (hRgnRect == NULL)
 
628
            {
 
629
              ErrorF("winReshapeRootless - CreateRectRgn() failed\n");
 
630
            }
 
631
 
 
632
          /* Merge the Windows region with the accumulated region */
 
633
          if (CombineRgn (hRgn, hRgn, hRgnRect, RGN_OR) == ERROR)
 
634
            {
 
635
              ErrorF("winReshapeRootless - CombineRgn() failed\n");
 
636
            }
 
637
 
 
638
          /* Delete the temporary Windows region */
 
639
          DeleteObject (hRgnRect);
 
640
        }
 
641
      
 
642
      /* Save a handle to the composite region in the window privates */
 
643
      pWinPriv->hRgn = hRgn;
 
644
    }
 
645
 
 
646
  REGION_UNINIT(pScreen, &rrNewShape);
 
647
  
 
648
  return;
 
649
}
 
650
#endif