1706f2543Smrg/* 2706f2543Smrg *Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved. 3706f2543Smrg * 4706f2543Smrg *Permission is hereby granted, free of charge, to any person obtaining 5706f2543Smrg * a copy of this software and associated documentation files (the 6706f2543Smrg *"Software"), to deal in the Software without restriction, including 7706f2543Smrg *without limitation the rights to use, copy, modify, merge, publish, 8706f2543Smrg *distribute, sublicense, and/or sell copies of the Software, and to 9706f2543Smrg *permit persons to whom the Software is furnished to do so, subject to 10706f2543Smrg *the following conditions: 11706f2543Smrg * 12706f2543Smrg *The above copyright notice and this permission notice shall be 13706f2543Smrg *included in all copies or substantial portions of the Software. 14706f2543Smrg * 15706f2543Smrg *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16706f2543Smrg *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17706f2543Smrg *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18706f2543Smrg *NONINFRINGEMENT. IN NO EVENT SHALL THE XFREE86 PROJECT BE LIABLE FOR 19706f2543Smrg *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF 20706f2543Smrg *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 21706f2543Smrg *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22706f2543Smrg * 23706f2543Smrg *Except as contained in this notice, the name of the XFree86 Project 24706f2543Smrg *shall not be used in advertising or otherwise to promote the sale, use 25706f2543Smrg *or other dealings in this Software without prior written authorization 26706f2543Smrg *from the XFree86 Project. 27706f2543Smrg * 28706f2543Smrg * Authors: Harold L Hunt II 29706f2543Smrg * Kensuke Matsuzaki 30706f2543Smrg */ 31706f2543Smrg 32706f2543Smrg#ifdef HAVE_XWIN_CONFIG_H 33706f2543Smrg#include <xwin-config.h> 34706f2543Smrg#endif 35706f2543Smrg#include "win.h" 36706f2543Smrg 37706f2543Smrg 38706f2543Smrg/* 39706f2543Smrg * Prototypes for local functions 40706f2543Smrg */ 41706f2543Smrg 42706f2543Smrgstatic int 43706f2543SmrgwinAddRgn (WindowPtr pWindow, pointer data); 44706f2543Smrg 45706f2543Smrgstatic 46706f2543Smrgvoid 47706f2543SmrgwinUpdateRgnRootless (WindowPtr pWindow); 48706f2543Smrg 49706f2543Smrgstatic 50706f2543Smrgvoid 51706f2543SmrgwinReshapeRootless (WindowPtr pWin); 52706f2543Smrg 53706f2543Smrg 54706f2543Smrg#ifdef XWIN_NATIVEGDI 55706f2543Smrg/* See Porting Layer Definition - p. 37 */ 56706f2543Smrg/* See mfb/mfbwindow.c - mfbCreateWindow() */ 57706f2543Smrg 58706f2543SmrgBool 59706f2543SmrgwinCreateWindowNativeGDI (WindowPtr pWin) 60706f2543Smrg{ 61706f2543Smrg Bool fResult = TRUE; 62706f2543Smrg ScreenPtr pScreen = pWin->drawable.pScreen; 63706f2543Smrg winWindowPriv(pWin); 64706f2543Smrg winScreenPriv(pScreen); 65706f2543Smrg 66706f2543Smrg#if CYGDEBUG 67706f2543Smrg winTrace ("winCreateWindowNativeGDI (%p)\n", pWin); 68706f2543Smrg#endif 69706f2543Smrg 70706f2543Smrg WIN_UNWRAP(CreateWindow); 71706f2543Smrg fResult = (*pScreen->CreateWindow) (pWin); 72706f2543Smrg WIN_WRAP(CreateWindow, winCreateWindowNativeGDI); 73706f2543Smrg 74706f2543Smrg return fResult; 75706f2543Smrg} 76706f2543Smrg 77706f2543Smrg 78706f2543Smrg/* See Porting Layer Definition - p. 37 */ 79706f2543Smrg/* See mfb/mfbwindow.c - mfbDestroyWindow() */ 80706f2543Smrg 81706f2543SmrgBool 82706f2543SmrgwinDestroyWindowNativeGDI (WindowPtr pWin) 83706f2543Smrg{ 84706f2543Smrg Bool fResult = TRUE; 85706f2543Smrg ScreenPtr pScreen = pWin->drawable.pScreen; 86706f2543Smrg winWindowPriv(pWin); 87706f2543Smrg winScreenPriv(pScreen); 88706f2543Smrg 89706f2543Smrg#if CYGDEBUG 90706f2543Smrg winTrace ("winDestroyWindowNativeGDI (%p)\n", pWin); 91706f2543Smrg#endif 92706f2543Smrg 93706f2543Smrg WIN_UNWRAP(DestroyWindow); 94706f2543Smrg fResult = (*pScreen->DestroyWindow)(pWin); 95706f2543Smrg WIN_WRAP(DestroyWindow, winDestroyWindowNativeGDI); 96706f2543Smrg 97706f2543Smrg return fResult; 98706f2543Smrg} 99706f2543Smrg 100706f2543Smrg 101706f2543Smrg/* See Porting Layer Definition - p. 37 */ 102706f2543Smrg/* See mfb/mfbwindow.c - mfbPositionWindow() */ 103706f2543Smrg 104706f2543SmrgBool 105706f2543SmrgwinPositionWindowNativeGDI (WindowPtr pWin, int x, int y) 106706f2543Smrg{ 107706f2543Smrg Bool fResult = TRUE; 108706f2543Smrg ScreenPtr pScreen = pWin->drawable.pScreen; 109706f2543Smrg winWindowPriv(pWin); 110706f2543Smrg winScreenPriv(pScreen); 111706f2543Smrg 112706f2543Smrg#if CYGDEBUG 113706f2543Smrg winTrace ("winPositionWindowNativeGDI (%p)\n", pWin); 114706f2543Smrg#endif 115706f2543Smrg 116706f2543Smrg WIN_UNWRAP(PositionWindow); 117706f2543Smrg fResult = (*pScreen->PositionWindow)(pWin, x, y); 118706f2543Smrg WIN_WRAP(PositionWindow, winPositionWindowNativeGDI); 119706f2543Smrg 120706f2543Smrg return fResult; 121706f2543Smrg} 122706f2543Smrg 123706f2543Smrg 124706f2543Smrg/* See Porting Layer Definition - p. 39 */ 125706f2543Smrg/* See mfb/mfbwindow.c - mfbCopyWindow() */ 126706f2543Smrg 127706f2543Smrgvoid 128706f2543SmrgwinCopyWindowNativeGDI (WindowPtr pWin, 129706f2543Smrg DDXPointRec ptOldOrg, 130706f2543Smrg RegionPtr prgnSrc) 131706f2543Smrg{ 132706f2543Smrg DDXPointPtr pptSrc; 133706f2543Smrg DDXPointPtr ppt; 134706f2543Smrg RegionPtr prgnDst; 135706f2543Smrg BoxPtr pBox; 136706f2543Smrg int dx, dy; 137706f2543Smrg int i, nbox; 138706f2543Smrg WindowPtr pwinRoot; 139706f2543Smrg BoxPtr pBoxDst; 140706f2543Smrg ScreenPtr pScreen = pWin->drawable.pScreen; 141706f2543Smrg winScreenPriv(pScreen); 142706f2543Smrg 143706f2543Smrg#if 0 144706f2543Smrg ErrorF ("winCopyWindow\n"); 145706f2543Smrg#endif 146706f2543Smrg 147706f2543Smrg /* Get a pointer to the root window */ 148706f2543Smrg pwinRoot = pWin->drawable.pScreen->root; 149706f2543Smrg 150706f2543Smrg /* Create a region for the destination */ 151706f2543Smrg prgnDst = RegionCreate(NULL, 1); 152706f2543Smrg 153706f2543Smrg /* Calculate the shift from the source to the destination */ 154706f2543Smrg dx = ptOldOrg.x - pWin->drawable.x; 155706f2543Smrg dy = ptOldOrg.y - pWin->drawable.y; 156706f2543Smrg 157706f2543Smrg /* Translate the region from the destination to the source? */ 158706f2543Smrg RegionTranslate(prgnSrc, -dx, -dy); 159706f2543Smrg RegionIntersect(prgnDst, &pWin->borderClip, 160706f2543Smrg prgnSrc); 161706f2543Smrg 162706f2543Smrg /* Get a pointer to the first box in the region to be copied */ 163706f2543Smrg pBox = RegionRects(prgnDst); 164706f2543Smrg 165706f2543Smrg /* Get the number of boxes in the region */ 166706f2543Smrg nbox = RegionNumRects(prgnDst); 167706f2543Smrg 168706f2543Smrg /* Allocate source points for each box */ 169706f2543Smrg if(!(pptSrc = (DDXPointPtr )malloc(nbox * sizeof(DDXPointRec)))) 170706f2543Smrg return; 171706f2543Smrg 172706f2543Smrg /* Set an iterator pointer */ 173706f2543Smrg ppt = pptSrc; 174706f2543Smrg 175706f2543Smrg /* Calculate the source point of each box? */ 176706f2543Smrg for (i = nbox; --i >= 0; ppt++, pBox++) 177706f2543Smrg { 178706f2543Smrg ppt->x = pBox->x1 + dx; 179706f2543Smrg ppt->y = pBox->y1 + dy; 180706f2543Smrg } 181706f2543Smrg 182706f2543Smrg /* Setup loop pointers again */ 183706f2543Smrg pBoxDst = RegionRects(prgnDst); 184706f2543Smrg ppt = pptSrc; 185706f2543Smrg 186706f2543Smrg#if 0 187706f2543Smrg ErrorF ("winCopyWindow - x1\tx2\ty1\ty2\tx\ty\n"); 188706f2543Smrg#endif 189706f2543Smrg 190706f2543Smrg /* BitBlt each source to the destination point */ 191706f2543Smrg for (i = nbox; --i >= 0; pBoxDst++, ppt++) 192706f2543Smrg { 193706f2543Smrg#if 0 194706f2543Smrg ErrorF ("winCopyWindow - %d\t%d\t%d\t%d\t%d\t%d\n", 195706f2543Smrg pBoxDst->x1, pBoxDst->x2, pBoxDst->y1, pBoxDst->y2, 196706f2543Smrg ppt->x, ppt->y); 197706f2543Smrg#endif 198706f2543Smrg 199706f2543Smrg BitBlt (pScreenPriv->hdcScreen, 200706f2543Smrg pBoxDst->x1, pBoxDst->y1, 201706f2543Smrg pBoxDst->x2 - pBoxDst->x1, pBoxDst->y2 - pBoxDst->y1, 202706f2543Smrg pScreenPriv->hdcScreen, 203706f2543Smrg ppt->x, ppt->y, 204706f2543Smrg SRCCOPY); 205706f2543Smrg } 206706f2543Smrg 207706f2543Smrg /* Cleanup the regions, etc. */ 208706f2543Smrg free(pptSrc); 209706f2543Smrg RegionDestroy(prgnDst); 210706f2543Smrg} 211706f2543Smrg 212706f2543Smrg 213706f2543Smrg/* See Porting Layer Definition - p. 37 */ 214706f2543Smrg/* See mfb/mfbwindow.c - mfbChangeWindowAttributes() */ 215706f2543Smrg 216706f2543SmrgBool 217706f2543SmrgwinChangeWindowAttributesNativeGDI (WindowPtr pWin, unsigned long mask) 218706f2543Smrg{ 219706f2543Smrg Bool fResult = TRUE; 220706f2543Smrg ScreenPtr pScreen = pWin->drawable.pScreen; 221706f2543Smrg winWindowPriv(pWin); 222706f2543Smrg winScreenPriv(pScreen); 223706f2543Smrg 224706f2543Smrg#if CYGDEBUG 225706f2543Smrg winTrace ("winChangeWindowAttributesNativeGDI (%p)\n", pWin); 226706f2543Smrg#endif 227706f2543Smrg 228706f2543Smrg WIN_UNWRAP(ChangeWindowAttributes); 229706f2543Smrg fResult = (*pScreen->ChangeWindowAttributes)(pWin, mask); 230706f2543Smrg WIN_WRAP(ChangeWindowAttributes, winChangeWindowAttributesNativeGDI); 231706f2543Smrg 232706f2543Smrg /* 233706f2543Smrg * NOTE: We do not currently need to do anything here. 234706f2543Smrg */ 235706f2543Smrg 236706f2543Smrg return fResult; 237706f2543Smrg} 238706f2543Smrg 239706f2543Smrg 240706f2543Smrg/* See Porting Layer Definition - p. 37 241706f2543Smrg * Also referred to as UnrealizeWindow 242706f2543Smrg */ 243706f2543Smrg 244706f2543SmrgBool 245706f2543SmrgwinUnmapWindowNativeGDI (WindowPtr pWin) 246706f2543Smrg{ 247706f2543Smrg Bool fResult = TRUE; 248706f2543Smrg ScreenPtr pScreen = pWin->drawable.pScreen; 249706f2543Smrg winWindowPriv(pWin); 250706f2543Smrg winScreenPriv(pScreen); 251706f2543Smrg 252706f2543Smrg#if CYGDEBUG 253706f2543Smrg winTrace ("winUnmapWindowNativeGDI (%p)\n", pWin); 254706f2543Smrg#endif 255706f2543Smrg 256706f2543Smrg WIN_UNWRAP(UnrealizeWindow); 257706f2543Smrg fResult = (*pScreen->UnrealizeWindow)(pWin); 258706f2543Smrg WIN_WRAP(UnrealizeWindow, winUnmapWindowNativeGDI); 259706f2543Smrg 260706f2543Smrg return fResult; 261706f2543Smrg} 262706f2543Smrg 263706f2543Smrg 264706f2543Smrg/* See Porting Layer Definition - p. 37 265706f2543Smrg * Also referred to as RealizeWindow 266706f2543Smrg */ 267706f2543Smrg 268706f2543SmrgBool 269706f2543SmrgwinMapWindowNativeGDI (WindowPtr pWin) 270706f2543Smrg{ 271706f2543Smrg Bool fResult = TRUE; 272706f2543Smrg ScreenPtr pScreen = pWin->drawable.pScreen; 273706f2543Smrg winWindowPriv(pWin); 274706f2543Smrg winScreenPriv(pScreen); 275706f2543Smrg 276706f2543Smrg#if CYGDEBUG 277706f2543Smrg winTrace ("winMapWindowNativeGDI (%p)\n", pWin); 278706f2543Smrg#endif 279706f2543Smrg 280706f2543Smrg WIN_UNWRAP(RealizeWindow); 281706f2543Smrg fResult = (*pScreen->RealizeWindow)(pWin); 282706f2543Smrg WIN_WRAP(RealizeWindow, winMapWindowMultiWindow); 283706f2543Smrg 284706f2543Smrg return fResult; 285706f2543Smrg 286706f2543Smrg} 287706f2543Smrg#endif 288706f2543Smrg 289706f2543Smrg 290706f2543Smrg/* See Porting Layer Definition - p. 37 */ 291706f2543Smrg/* See mfb/mfbwindow.c - mfbCreateWindow() */ 292706f2543Smrg 293706f2543SmrgBool 294706f2543SmrgwinCreateWindowRootless (WindowPtr pWin) 295706f2543Smrg{ 296706f2543Smrg Bool fResult = FALSE; 297706f2543Smrg ScreenPtr pScreen = pWin->drawable.pScreen; 298706f2543Smrg winWindowPriv(pWin); 299706f2543Smrg winScreenPriv(pScreen); 300706f2543Smrg 301706f2543Smrg#if CYGDEBUG 302706f2543Smrg winTrace ("winCreateWindowRootless (%p)\n", pWin); 303706f2543Smrg#endif 304706f2543Smrg 305706f2543Smrg WIN_UNWRAP(CreateWindow); 306706f2543Smrg fResult = (*pScreen->CreateWindow) (pWin); 307706f2543Smrg WIN_WRAP(CreateWindow, winCreateWindowRootless); 308706f2543Smrg 309706f2543Smrg pWinPriv->hRgn = NULL; 310706f2543Smrg 311706f2543Smrg return fResult; 312706f2543Smrg} 313706f2543Smrg 314706f2543Smrg 315706f2543Smrg/* See Porting Layer Definition - p. 37 */ 316706f2543Smrg/* See mfb/mfbwindow.c - mfbDestroyWindow() */ 317706f2543Smrg 318706f2543SmrgBool 319706f2543SmrgwinDestroyWindowRootless (WindowPtr pWin) 320706f2543Smrg{ 321706f2543Smrg Bool fResult = FALSE; 322706f2543Smrg ScreenPtr pScreen = pWin->drawable.pScreen; 323706f2543Smrg winWindowPriv(pWin); 324706f2543Smrg winScreenPriv(pScreen); 325706f2543Smrg 326706f2543Smrg#if CYGDEBUG 327706f2543Smrg winTrace ("winDestroyWindowRootless (%p)\n", pWin); 328706f2543Smrg#endif 329706f2543Smrg 330706f2543Smrg WIN_UNWRAP(DestroyWindow); 331706f2543Smrg fResult = (*pScreen->DestroyWindow)(pWin); 332706f2543Smrg WIN_WRAP(DestroyWindow, winDestroyWindowRootless); 333706f2543Smrg 334706f2543Smrg if (pWinPriv->hRgn != NULL) 335706f2543Smrg { 336706f2543Smrg DeleteObject(pWinPriv->hRgn); 337706f2543Smrg pWinPriv->hRgn = NULL; 338706f2543Smrg } 339706f2543Smrg 340706f2543Smrg winUpdateRgnRootless (pWin); 341706f2543Smrg 342706f2543Smrg return fResult; 343706f2543Smrg} 344706f2543Smrg 345706f2543Smrg 346706f2543Smrg/* See Porting Layer Definition - p. 37 */ 347706f2543Smrg/* See mfb/mfbwindow.c - mfbPositionWindow() */ 348706f2543Smrg 349706f2543SmrgBool 350706f2543SmrgwinPositionWindowRootless (WindowPtr pWin, int x, int y) 351706f2543Smrg{ 352706f2543Smrg Bool fResult = FALSE; 353706f2543Smrg ScreenPtr pScreen = pWin->drawable.pScreen; 354706f2543Smrg winScreenPriv(pScreen); 355706f2543Smrg 356706f2543Smrg 357706f2543Smrg#if CYGDEBUG 358706f2543Smrg winTrace ("winPositionWindowRootless (%p)\n", pWin); 359706f2543Smrg#endif 360706f2543Smrg 361706f2543Smrg WIN_UNWRAP(PositionWindow); 362706f2543Smrg fResult = (*pScreen->PositionWindow)(pWin, x, y); 363706f2543Smrg WIN_WRAP(PositionWindow, winPositionWindowRootless); 364706f2543Smrg 365706f2543Smrg winUpdateRgnRootless (pWin); 366706f2543Smrg 367706f2543Smrg return fResult; 368706f2543Smrg} 369706f2543Smrg 370706f2543Smrg 371706f2543Smrg/* See Porting Layer Definition - p. 37 */ 372706f2543Smrg/* See mfb/mfbwindow.c - mfbChangeWindowAttributes() */ 373706f2543Smrg 374706f2543SmrgBool 375706f2543SmrgwinChangeWindowAttributesRootless (WindowPtr pWin, unsigned long mask) 376706f2543Smrg{ 377706f2543Smrg Bool fResult = FALSE; 378706f2543Smrg ScreenPtr pScreen = pWin->drawable.pScreen; 379706f2543Smrg winScreenPriv(pScreen); 380706f2543Smrg 381706f2543Smrg#if CYGDEBUG 382706f2543Smrg winTrace ("winChangeWindowAttributesRootless (%p)\n", pWin); 383706f2543Smrg#endif 384706f2543Smrg 385706f2543Smrg WIN_UNWRAP(ChangeWindowAttributes); 386706f2543Smrg fResult = (*pScreen->ChangeWindowAttributes)(pWin, mask); 387706f2543Smrg WIN_WRAP(ChangeWindowAttributes, winChangeWindowAttributesRootless); 388706f2543Smrg 389706f2543Smrg winUpdateRgnRootless (pWin); 390706f2543Smrg 391706f2543Smrg return fResult; 392706f2543Smrg} 393706f2543Smrg 394706f2543Smrg 395706f2543Smrg/* See Porting Layer Definition - p. 37 396706f2543Smrg * Also referred to as UnrealizeWindow 397706f2543Smrg */ 398706f2543Smrg 399706f2543SmrgBool 400706f2543SmrgwinUnmapWindowRootless (WindowPtr pWin) 401706f2543Smrg{ 402706f2543Smrg Bool fResult = FALSE; 403706f2543Smrg ScreenPtr pScreen = pWin->drawable.pScreen; 404706f2543Smrg winWindowPriv(pWin); 405706f2543Smrg winScreenPriv(pScreen); 406706f2543Smrg 407706f2543Smrg#if CYGDEBUG 408706f2543Smrg winTrace ("winUnmapWindowRootless (%p)\n", pWin); 409706f2543Smrg#endif 410706f2543Smrg 411706f2543Smrg WIN_UNWRAP(UnrealizeWindow); 412706f2543Smrg fResult = (*pScreen->UnrealizeWindow)(pWin); 413706f2543Smrg WIN_WRAP(UnrealizeWindow, winUnmapWindowRootless); 414706f2543Smrg 415706f2543Smrg if (pWinPriv->hRgn != NULL) 416706f2543Smrg { 417706f2543Smrg DeleteObject(pWinPriv->hRgn); 418706f2543Smrg pWinPriv->hRgn = NULL; 419706f2543Smrg } 420706f2543Smrg 421706f2543Smrg winUpdateRgnRootless (pWin); 422706f2543Smrg 423706f2543Smrg return fResult; 424706f2543Smrg} 425706f2543Smrg 426706f2543Smrg 427706f2543Smrg/* See Porting Layer Definition - p. 37 428706f2543Smrg * Also referred to as RealizeWindow 429706f2543Smrg */ 430706f2543Smrg 431706f2543SmrgBool 432706f2543SmrgwinMapWindowRootless (WindowPtr pWin) 433706f2543Smrg{ 434706f2543Smrg Bool fResult = FALSE; 435706f2543Smrg ScreenPtr pScreen = pWin->drawable.pScreen; 436706f2543Smrg winScreenPriv(pScreen); 437706f2543Smrg 438706f2543Smrg#if CYGDEBUG 439706f2543Smrg winTrace ("winMapWindowRootless (%p)\n", pWin); 440706f2543Smrg#endif 441706f2543Smrg 442706f2543Smrg WIN_UNWRAP(RealizeWindow); 443706f2543Smrg fResult = (*pScreen->RealizeWindow)(pWin); 444706f2543Smrg WIN_WRAP(RealizeWindow, winMapWindowRootless); 445706f2543Smrg 446706f2543Smrg winReshapeRootless (pWin); 447706f2543Smrg 448706f2543Smrg winUpdateRgnRootless (pWin); 449706f2543Smrg 450706f2543Smrg return fResult; 451706f2543Smrg} 452706f2543Smrg 453706f2543Smrg 454706f2543Smrgvoid 455706f2543SmrgwinSetShapeRootless (WindowPtr pWin, int kind) 456706f2543Smrg{ 457706f2543Smrg ScreenPtr pScreen = pWin->drawable.pScreen; 458706f2543Smrg winScreenPriv(pScreen); 459706f2543Smrg 460706f2543Smrg#if CYGDEBUG 461706f2543Smrg winTrace ("winSetShapeRootless (%p, %i)\n", pWin, kind); 462706f2543Smrg#endif 463706f2543Smrg 464706f2543Smrg WIN_UNWRAP(SetShape); 465706f2543Smrg (*pScreen->SetShape)(pWin, kind); 466706f2543Smrg WIN_WRAP(SetShape, winSetShapeRootless); 467706f2543Smrg 468706f2543Smrg winReshapeRootless (pWin); 469706f2543Smrg winUpdateRgnRootless (pWin); 470706f2543Smrg 471706f2543Smrg return; 472706f2543Smrg} 473706f2543Smrg 474706f2543Smrg 475706f2543Smrg/* 476706f2543Smrg * Local function for adding a region to the Windows window region 477706f2543Smrg */ 478706f2543Smrg 479706f2543Smrgstatic 480706f2543Smrgint 481706f2543SmrgwinAddRgn (WindowPtr pWin, pointer data) 482706f2543Smrg{ 483706f2543Smrg int iX, iY, iWidth, iHeight, iBorder; 484706f2543Smrg HRGN hRgn = *(HRGN*)data; 485706f2543Smrg HRGN hRgnWin; 486706f2543Smrg winWindowPriv(pWin); 487706f2543Smrg 488706f2543Smrg /* If pWin is not Root */ 489706f2543Smrg if (pWin->parent != NULL) 490706f2543Smrg { 491706f2543Smrg#if CYGDEBUG 492706f2543Smrg winDebug ("winAddRgn ()\n"); 493706f2543Smrg#endif 494706f2543Smrg if (pWin->mapped) 495706f2543Smrg { 496706f2543Smrg iBorder = wBorderWidth (pWin); 497706f2543Smrg 498706f2543Smrg iX = pWin->drawable.x - iBorder; 499706f2543Smrg iY = pWin->drawable.y - iBorder; 500706f2543Smrg 501706f2543Smrg iWidth = pWin->drawable.width + iBorder * 2; 502706f2543Smrg iHeight = pWin->drawable.height + iBorder * 2; 503706f2543Smrg 504706f2543Smrg hRgnWin = CreateRectRgn (0, 0, iWidth, iHeight); 505706f2543Smrg 506706f2543Smrg if (hRgnWin == NULL) 507706f2543Smrg { 508706f2543Smrg ErrorF ("winAddRgn - CreateRectRgn () failed\n"); 509706f2543Smrg ErrorF (" Rect %d %d %d %d\n", 510706f2543Smrg iX, iY, iX + iWidth, iY + iHeight); 511706f2543Smrg } 512706f2543Smrg 513706f2543Smrg if (pWinPriv->hRgn) 514706f2543Smrg { 515706f2543Smrg if (CombineRgn (hRgnWin, hRgnWin, pWinPriv->hRgn, RGN_AND) 516706f2543Smrg == ERROR) 517706f2543Smrg { 518706f2543Smrg ErrorF ("winAddRgn - CombineRgn () failed\n"); 519706f2543Smrg } 520706f2543Smrg } 521706f2543Smrg 522706f2543Smrg OffsetRgn (hRgnWin, iX, iY); 523706f2543Smrg 524706f2543Smrg if (CombineRgn (hRgn, hRgn, hRgnWin, RGN_OR) == ERROR) 525706f2543Smrg { 526706f2543Smrg ErrorF ("winAddRgn - CombineRgn () failed\n"); 527706f2543Smrg } 528706f2543Smrg 529706f2543Smrg DeleteObject (hRgnWin); 530706f2543Smrg } 531706f2543Smrg return WT_DONTWALKCHILDREN; 532706f2543Smrg } 533706f2543Smrg else 534706f2543Smrg { 535706f2543Smrg return WT_WALKCHILDREN; 536706f2543Smrg } 537706f2543Smrg} 538706f2543Smrg 539706f2543Smrg 540706f2543Smrg/* 541706f2543Smrg * Local function to update the Windows window's region 542706f2543Smrg */ 543706f2543Smrg 544706f2543Smrgstatic 545706f2543Smrgvoid 546706f2543SmrgwinUpdateRgnRootless (WindowPtr pWin) 547706f2543Smrg{ 548706f2543Smrg HRGN hRgn = CreateRectRgn (0, 0, 0, 0); 549706f2543Smrg 550706f2543Smrg if (hRgn != NULL) 551706f2543Smrg { 552706f2543Smrg WalkTree (pWin->drawable.pScreen, winAddRgn, &hRgn); 553706f2543Smrg SetWindowRgn (winGetScreenPriv(pWin->drawable.pScreen)->hwndScreen, 554706f2543Smrg hRgn, TRUE); 555706f2543Smrg } 556706f2543Smrg else 557706f2543Smrg { 558706f2543Smrg ErrorF ("winUpdateRgnRootless - CreateRectRgn failed.\n"); 559706f2543Smrg } 560706f2543Smrg} 561706f2543Smrg 562706f2543Smrg 563706f2543Smrgstatic 564706f2543Smrgvoid 565706f2543SmrgwinReshapeRootless (WindowPtr pWin) 566706f2543Smrg{ 567706f2543Smrg int nRects; 568706f2543Smrg RegionRec rrNewShape; 569706f2543Smrg BoxPtr pShape, pRects, pEnd; 570706f2543Smrg HRGN hRgn, hRgnRect; 571706f2543Smrg winWindowPriv(pWin); 572706f2543Smrg 573706f2543Smrg#if CYGDEBUG 574706f2543Smrg winDebug ("winReshapeRootless ()\n"); 575706f2543Smrg#endif 576706f2543Smrg 577706f2543Smrg /* Bail if the window is the root window */ 578706f2543Smrg if (pWin->parent == NULL) 579706f2543Smrg return; 580706f2543Smrg 581706f2543Smrg /* Bail if the window is not top level */ 582706f2543Smrg if (pWin->parent->parent != NULL) 583706f2543Smrg return; 584706f2543Smrg 585706f2543Smrg /* Free any existing window region stored in the window privates */ 586706f2543Smrg if (pWinPriv->hRgn != NULL) 587706f2543Smrg { 588706f2543Smrg DeleteObject (pWinPriv->hRgn); 589706f2543Smrg pWinPriv->hRgn = NULL; 590706f2543Smrg } 591706f2543Smrg 592706f2543Smrg /* Bail if the window has no bounding region defined */ 593706f2543Smrg if (!wBoundingShape (pWin)) 594706f2543Smrg return; 595706f2543Smrg 596706f2543Smrg RegionNull(&rrNewShape); 597706f2543Smrg RegionCopy(&rrNewShape, wBoundingShape(pWin)); 598706f2543Smrg RegionTranslate(&rrNewShape, pWin->borderWidth, 599706f2543Smrg pWin->borderWidth); 600706f2543Smrg 601706f2543Smrg nRects = RegionNumRects(&rrNewShape); 602706f2543Smrg pShape = RegionRects(&rrNewShape); 603706f2543Smrg 604706f2543Smrg if (nRects > 0) 605706f2543Smrg { 606706f2543Smrg /* Create initial empty Windows region */ 607706f2543Smrg hRgn = CreateRectRgn (0, 0, 0, 0); 608706f2543Smrg 609706f2543Smrg /* Loop through all rectangles in the X region */ 610706f2543Smrg for (pRects = pShape, pEnd = pShape + nRects; pRects < pEnd; pRects++) 611706f2543Smrg { 612706f2543Smrg /* Create a Windows region for the X rectangle */ 613706f2543Smrg hRgnRect = CreateRectRgn (pRects->x1, pRects->y1, 614706f2543Smrg pRects->x2, pRects->y2); 615706f2543Smrg if (hRgnRect == NULL) 616706f2543Smrg { 617706f2543Smrg ErrorF("winReshapeRootless - CreateRectRgn() failed\n"); 618706f2543Smrg } 619706f2543Smrg 620706f2543Smrg /* Merge the Windows region with the accumulated region */ 621706f2543Smrg if (CombineRgn (hRgn, hRgn, hRgnRect, RGN_OR) == ERROR) 622706f2543Smrg { 623706f2543Smrg ErrorF("winReshapeRootless - CombineRgn() failed\n"); 624706f2543Smrg } 625706f2543Smrg 626706f2543Smrg /* Delete the temporary Windows region */ 627706f2543Smrg DeleteObject (hRgnRect); 628706f2543Smrg } 629706f2543Smrg 630706f2543Smrg /* Save a handle to the composite region in the window privates */ 631706f2543Smrg pWinPriv->hRgn = hRgn; 632706f2543Smrg } 633706f2543Smrg 634706f2543Smrg RegionUninit(&rrNewShape); 635706f2543Smrg 636706f2543Smrg return; 637706f2543Smrg} 638