winscrinit.c revision 05b261ec
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: Dakshinamurthy Karra 29 * Suhaib M Siddiqi 30 * Peter Busch 31 * Harold L Hunt II 32 * Kensuke Matsuzaki 33 */ 34 35#ifdef HAVE_XWIN_CONFIG_H 36#include <xwin-config.h> 37#endif 38#include "win.h" 39#include "winmsg.h" 40#include "safeAlpha.h" 41 42 43#ifdef XWIN_MULTIWINDOWEXTWM 44static RootlessFrameProcsRec 45winMWExtWMProcs = { 46 winMWExtWMCreateFrame, 47 winMWExtWMDestroyFrame, 48 49 winMWExtWMMoveFrame, 50 winMWExtWMResizeFrame, 51 winMWExtWMRestackFrame, 52 winMWExtWMReshapeFrame, 53 winMWExtWMUnmapFrame, 54 55 winMWExtWMStartDrawing, 56 winMWExtWMStopDrawing, 57 winMWExtWMUpdateRegion, 58#ifndef ROOTLESS_TRACK_DAMAGE 59 winMWExtWMDamageRects, 60#endif 61 winMWExtWMRootlessSwitchWindow, 62 NULL,//winWMExtWMDoReorderWindow, 63 64 NULL,//winMWExtWMCopyBytes, 65 NULL,//winMWExtWMFillBytes, 66 NULL,//winMWExtWMCompositePixels, 67 winMWExtWMCopyWindow 68}; 69#endif 70 71 72/* 73 * References to external symbols 74 */ 75 76extern winScreenInfo g_ScreenInfo[]; 77extern miPointerScreenFuncRec g_winPointerCursorFuncs; 78extern int g_iScreenPrivateIndex; 79extern Bool g_fSoftwareCursor; 80 81 82/* 83 * Prototypes 84 */ 85 86Bool 87winRandRInit (ScreenPtr pScreen); 88 89 90/* 91 * Local functions 92 */ 93 94static Bool 95winSaveScreen (ScreenPtr pScreen, int on); 96 97 98/* 99 * Determine what type of screen we are initializing 100 * and call the appropriate procedure to intiailize 101 * that type of screen. 102 */ 103 104Bool 105winScreenInit (int index, 106 ScreenPtr pScreen, 107 int argc, char **argv) 108{ 109 winScreenInfoPtr pScreenInfo = &g_ScreenInfo[index]; 110 winPrivScreenPtr pScreenPriv; 111 HDC hdc; 112 113#if CYGDEBUG || YES 114 winDebug ("winScreenInit - dwWidth: %ld dwHeight: %ld\n", 115 pScreenInfo->dwWidth, pScreenInfo->dwHeight); 116#endif 117 118 /* Allocate privates for this screen */ 119 if (!winAllocatePrivates (pScreen)) 120 { 121 ErrorF ("winScreenInit - Couldn't allocate screen privates\n"); 122 return FALSE; 123 } 124 125 /* Get a pointer to the privates structure that was allocated */ 126 pScreenPriv = winGetScreenPriv (pScreen); 127 128 /* Save a pointer to this screen in the screen info structure */ 129 pScreenInfo->pScreen = pScreen; 130 131 /* Save a pointer to the screen info in the screen privates structure */ 132 /* This allows us to get back to the screen info from a screen pointer */ 133 pScreenPriv->pScreenInfo = pScreenInfo; 134 135 /* 136 * Determine which engine to use. 137 * 138 * NOTE: This is done once per screen because each screen possibly has 139 * a preferred engine specified on the command line. 140 */ 141 if (!winSetEngine (pScreen)) 142 { 143 ErrorF ("winScreenInit - winSetEngine () failed\n"); 144 return FALSE; 145 } 146 147 /* Adjust the video mode for our engine type */ 148 if (!(*pScreenPriv->pwinAdjustVideoMode) (pScreen)) 149 { 150 ErrorF ("winScreenInit - winAdjustVideoMode () failed\n"); 151 return FALSE; 152 } 153 154 /* Check for supported display depth */ 155 if (!(WIN_SUPPORTED_BPPS & (1 << (pScreenInfo->dwBPP - 1)))) 156 { 157 ErrorF ("winScreenInit - Unsupported display depth: %d\n" \ 158 "Change your Windows display depth to 15, 16, 24, or 32 bits " 159 "per pixel.\n", 160 (int) pScreenInfo->dwBPP); 161 ErrorF ("winScreenInit - Supported depths: %08x\n", 162 WIN_SUPPORTED_BPPS); 163#if WIN_CHECK_DEPTH 164 return FALSE; 165#endif 166 } 167 168 /* 169 * Check that all monitors have the same display depth if we are using 170 * multiple monitors 171 */ 172 if (pScreenInfo->fMultipleMonitors 173 && !GetSystemMetrics (SM_SAMEDISPLAYFORMAT)) 174 { 175 ErrorF ("winScreenInit - Monitors do not all have same pixel format / " 176 "display depth.\n" 177 "Using primary display only.\n"); 178 pScreenInfo->fMultipleMonitors = FALSE; 179 } 180 181 /* Create display window */ 182 if (!(*pScreenPriv->pwinCreateBoundingWindow) (pScreen)) 183 { 184 ErrorF ("winScreenInit - pwinCreateBoundingWindow () " 185 "failed\n"); 186 return FALSE; 187 } 188 189 /* Get a device context */ 190 hdc = GetDC (pScreenPriv->hwndScreen); 191 192 /* Store the initial height, width, and depth of the display */ 193 /* Are we using multiple monitors? */ 194 if (pScreenInfo->fMultipleMonitors) 195 { 196 pScreenPriv->dwLastWindowsWidth = GetSystemMetrics (SM_CXVIRTUALSCREEN); 197 pScreenPriv->dwLastWindowsHeight = GetSystemMetrics (SM_CYVIRTUALSCREEN); 198 199 /* 200 * In this case, some of the defaults set in 201 * winInitializeDefaultScreens () are not correct ... 202 */ 203 if (!pScreenInfo->fUserGaveHeightAndWidth) 204 { 205 pScreenInfo->dwWidth = GetSystemMetrics (SM_CXVIRTUALSCREEN); 206 pScreenInfo->dwHeight = GetSystemMetrics (SM_CYVIRTUALSCREEN); 207 pScreenInfo->dwWidth_mm = (pScreenInfo->dwWidth / 208 WIN_DEFAULT_DPI) * 25.4; 209 pScreenInfo->dwHeight_mm = (pScreenInfo->dwHeight / 210 WIN_DEFAULT_DPI) * 25.4; 211 } 212 } 213 else 214 { 215 pScreenPriv->dwLastWindowsWidth = GetSystemMetrics (SM_CXSCREEN); 216 pScreenPriv->dwLastWindowsHeight = GetSystemMetrics (SM_CYSCREEN); 217 } 218 219 /* Save the original bits per pixel */ 220 pScreenPriv->dwLastWindowsBitsPixel = GetDeviceCaps (hdc, BITSPIXEL); 221 222 /* Release the device context */ 223 ReleaseDC (pScreenPriv->hwndScreen, hdc); 224 225 /* Clear the visuals list */ 226 miClearVisualTypes (); 227 228 /* Set the padded screen width */ 229 pScreenInfo->dwPaddedWidth = PixmapBytePad (pScreenInfo->dwWidth, 230 pScreenInfo->dwBPP); 231 232 /* Call the engine dependent screen initialization procedure */ 233 if (!((*pScreenPriv->pwinFinishScreenInit) (index, pScreen, argc, argv))) 234 { 235 ErrorF ("winScreenInit - winFinishScreenInit () failed\n"); 236 return FALSE; 237 } 238 239 if (!g_fSoftwareCursor) 240 winInitCursor(pScreen); 241 else 242 winErrorFVerb(2, "winScreenInit - Using software cursor\n"); 243 244#if CYGDEBUG || YES 245 winDebug ("winScreenInit - returning\n"); 246#endif 247 248 return TRUE; 249} 250 251 252/* See Porting Layer Definition - p. 20 */ 253Bool 254winFinishScreenInitFB (int index, 255 ScreenPtr pScreen, 256 int argc, char **argv) 257{ 258 winScreenPriv(pScreen); 259 winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo; 260 VisualPtr pVisual = NULL; 261 char *pbits = NULL; 262#if defined(XWIN_CLIPBOARD) || defined(XWIN_MULTIWINDOW) 263 int iReturn; 264#endif 265 266 /* Create framebuffer */ 267 if (!(*pScreenPriv->pwinAllocateFB) (pScreen)) 268 { 269 ErrorF ("winFinishScreenInitFB - Could not allocate framebuffer\n"); 270 return FALSE; 271 } 272 273 /* 274 * Grab the number of bits that are used to represent color in each pixel. 275 */ 276 if (pScreenInfo->dwBPP == 8) 277 pScreenInfo->dwDepth = 8; 278 else 279 pScreenInfo->dwDepth = winCountBits (pScreenPriv->dwRedMask) 280 + winCountBits (pScreenPriv->dwGreenMask) 281 + winCountBits (pScreenPriv->dwBlueMask); 282 283 winErrorFVerb (2, "winFinishScreenInitFB - Masks: %08x %08x %08x\n", 284 (unsigned int) pScreenPriv->dwRedMask, 285 (unsigned int) pScreenPriv->dwGreenMask, 286 (unsigned int) pScreenPriv->dwBlueMask); 287 288 /* Init visuals */ 289 if (!(*pScreenPriv->pwinInitVisuals) (pScreen)) 290 { 291 ErrorF ("winFinishScreenInitFB - winInitVisuals failed\n"); 292 return FALSE; 293 } 294 295 /* Setup a local variable to point to the framebuffer */ 296 pbits = pScreenInfo->pfb; 297 298 /* Apparently we need this for the render extension */ 299 miSetPixmapDepths (); 300 301 /* Start fb initialization */ 302 if (!fbSetupScreen (pScreen, 303 pScreenInfo->pfb, 304 pScreenInfo->dwWidth, pScreenInfo->dwHeight, 305 monitorResolution, monitorResolution, 306 pScreenInfo->dwStride, 307 pScreenInfo->dwBPP)) 308 { 309 ErrorF ("winFinishScreenInitFB - fbSetupScreen failed\n"); 310 return FALSE; 311 } 312 313 /* Override default colormap routines if visual class is dynamic */ 314 if (pScreenInfo->dwDepth == 8 315 && (pScreenInfo->dwEngine == WIN_SERVER_SHADOW_GDI 316 || (pScreenInfo->dwEngine == WIN_SERVER_SHADOW_DDNL 317 && pScreenInfo->fFullScreen) 318 || (pScreenInfo->dwEngine == WIN_SERVER_SHADOW_DD 319 && pScreenInfo->fFullScreen))) 320 { 321 winSetColormapFunctions (pScreen); 322 323 /* 324 * NOTE: Setting whitePixel to 255 causes Magic 7.1 to allocate its 325 * own colormap, as it cannot allocate 7 planes in the default 326 * colormap. Setting whitePixel to 1 allows Magic to get 7 327 * planes in the default colormap, so it doesn't create its 328 * own colormap. This latter situation is highly desireable, 329 * as it keeps the Magic window viewable when switching to 330 * other X clients that use the default colormap. 331 */ 332 pScreen->blackPixel = 0; 333 pScreen->whitePixel = 1; 334 } 335 336 /* Place our save screen function */ 337 pScreen->SaveScreen = winSaveScreen; 338 339 /* Backing store functions */ 340 /* 341 * FIXME: Backing store support still doesn't seem to be working. 342 */ 343 pScreen->BackingStoreFuncs.SaveAreas = fbSaveAreas; 344 pScreen->BackingStoreFuncs.RestoreAreas = fbRestoreAreas; 345 346 /* Finish fb initialization */ 347 if (!fbFinishScreenInit (pScreen, 348 pScreenInfo->pfb, 349 pScreenInfo->dwWidth, pScreenInfo->dwHeight, 350 monitorResolution, monitorResolution, 351 pScreenInfo->dwStride, 352 pScreenInfo->dwBPP)) 353 { 354 ErrorF ("winFinishScreenInitFB - fbFinishScreenInit failed\n"); 355 return FALSE; 356 } 357 358 /* Save a pointer to the root visual */ 359 for (pVisual = pScreen->visuals; 360 pVisual->vid != pScreen->rootVisual; 361 pVisual++); 362 pScreenPriv->pRootVisual = pVisual; 363 364 /* 365 * Setup points to the block and wakeup handlers. Pass a pointer 366 * to the current screen as pWakeupdata. 367 */ 368 pScreen->BlockHandler = winBlockHandler; 369 pScreen->WakeupHandler = winWakeupHandler; 370 pScreen->blockData = pScreen; 371 pScreen->wakeupData = pScreen; 372 373#ifdef XWIN_MULTIWINDOWEXTWM 374 /* 375 * Setup acceleration for multi-window external window manager mode. 376 * To be compatible with the Damage extension, this must be done 377 * before calling miDCInitialize, which calls DamageSetup. 378 */ 379 if (pScreenInfo->fMWExtWM) 380 { 381 if (!RootlessAccelInit (pScreen)) 382 { 383 ErrorF ("winFinishScreenInitFB - RootlessAccelInit () failed\n"); 384 return FALSE; 385 } 386 } 387#endif 388 389#ifdef RENDER 390 /* Render extension initialization, calls miPictureInit */ 391 if (!fbPictureInit (pScreen, NULL, 0)) 392 { 393 ErrorF ("winFinishScreenInitFB - fbPictureInit () failed\n"); 394 return FALSE; 395 } 396#endif 397 398#ifdef RANDR 399 /* Initialize resize and rotate support */ 400 if (!winRandRInit (pScreen)) 401 { 402 ErrorF ("winFinishScreenInitFB - winRandRInit () failed\n"); 403 return FALSE; 404 } 405#endif 406 407 /* 408 * Backing store support should reduce network traffic and increase 409 * performance. 410 */ 411 miInitializeBackingStore (pScreen); 412 413 /* KDrive does miDCInitialize right after miInitializeBackingStore */ 414 /* Setup the cursor routines */ 415#if CYGDEBUG 416 winDebug ("winFinishScreenInitFB - Calling miDCInitialize ()\n"); 417#endif 418 miDCInitialize (pScreen, &g_winPointerCursorFuncs); 419 420 /* KDrive does winCreateDefColormap right after miDCInitialize */ 421 /* Create a default colormap */ 422#if CYGDEBUG 423 winDebug ("winFinishScreenInitFB - Calling winCreateDefColormap ()\n"); 424#endif 425 if (!winCreateDefColormap (pScreen)) 426 { 427 ErrorF ("winFinishScreenInitFB - Could not create colormap\n"); 428 return FALSE; 429 } 430 431 /* Initialize the shadow framebuffer layer */ 432 if ((pScreenInfo->dwEngine == WIN_SERVER_SHADOW_GDI 433 || pScreenInfo->dwEngine == WIN_SERVER_SHADOW_DD 434 || pScreenInfo->dwEngine == WIN_SERVER_SHADOW_DDNL) 435#ifdef XWIN_MULTIWINDOWEXTWM 436 && !pScreenInfo->fMWExtWM 437#endif 438 ) 439 { 440#if CYGDEBUG 441 winDebug ("winFinishScreenInitFB - Calling shadowInit ()\n"); 442#endif 443 if (!shadowInit (pScreen, 444 pScreenPriv->pwinShadowUpdate, 445 NULL)) 446 { 447 ErrorF ("winFinishScreenInitFB - shadowInit () failed\n"); 448 return FALSE; 449 } 450 } 451 452#ifdef XWIN_MULTIWINDOWEXTWM 453 /* Handle multi-window external window manager mode */ 454 if (pScreenInfo->fMWExtWM) 455 { 456 winDebug ("winScreenInit - MultiWindowExtWM - Calling RootlessInit\n"); 457 458 RootlessInit(pScreen, &winMWExtWMProcs); 459 460 winDebug ("winScreenInit - MultiWindowExtWM - RootlessInit returned\n"); 461 462 rootless_CopyBytes_threshold = 0; 463 rootless_FillBytes_threshold = 0; 464 rootless_CompositePixels_threshold = 0; 465 /* FIXME: How many? Profiling needed? */ 466 rootless_CopyWindow_threshold = 1; 467 468 winWindowsWMExtensionInit (); 469 } 470#endif 471 472 /* Handle rootless mode */ 473 if (pScreenInfo->fRootless) 474 { 475 /* Define the WRAP macro temporarily for local use */ 476#define WRAP(a) \ 477 if (pScreen->a) { \ 478 pScreenPriv->a = pScreen->a; \ 479 } else { \ 480 ErrorF("null screen fn " #a "\n"); \ 481 pScreenPriv->a = NULL; \ 482 } 483 484 /* Save a pointer to each lower-level window procedure */ 485 WRAP(CreateWindow); 486 WRAP(DestroyWindow); 487 WRAP(RealizeWindow); 488 WRAP(UnrealizeWindow); 489 WRAP(PositionWindow); 490 WRAP(ChangeWindowAttributes); 491#ifdef SHAPE 492 WRAP(SetShape); 493#endif 494 495 /* Assign rootless window procedures to be top level procedures */ 496 pScreen->CreateWindow = winCreateWindowRootless; 497 pScreen->DestroyWindow = winDestroyWindowRootless; 498 pScreen->PositionWindow = winPositionWindowRootless; 499 /*pScreen->ChangeWindowAttributes = winChangeWindowAttributesRootless;*/ 500 pScreen->RealizeWindow = winMapWindowRootless; 501 pScreen->UnrealizeWindow = winUnmapWindowRootless; 502#ifdef SHAPE 503 pScreen->SetShape = winSetShapeRootless; 504#endif 505 506 /* Undefine the WRAP macro, as it is not needed elsewhere */ 507#undef WRAP 508 } 509 510 511#ifdef XWIN_MULTIWINDOW 512 /* Handle multi window mode */ 513 else if (pScreenInfo->fMultiWindow) 514 { 515 /* Define the WRAP macro temporarily for local use */ 516#define WRAP(a) \ 517 if (pScreen->a) { \ 518 pScreenPriv->a = pScreen->a; \ 519 } else { \ 520 ErrorF("null screen fn " #a "\n"); \ 521 pScreenPriv->a = NULL; \ 522 } 523 524 /* Save a pointer to each lower-level window procedure */ 525 WRAP(CreateWindow); 526 WRAP(DestroyWindow); 527 WRAP(RealizeWindow); 528 WRAP(UnrealizeWindow); 529 WRAP(PositionWindow); 530 WRAP(ChangeWindowAttributes); 531 WRAP(ReparentWindow); 532 WRAP(RestackWindow); 533 WRAP(ResizeWindow); 534 WRAP(MoveWindow); 535 WRAP(CopyWindow); 536#ifdef SHAPE 537 WRAP(SetShape); 538#endif 539 540 /* Assign multi-window window procedures to be top level procedures */ 541 pScreen->CreateWindow = winCreateWindowMultiWindow; 542 pScreen->DestroyWindow = winDestroyWindowMultiWindow; 543 pScreen->PositionWindow = winPositionWindowMultiWindow; 544 /*pScreen->ChangeWindowAttributes = winChangeWindowAttributesMultiWindow;*/ 545 pScreen->RealizeWindow = winMapWindowMultiWindow; 546 pScreen->UnrealizeWindow = winUnmapWindowMultiWindow; 547 pScreen->ReparentWindow = winReparentWindowMultiWindow; 548 pScreen->RestackWindow = winRestackWindowMultiWindow; 549 pScreen->ResizeWindow = winResizeWindowMultiWindow; 550 pScreen->MoveWindow = winMoveWindowMultiWindow; 551 pScreen->CopyWindow = winCopyWindowMultiWindow; 552#ifdef SHAPE 553 pScreen->SetShape = winSetShapeMultiWindow; 554#endif 555 556 /* Undefine the WRAP macro, as it is not needed elsewhere */ 557#undef WRAP 558 } 559#endif 560 561 /* Wrap either fb's or shadow's CloseScreen with our CloseScreen */ 562 pScreenPriv->CloseScreen = pScreen->CloseScreen; 563 pScreen->CloseScreen = pScreenPriv->pwinCloseScreen; 564 565#if defined(XWIN_CLIPBOARD) || defined(XWIN_MULTIWINDOW) 566 /* Create a mutex for modules in separate threads to wait for */ 567 iReturn = pthread_mutex_init (&pScreenPriv->pmServerStarted, NULL); 568 if (iReturn != 0) 569 { 570 ErrorF ("winFinishScreenInitFB - pthread_mutex_init () failed: %d\n", 571 iReturn); 572 return FALSE; 573 } 574 575 /* Own the mutex for modules in separate threads */ 576 iReturn = pthread_mutex_lock (&pScreenPriv->pmServerStarted); 577 if (iReturn != 0) 578 { 579 ErrorF ("winFinishScreenInitFB - pthread_mutex_lock () failed: %d\n", 580 iReturn); 581 return FALSE; 582 } 583 584 /* Set the ServerStarted flag to false */ 585 pScreenPriv->fServerStarted = FALSE; 586#endif 587 588#ifdef XWIN_MULTIWINDOWEXTWM 589 pScreenPriv->fRestacking = FALSE; 590#endif 591 592#if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM) 593 if (FALSE 594#ifdef XWIN_MULTIWINDOW 595 || pScreenInfo->fMultiWindow 596#endif 597#ifdef XWIN_MULTIWINDOWEXTWM 598 || pScreenInfo->fInternalWM 599#endif 600 ) 601 { 602#if CYGDEBUG || YES 603 winDebug ("winFinishScreenInitFB - Calling winInitWM.\n"); 604#endif 605 606 /* Initialize multi window mode */ 607 if (!winInitWM (&pScreenPriv->pWMInfo, 608 &pScreenPriv->ptWMProc, 609 &pScreenPriv->ptXMsgProc, 610 &pScreenPriv->pmServerStarted, 611 pScreenInfo->dwScreen, 612 (HWND)&pScreenPriv->hwndScreen, 613#ifdef XWIN_MULTIWINDOWEXTWM 614 pScreenInfo->fInternalWM || 615#endif 616 FALSE)) 617 { 618 ErrorF ("winFinishScreenInitFB - winInitWM () failed.\n"); 619 return FALSE; 620 } 621 } 622#endif 623 624 /* Tell the server that we are enabled */ 625 pScreenPriv->fEnabled = TRUE; 626 627 /* Tell the server that we have a valid depth */ 628 pScreenPriv->fBadDepth = FALSE; 629 630#if CYGDEBUG || YES 631 winDebug ("winFinishScreenInitFB - returning\n"); 632#endif 633 634 return TRUE; 635} 636 637#ifdef XWIN_NATIVEGDI 638/* See Porting Layer Definition - p. 20 */ 639 640Bool 641winFinishScreenInitNativeGDI (int index, 642 ScreenPtr pScreen, 643 int argc, char **argv) 644{ 645 winScreenPriv(pScreen); 646 winScreenInfoPtr pScreenInfo = &g_ScreenInfo[index]; 647 VisualPtr pVisuals = NULL; 648 DepthPtr pDepths = NULL; 649 VisualID rootVisual = 0; 650 int nVisuals = 0, nDepths = 0, nRootDepth = 0; 651 652 /* Ignore user input (mouse, keyboard) */ 653 pScreenInfo->fIgnoreInput = FALSE; 654 655 /* Get device contexts for the screen and shadow bitmap */ 656 pScreenPriv->hdcScreen = GetDC (pScreenPriv->hwndScreen); 657 if (pScreenPriv->hdcScreen == NULL) 658 FatalError ("winFinishScreenInitNativeGDI - Couldn't get a DC\n"); 659 660 /* Init visuals */ 661 if (!(*pScreenPriv->pwinInitVisuals) (pScreen)) 662 { 663 ErrorF ("winFinishScreenInitNativeGDI - pwinInitVisuals failed\n"); 664 return FALSE; 665 } 666 667 /* Initialize the mi visuals */ 668 if (!miInitVisuals (&pVisuals, &pDepths, &nVisuals, &nDepths, &nRootDepth, 669 &rootVisual, 670 ((unsigned long)1 << (pScreenInfo->dwDepth - 1)), 8, 671 TrueColor)) 672 { 673 ErrorF ("winFinishScreenInitNativeGDI - miInitVisuals () failed\n"); 674 return FALSE; 675 } 676 677 /* Initialize the CloseScreen procedure pointer */ 678 pScreen->CloseScreen = NULL; 679 680 /* Initialize the mi code */ 681 if (!miScreenInit (pScreen, 682 NULL, /* No framebuffer */ 683 pScreenInfo->dwWidth, pScreenInfo->dwHeight, 684 monitorResolution, monitorResolution, 685 pScreenInfo->dwStride, 686 nRootDepth, nDepths, pDepths, rootVisual, 687 nVisuals, pVisuals)) 688 { 689 ErrorF ("winFinishScreenInitNativeGDI - miScreenInit failed\n"); 690 return FALSE; 691 } 692 693 pScreen->defColormap = FakeClientID(0); 694 695 /* 696 * Register our block and wakeup handlers; these procedures 697 * process messages in our Windows message queue; specifically, 698 * they process mouse and keyboard input. 699 */ 700 pScreen->BlockHandler = winBlockHandler; 701 pScreen->WakeupHandler = winWakeupHandler; 702 pScreen->blockData = pScreen; 703 pScreen->wakeupData = pScreen; 704 705 /* Place our save screen function */ 706 pScreen->SaveScreen = winSaveScreen; 707 708 /* Pixmaps */ 709 pScreen->CreatePixmap = winCreatePixmapNativeGDI; 710 pScreen->DestroyPixmap = winDestroyPixmapNativeGDI; 711 712 /* Other Screen Routines */ 713 pScreen->QueryBestSize = winQueryBestSizeNativeGDI; 714 pScreen->SaveScreen = winSaveScreen; 715 pScreen->GetImage = miGetImage; 716 pScreen->GetSpans = winGetSpansNativeGDI; 717 718 /* Window Procedures */ 719 pScreen->CreateWindow = winCreateWindowNativeGDI; 720 pScreen->DestroyWindow = winDestroyWindowNativeGDI; 721 pScreen->PositionWindow = winPositionWindowNativeGDI; 722 /*pScreen->ChangeWindowAttributes = winChangeWindowAttributesNativeGDI;*/ 723 pScreen->RealizeWindow = winMapWindowNativeGDI; 724 pScreen->UnrealizeWindow = winUnmapWindowNativeGDI; 725 726 /* Paint window */ 727 pScreen->PaintWindowBackground = miPaintWindow; 728 pScreen->PaintWindowBorder = miPaintWindow; 729 pScreen->CopyWindow = winCopyWindowNativeGDI; 730 731 /* Fonts */ 732 pScreen->RealizeFont = winRealizeFontNativeGDI; 733 pScreen->UnrealizeFont = winUnrealizeFontNativeGDI; 734 735 /* GC */ 736 pScreen->CreateGC = winCreateGCNativeGDI; 737 738 /* Colormap Routines */ 739 pScreen->CreateColormap = miInitializeColormap; 740 pScreen->DestroyColormap = (DestroyColormapProcPtr) (void (*)(void)) NoopDDA; 741 pScreen->InstallColormap = miInstallColormap; 742 pScreen->UninstallColormap = miUninstallColormap; 743 pScreen->ListInstalledColormaps = miListInstalledColormaps; 744 pScreen->StoreColors = (StoreColorsProcPtr) (void (*)(void)) NoopDDA; 745 pScreen->ResolveColor = miResolveColor; 746 747 /* Bitmap */ 748 pScreen->BitmapToRegion = winPixmapToRegionNativeGDI; 749 750 ErrorF ("winFinishScreenInitNativeGDI - calling miDCInitialize\n"); 751 752 /* Set the default white and black pixel positions */ 753 pScreen->whitePixel = pScreen->blackPixel = (Pixel) 0; 754 755 /* Initialize the cursor */ 756 if (!miDCInitialize (pScreen, &g_winPointerCursorFuncs)) 757 { 758 ErrorF ("winFinishScreenInitNativeGDI - miDCInitialize failed\n"); 759 return FALSE; 760 } 761 762 /* Create a default colormap */ 763 if (!miCreateDefColormap (pScreen)) 764 { 765 ErrorF ("winFinishScreenInitNativeGDI - miCreateDefColormap () " 766 "failed\n"); 767 return FALSE; 768 } 769 770 ErrorF ("winFinishScreenInitNativeGDI - miCreateDefColormap () " 771 "returned\n"); 772 773 /* mi doesn't use a CloseScreen procedure, so no need to wrap */ 774 pScreen->CloseScreen = pScreenPriv->pwinCloseScreen; 775 776 /* Tell the server that we are enabled */ 777 pScreenPriv->fEnabled = TRUE; 778 779 ErrorF ("winFinishScreenInitNativeGDI - Successful addition of " 780 "screen %08x\n", 781 (unsigned int) pScreen); 782 783 return TRUE; 784} 785#endif 786 787 788/* See Porting Layer Definition - p. 33 */ 789static Bool 790winSaveScreen (ScreenPtr pScreen, int on) 791{ 792 return TRUE; 793} 794