2
*Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved.
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:
12
*The above copyright notice and this permission notice shall be
13
*included in all copies or substantial portions of the Software.
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.
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.
28
* Authors: Harold L Hunt II
31
/* $XFree86: xc/programs/Xserver/hw/xwin/winwindow.c,v 1.6 2003/02/12 15:01:38 alanh Exp $ */
36
* Prototypes for local functions
40
winAddRgn (WindowPtr pWindow, pointer data);
44
winUpdateRgn (WindowPtr pWindow);
49
winReshape (WindowPtr pWin);
53
/* See Porting Layer Definition - p. 37 */
54
/* See mfb/mfbwindow.c - mfbCreateWindow() */
57
winCreateWindowNativeGDI (WindowPtr pWin)
59
ErrorF ("winCreateWindowNativeGDI ()\n");
64
/* See Porting Layer Definition - p. 37 */
65
/* See mfb/mfbwindow.c - mfbDestroyWindow() */
68
winDestroyWindowNativeGDI (WindowPtr pWin)
70
ErrorF ("winDestroyWindowNativeGDI ()\n");
75
/* See Porting Layer Definition - p. 37 */
76
/* See mfb/mfbwindow.c - mfbPositionWindow() */
79
winPositionWindowNativeGDI (WindowPtr pWin, int x, int y)
81
ErrorF ("winPositionWindowNativeGDI ()\n");
86
/* See Porting Layer Definition - p. 39 */
87
/* See mfb/mfbwindow.c - mfbCopyWindow() */
90
winCopyWindowNativeGDI (WindowPtr pWin,
94
ErrorF ("winCopyWindowNativeGDI ()\n");
98
/* See Porting Layer Definition - p. 37 */
99
/* See mfb/mfbwindow.c - mfbChangeWindowAttributes() */
102
winChangeWindowAttributesNativeGDI (WindowPtr pWin, unsigned long mask)
104
ErrorF ("winChangeWindowAttributesNativeGDI ()\n");
109
/* See Porting Layer Definition - p. 37
110
* Also referred to as UnrealizeWindow
114
winUnmapWindowNativeGDI (WindowPtr pWindow)
116
ErrorF ("winUnmapWindowNativeGDI ()\n");
117
/* This functions is empty in the CFB,
118
* we probably won't need to do anything
124
/* See Porting Layer Definition - p. 37
125
* Also referred to as RealizeWindow
129
winMapWindowNativeGDI (WindowPtr pWindow)
131
ErrorF ("winMapWindowNativeGDI ()\n");
132
/* This function is empty in the CFB,
133
* we probably won't need to do anything
140
/* See Porting Layer Definition - p. 37 */
141
/* See mfb/mfbwindow.c - mfbCreateWindow() */
144
winCreateWindowPRootless (WindowPtr pWin)
146
Bool fResult = FALSE;
150
ErrorF ("winCreateWindowPRootless ()\n");
153
fResult = winGetScreenPriv(pWin->drawable.pScreen)->CreateWindow(pWin);
155
pWinPriv->hRgn = NULL;
156
/*winUpdateRgn (pWin);*/
162
/* See Porting Layer Definition - p. 37 */
163
/* See mfb/mfbwindow.c - mfbDestroyWindow() */
166
winDestroyWindowPRootless (WindowPtr pWin)
168
Bool fResult = FALSE;
172
ErrorF ("winDestroyWindowPRootless ()\n");
175
fResult = winGetScreenPriv(pWin->drawable.pScreen)->DestroyWindow(pWin);
177
if (pWinPriv->hRgn != NULL)
179
DeleteObject(pWinPriv->hRgn);
180
pWinPriv->hRgn = NULL;
189
/* See Porting Layer Definition - p. 37 */
190
/* See mfb/mfbwindow.c - mfbPositionWindow() */
193
winPositionWindowPRootless (WindowPtr pWin, int x, int y)
195
Bool fResult = FALSE;
198
ErrorF ("winPositionWindowPRootless ()\n");
201
fResult = winGetScreenPriv(pWin->drawable.pScreen)->PositionWindow(pWin, x, y);
209
/* See Porting Layer Definition - p. 37 */
210
/* See mfb/mfbwindow.c - mfbChangeWindowAttributes() */
213
winChangeWindowAttributesPRootless (WindowPtr pWin, unsigned long mask)
215
Bool fResult = FALSE;
218
ErrorF ("winChangeWindowAttributesPRootless ()\n");
221
fResult = winGetScreenPriv(pWin->drawable.pScreen)->ChangeWindowAttributes(pWin, mask);
229
/* See Porting Layer Definition - p. 37
230
* Also referred to as UnrealizeWindow
234
winUnmapWindowPRootless (WindowPtr pWin)
236
Bool fResult = FALSE;
240
ErrorF ("winUnmapWindowPRootless ()\n");
243
fResult = winGetScreenPriv(pWin->drawable.pScreen)->UnrealizeWindow(pWin);
245
if (pWinPriv->hRgn != NULL)
247
DeleteObject(pWinPriv->hRgn);
248
pWinPriv->hRgn = NULL;
257
/* See Porting Layer Definition - p. 37
258
* Also referred to as RealizeWindow
262
winMapWindowPRootless (WindowPtr pWin)
264
Bool fResult = FALSE;
267
ErrorF ("winMapWindowPRootless ()\n");
270
fResult = winGetScreenPriv(pWin->drawable.pScreen)->RealizeWindow(pWin);
282
winSetShapePRootless (WindowPtr pWin)
285
ErrorF ("winSetShapePRootless ()\n");
288
winGetScreenPriv(pWin->drawable.pScreen)->SetShape(pWin);
299
* Local function for adding a region to the Windows window region
304
winAddRgn (WindowPtr pWin, pointer data)
306
int iX, iY, iWidth, iHeight, iBorder;
307
HRGN hRgn = *(HRGN*)data;
311
/* If pWin is not Root */
312
if (pWin->parent != NULL)
315
ErrorF ("winAddRgn ()\n");
319
iBorder = wBorderWidth (pWin);
321
iX = pWin->drawable.x - iBorder;
322
iY = pWin->drawable.y - iBorder;
324
iWidth = pWin->drawable.width + iBorder * 2;
325
iHeight = pWin->drawable.height + iBorder * 2;
327
hRgnWin = CreateRectRgn (0, 0, iWidth, iHeight);
331
ErrorF ("winAddRgn - CreateRectRgn () failed\n");
332
ErrorF (" Rect %d %d %d %d\n",
333
iX, iY, iX + iWidth, iY + iHeight);
338
if (CombineRgn (hRgnWin, hRgnWin, pWinPriv->hRgn, RGN_AND)
341
ErrorF ("winAddRgn - CombineRgn () failed\n");
345
OffsetRgn (hRgnWin, iX, iY);
347
if (CombineRgn (hRgn, hRgn, hRgnWin, RGN_OR) == ERROR)
349
ErrorF ("winAddRgn - CombineRgn () failed\n");
352
DeleteObject (hRgnWin);
354
return WT_DONTWALKCHILDREN;
358
return WT_WALKCHILDREN;
364
* Local function to update the Windows window's region
369
winUpdateRgn (WindowPtr pWin)
371
HRGN hRgn = CreateRectRgn (0, 0, 0, 0);
375
WalkTree (pWin->drawable.pScreen, winAddRgn, &hRgn);
376
SetWindowRgn (winGetScreenPriv(pWin->drawable.pScreen)->hwndScreen,
381
ErrorF ("winUpdateRgn - CreateRectRgn failed.\n");
389
winReshape (WindowPtr pWin)
392
ScreenPtr pScreen = pWin->drawable.pScreen;
393
RegionRec rrNewShape;
394
BoxPtr pShape, pRects, pEnd;
399
ErrorF ("winReshape ()\n");
402
/* Bail if the window is the root window */
403
if (pWin->parent == NULL)
406
/* Bail if the window is not top level */
407
if (pWin->parent->parent != NULL)
410
/* Free any existing window region stored in the window privates */
411
if (pWinPriv->hRgn != NULL)
413
DeleteObject (pWinPriv->hRgn);
414
pWinPriv->hRgn = NULL;
417
/* Bail if the window has no bounding region defined */
418
if (!wBoundingShape (pWin))
421
REGION_INIT(pScreen, &rrNewShape, NullBox, 0);
422
REGION_COPY(pScreen, &rrNewShape, wBoundingShape(pWin));
423
REGION_TRANSLATE(pScreen, &rrNewShape, pWin->borderWidth,
426
nRects = REGION_NUM_RECTS(&rrNewShape);
427
pShape = REGION_RECTS(&rrNewShape);
431
/* Create initial empty Windows region */
432
hRgn = CreateRectRgn (0, 0, 0, 0);
434
/* Loop through all rectangles in the X region */
435
for (pRects = pShape, pEnd = pShape + nRects; pRects < pEnd; pRects++)
437
/* Create a Windows region for the X rectangle */
438
hRgnRect = CreateRectRgn (pRects->x1, pRects->y1,
439
pRects->x2, pRects->y2);
440
if (hRgnRect == NULL)
442
ErrorF("winReshape - CreateRectRgn() failed\n");
445
/* Merge the Windows region with the accumulated region */
446
if (CombineRgn (hRgn, hRgn, hRgnRect, RGN_OR) == ERROR)
448
ErrorF("winReshape - CombineRgn() failed\n");
451
/* Delete the temporary Windows region */
452
DeleteObject (hRgnRect);
455
/* Save a handle to the composite region in the window privates */
456
pWinPriv->hRgn = hRgn;
459
REGION_UNINIT(pScreen, &rrNewShape);