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