winshadgdi.c revision 05b261ec
105b261ecSmrg/*
205b261ecSmrg *Copyright (C) 2001-2004 Harold L Hunt II All Rights Reserved.
305b261ecSmrg *
405b261ecSmrg *Permission is hereby granted, free of charge, to any person obtaining
505b261ecSmrg * a copy of this software and associated documentation files (the
605b261ecSmrg *"Software"), to deal in the Software without restriction, including
705b261ecSmrg *without limitation the rights to use, copy, modify, merge, publish,
805b261ecSmrg *distribute, sublicense, and/or sell copies of the Software, and to
905b261ecSmrg *permit persons to whom the Software is furnished to do so, subject to
1005b261ecSmrg *the following conditions:
1105b261ecSmrg *
1205b261ecSmrg *The above copyright notice and this permission notice shall be
1305b261ecSmrg *included in all copies or substantial portions of the Software.
1405b261ecSmrg *
1505b261ecSmrg *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
1605b261ecSmrg *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
1705b261ecSmrg *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
1805b261ecSmrg *NONINFRINGEMENT. IN NO EVENT SHALL HAROLD L HUNT II BE LIABLE FOR
1905b261ecSmrg *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
2005b261ecSmrg *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
2105b261ecSmrg *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2205b261ecSmrg *
2305b261ecSmrg *Except as contained in this notice, the name of Harold L Hunt II
2405b261ecSmrg *shall not be used in advertising or otherwise to promote the sale, use
2505b261ecSmrg *or other dealings in this Software without prior written authorization
2605b261ecSmrg *from Harold L Hunt II.
2705b261ecSmrg *
2805b261ecSmrg * Authors:	Harold L Hunt II
2905b261ecSmrg */
3005b261ecSmrg
3105b261ecSmrg#ifdef HAVE_XWIN_CONFIG_H
3205b261ecSmrg#include <xwin-config.h>
3305b261ecSmrg#endif
3405b261ecSmrg#include "win.h"
3505b261ecSmrg
3605b261ecSmrg
3705b261ecSmrg/*
3805b261ecSmrg * External symbols
3905b261ecSmrg */
4005b261ecSmrg
4105b261ecSmrg#ifdef XWIN_MULTIWINDOW
4205b261ecSmrgextern DWORD			g_dwCurrentThreadID;
4305b261ecSmrg#endif
4405b261ecSmrgextern HWND			g_hDlgExit;
4505b261ecSmrg
4605b261ecSmrg
4705b261ecSmrg/*
4805b261ecSmrg * Local function prototypes
4905b261ecSmrg */
5005b261ecSmrg
5105b261ecSmrg#ifdef XWIN_MULTIWINDOW
5205b261ecSmrgstatic wBOOL CALLBACK
5305b261ecSmrgwinRedrawAllProcShadowGDI (HWND hwnd, LPARAM lParam);
5405b261ecSmrg
5505b261ecSmrgstatic wBOOL CALLBACK
5605b261ecSmrgwinRedrawDamagedWindowShadowGDI (HWND hwnd, LPARAM lParam);
5705b261ecSmrg#endif
5805b261ecSmrg
5905b261ecSmrgstatic Bool
6005b261ecSmrgwinAllocateFBShadowGDI (ScreenPtr pScreen);
6105b261ecSmrg
6205b261ecSmrgstatic void
6305b261ecSmrgwinShadowUpdateGDI (ScreenPtr pScreen,
6405b261ecSmrg		    shadowBufPtr pBuf);
6505b261ecSmrg
6605b261ecSmrgstatic Bool
6705b261ecSmrgwinCloseScreenShadowGDI (int nIndex, ScreenPtr pScreen);
6805b261ecSmrg
6905b261ecSmrgstatic Bool
7005b261ecSmrgwinInitVisualsShadowGDI (ScreenPtr pScreen);
7105b261ecSmrg
7205b261ecSmrgstatic Bool
7305b261ecSmrgwinAdjustVideoModeShadowGDI (ScreenPtr pScreen);
7405b261ecSmrg
7505b261ecSmrgstatic Bool
7605b261ecSmrgwinBltExposedRegionsShadowGDI (ScreenPtr pScreen);
7705b261ecSmrg
7805b261ecSmrgstatic Bool
7905b261ecSmrgwinActivateAppShadowGDI (ScreenPtr pScreen);
8005b261ecSmrg
8105b261ecSmrgstatic Bool
8205b261ecSmrgwinRedrawScreenShadowGDI (ScreenPtr pScreen);
8305b261ecSmrg
8405b261ecSmrgstatic Bool
8505b261ecSmrgwinRealizeInstalledPaletteShadowGDI (ScreenPtr pScreen);
8605b261ecSmrg
8705b261ecSmrgstatic Bool
8805b261ecSmrgwinInstallColormapShadowGDI (ColormapPtr pColormap);
8905b261ecSmrg
9005b261ecSmrgstatic Bool
9105b261ecSmrgwinStoreColorsShadowGDI (ColormapPtr pmap,
9205b261ecSmrg			 int ndef,
9305b261ecSmrg			 xColorItem *pdefs);
9405b261ecSmrg
9505b261ecSmrgstatic Bool
9605b261ecSmrgwinCreateColormapShadowGDI (ColormapPtr pColormap);
9705b261ecSmrg
9805b261ecSmrgstatic Bool
9905b261ecSmrgwinDestroyColormapShadowGDI (ColormapPtr pColormap);
10005b261ecSmrg
10105b261ecSmrg
10205b261ecSmrg/*
10305b261ecSmrg * Internal function to get the DIB format that is compatible with the screen
10405b261ecSmrg */
10505b261ecSmrg
10605b261ecSmrgstatic
10705b261ecSmrgBool
10805b261ecSmrgwinQueryScreenDIBFormat (ScreenPtr pScreen, BITMAPINFOHEADER *pbmih)
10905b261ecSmrg{
11005b261ecSmrg  winScreenPriv(pScreen);
11105b261ecSmrg  HBITMAP		hbmp;
11205b261ecSmrg#if CYGDEBUG
11305b261ecSmrg  LPDWORD		pdw = NULL;
11405b261ecSmrg#endif
11505b261ecSmrg
11605b261ecSmrg  /* Create a memory bitmap compatible with the screen */
11705b261ecSmrg  hbmp = CreateCompatibleBitmap (pScreenPriv->hdcScreen, 1, 1);
11805b261ecSmrg  if (hbmp == NULL)
11905b261ecSmrg    {
12005b261ecSmrg      ErrorF ("winQueryScreenDIBFormat - CreateCompatibleBitmap failed\n");
12105b261ecSmrg      return FALSE;
12205b261ecSmrg    }
12305b261ecSmrg
12405b261ecSmrg  /* Initialize our bitmap info header */
12505b261ecSmrg  ZeroMemory (pbmih, sizeof (BITMAPINFOHEADER) + 256 * sizeof (RGBQUAD));
12605b261ecSmrg  pbmih->biSize = sizeof (BITMAPINFOHEADER);
12705b261ecSmrg
12805b261ecSmrg  /* Get the biBitCount */
12905b261ecSmrg  if (!GetDIBits (pScreenPriv->hdcScreen,
13005b261ecSmrg		  hbmp,
13105b261ecSmrg		  0, 1,
13205b261ecSmrg		  NULL,
13305b261ecSmrg		  (BITMAPINFO*) pbmih,
13405b261ecSmrg		  DIB_RGB_COLORS))
13505b261ecSmrg    {
13605b261ecSmrg      ErrorF ("winQueryScreenDIBFormat - First call to GetDIBits failed\n");
13705b261ecSmrg      DeleteObject (hbmp);
13805b261ecSmrg      return FALSE;
13905b261ecSmrg    }
14005b261ecSmrg
14105b261ecSmrg#if CYGDEBUG
14205b261ecSmrg  /* Get a pointer to bitfields */
14305b261ecSmrg  pdw = (DWORD*) ((CARD8*)pbmih + sizeof (BITMAPINFOHEADER));
14405b261ecSmrg
14505b261ecSmrg  winDebug ("winQueryScreenDIBFormat - First call masks: %08x %08x %08x\n",
14605b261ecSmrg	  pdw[0], pdw[1], pdw[2]);
14705b261ecSmrg#endif
14805b261ecSmrg
14905b261ecSmrg  /* Get optimal color table, or the optimal bitfields */
15005b261ecSmrg  if (!GetDIBits (pScreenPriv->hdcScreen,
15105b261ecSmrg		  hbmp,
15205b261ecSmrg		  0, 1,
15305b261ecSmrg		  NULL,
15405b261ecSmrg		  (BITMAPINFO*)pbmih,
15505b261ecSmrg		  DIB_RGB_COLORS))
15605b261ecSmrg    {
15705b261ecSmrg      ErrorF ("winQueryScreenDIBFormat - Second call to GetDIBits "
15805b261ecSmrg	      "failed\n");
15905b261ecSmrg      DeleteObject (hbmp);
16005b261ecSmrg      return FALSE;
16105b261ecSmrg    }
16205b261ecSmrg
16305b261ecSmrg  /* Free memory */
16405b261ecSmrg  DeleteObject (hbmp);
16505b261ecSmrg
16605b261ecSmrg  return TRUE;
16705b261ecSmrg}
16805b261ecSmrg
16905b261ecSmrg
17005b261ecSmrg/*
17105b261ecSmrg * Internal function to determine the GDI bits per rgb and bit masks
17205b261ecSmrg */
17305b261ecSmrg
17405b261ecSmrgstatic
17505b261ecSmrgBool
17605b261ecSmrgwinQueryRGBBitsAndMasks (ScreenPtr pScreen)
17705b261ecSmrg{
17805b261ecSmrg  winScreenPriv(pScreen);
17905b261ecSmrg  BITMAPINFOHEADER	*pbmih = NULL;
18005b261ecSmrg  Bool			fReturn = TRUE;
18105b261ecSmrg  LPDWORD		pdw = NULL;
18205b261ecSmrg  DWORD			dwRedBits, dwGreenBits, dwBlueBits;
18305b261ecSmrg
18405b261ecSmrg  /* Color masks for 8 bpp are standardized */
18505b261ecSmrg  if (GetDeviceCaps (pScreenPriv->hdcScreen, RASTERCAPS) & RC_PALETTE)
18605b261ecSmrg    {
18705b261ecSmrg      /*
18805b261ecSmrg       * RGB BPP for 8 bit palletes is always 8
18905b261ecSmrg       * and the color masks are always 0.
19005b261ecSmrg       */
19105b261ecSmrg      pScreenPriv->dwBitsPerRGB = 8;
19205b261ecSmrg      pScreenPriv->dwRedMask = 0x0L;
19305b261ecSmrg      pScreenPriv->dwGreenMask = 0x0L;
19405b261ecSmrg      pScreenPriv->dwBlueMask = 0x0L;
19505b261ecSmrg      return TRUE;
19605b261ecSmrg    }
19705b261ecSmrg
19805b261ecSmrg  /* Color masks for 24 bpp are standardized */
19905b261ecSmrg  if (GetDeviceCaps (pScreenPriv->hdcScreen, PLANES)
20005b261ecSmrg      * GetDeviceCaps (pScreenPriv->hdcScreen, BITSPIXEL) == 24)
20105b261ecSmrg    {
20205b261ecSmrg      ErrorF ("winQueryRGBBitsAndMasks - GetDeviceCaps (BITSPIXEL) "
20305b261ecSmrg	      "returned 24 for the screen.  Using default 24bpp masks.\n");
20405b261ecSmrg
20505b261ecSmrg      /* 8 bits per primary color */
20605b261ecSmrg      pScreenPriv->dwBitsPerRGB = 8;
20705b261ecSmrg
20805b261ecSmrg      /* Set screen privates masks */
20905b261ecSmrg      pScreenPriv->dwRedMask = WIN_24BPP_MASK_RED;
21005b261ecSmrg      pScreenPriv->dwGreenMask = WIN_24BPP_MASK_GREEN;
21105b261ecSmrg      pScreenPriv->dwBlueMask = WIN_24BPP_MASK_BLUE;
21205b261ecSmrg
21305b261ecSmrg      return TRUE;
21405b261ecSmrg    }
21505b261ecSmrg
21605b261ecSmrg  /* Allocate a bitmap header and color table */
21705b261ecSmrg  pbmih = (BITMAPINFOHEADER*) malloc (sizeof (BITMAPINFOHEADER)
21805b261ecSmrg				      + 256  * sizeof (RGBQUAD));
21905b261ecSmrg  if (pbmih == NULL)
22005b261ecSmrg    {
22105b261ecSmrg      ErrorF ("winQueryRGBBitsAndMasks - malloc failed\n");
22205b261ecSmrg      return FALSE;
22305b261ecSmrg    }
22405b261ecSmrg
22505b261ecSmrg  /* Get screen description */
22605b261ecSmrg  if (winQueryScreenDIBFormat (pScreen, pbmih))
22705b261ecSmrg    {
22805b261ecSmrg      /* Get a pointer to bitfields */
22905b261ecSmrg      pdw = (DWORD*) ((CARD8*)pbmih + sizeof (BITMAPINFOHEADER));
23005b261ecSmrg
23105b261ecSmrg#if CYGDEBUG
23205b261ecSmrg      winDebug ("%s - Masks: %08x %08x %08x\n", __FUNCTION__,
23305b261ecSmrg	      pdw[0], pdw[1], pdw[2]);
23405b261ecSmrg      winDebug ("%s - Bitmap: %dx%d %d bpp %d planes\n", __FUNCTION__,
23505b261ecSmrg              pbmih->biWidth, pbmih->biHeight, pbmih->biBitCount, pbmih->biPlanes);
23605b261ecSmrg      winDebug ("%s - Compression: %d %s\n", __FUNCTION__,
23705b261ecSmrg              pbmih->biCompression,
23805b261ecSmrg              (pbmih->biCompression == BI_RGB?"(BI_RGB)":
23905b261ecSmrg               (pbmih->biCompression == BI_RLE8?"(BI_RLE8)":
24005b261ecSmrg                (pbmih->biCompression == BI_RLE4?"(BI_RLE4)":
24105b261ecSmrg                 (pbmih->biCompression == BI_BITFIELDS?"(BI_BITFIELDS)":""
24205b261ecSmrg                 )))));
24305b261ecSmrg#endif
24405b261ecSmrg
24505b261ecSmrg      /* Handle BI_RGB case, which is returned by Wine */
24605b261ecSmrg      if (pbmih->biCompression == BI_RGB)
24705b261ecSmrg        {
24805b261ecSmrg	  dwRedBits = 5;
24905b261ecSmrg	  dwGreenBits = 5;
25005b261ecSmrg	  dwBlueBits = 5;
25105b261ecSmrg
25205b261ecSmrg	  pScreenPriv->dwBitsPerRGB = 5;
25305b261ecSmrg
25405b261ecSmrg	  /* Set screen privates masks */
25505b261ecSmrg	  pScreenPriv->dwRedMask = 0x7c00;
25605b261ecSmrg	  pScreenPriv->dwGreenMask = 0x03e0;
25705b261ecSmrg	  pScreenPriv->dwBlueMask = 0x001f;
25805b261ecSmrg        }
25905b261ecSmrg      else
26005b261ecSmrg        {
26105b261ecSmrg          /* Count the number of bits in each mask */
26205b261ecSmrg          dwRedBits = winCountBits (pdw[0]);
26305b261ecSmrg          dwGreenBits = winCountBits (pdw[1]);
26405b261ecSmrg          dwBlueBits = winCountBits (pdw[2]);
26505b261ecSmrg
26605b261ecSmrg	  /* Find maximum bits per red, green, blue */
26705b261ecSmrg	  if (dwRedBits > dwGreenBits && dwRedBits > dwBlueBits)
26805b261ecSmrg	    pScreenPriv->dwBitsPerRGB = dwRedBits;
26905b261ecSmrg	  else if (dwGreenBits > dwRedBits && dwGreenBits > dwBlueBits)
27005b261ecSmrg	    pScreenPriv->dwBitsPerRGB = dwGreenBits;
27105b261ecSmrg	  else
27205b261ecSmrg	    pScreenPriv->dwBitsPerRGB = dwBlueBits;
27305b261ecSmrg
27405b261ecSmrg	  /* Set screen privates masks */
27505b261ecSmrg	  pScreenPriv->dwRedMask = pdw[0];
27605b261ecSmrg	  pScreenPriv->dwGreenMask = pdw[1];
27705b261ecSmrg	  pScreenPriv->dwBlueMask = pdw[2];
27805b261ecSmrg	}
27905b261ecSmrg    }
28005b261ecSmrg  else
28105b261ecSmrg    {
28205b261ecSmrg      ErrorF ("winQueryRGBBitsAndMasks - winQueryScreenDIBFormat failed\n");
28305b261ecSmrg      free (pbmih);
28405b261ecSmrg      fReturn = FALSE;
28505b261ecSmrg    }
28605b261ecSmrg
28705b261ecSmrg  /* Free memory */
28805b261ecSmrg  free (pbmih);
28905b261ecSmrg
29005b261ecSmrg  return fReturn;
29105b261ecSmrg}
29205b261ecSmrg
29305b261ecSmrg
29405b261ecSmrg#ifdef XWIN_MULTIWINDOW
29505b261ecSmrg/*
29605b261ecSmrg * Redraw all ---?
29705b261ecSmrg */
29805b261ecSmrg
29905b261ecSmrgstatic wBOOL CALLBACK
30005b261ecSmrgwinRedrawAllProcShadowGDI (HWND hwnd, LPARAM lParam)
30105b261ecSmrg{
30205b261ecSmrg  if (hwnd == (HWND)lParam)
30305b261ecSmrg    return TRUE;
30405b261ecSmrg  InvalidateRect (hwnd, NULL, FALSE);
30505b261ecSmrg  UpdateWindow (hwnd);
30605b261ecSmrg  return TRUE;
30705b261ecSmrg}
30805b261ecSmrg
30905b261ecSmrgstatic wBOOL CALLBACK
31005b261ecSmrgwinRedrawDamagedWindowShadowGDI (HWND hwnd, LPARAM lParam)
31105b261ecSmrg{
31205b261ecSmrg  BoxPtr pDamage = (BoxPtr)lParam;
31305b261ecSmrg  RECT rcClient, rcDamage, rcRedraw;
31405b261ecSmrg  POINT topLeft, bottomRight;
31505b261ecSmrg
31605b261ecSmrg  if (IsIconic (hwnd))
31705b261ecSmrg    return TRUE; /* Don't care minimized windows */
31805b261ecSmrg
31905b261ecSmrg  /* Convert the damaged area from Screen coords to Client coords */
32005b261ecSmrg  topLeft.x = pDamage->x1; topLeft.y = pDamage->y1;
32105b261ecSmrg  bottomRight.x = pDamage->x2; bottomRight.y = pDamage->y2;
32205b261ecSmrg  topLeft.x += GetSystemMetrics (SM_XVIRTUALSCREEN);
32305b261ecSmrg  bottomRight.x += GetSystemMetrics (SM_XVIRTUALSCREEN);
32405b261ecSmrg  topLeft.y += GetSystemMetrics (SM_YVIRTUALSCREEN);
32505b261ecSmrg  bottomRight.y += GetSystemMetrics (SM_YVIRTUALSCREEN);
32605b261ecSmrg  ScreenToClient (hwnd, &topLeft);
32705b261ecSmrg  ScreenToClient (hwnd, &bottomRight);
32805b261ecSmrg  SetRect (&rcDamage, topLeft.x, topLeft.y, bottomRight.x, bottomRight.y);
32905b261ecSmrg
33005b261ecSmrg  GetClientRect (hwnd, &rcClient);
33105b261ecSmrg
33205b261ecSmrg  if (IntersectRect (&rcRedraw, &rcClient, &rcDamage))
33305b261ecSmrg    {
33405b261ecSmrg      InvalidateRect (hwnd, &rcRedraw, FALSE);
33505b261ecSmrg      UpdateWindow (hwnd);
33605b261ecSmrg    }
33705b261ecSmrg  return TRUE;
33805b261ecSmrg}
33905b261ecSmrg#endif
34005b261ecSmrg
34105b261ecSmrg
34205b261ecSmrg/*
34305b261ecSmrg * Allocate a DIB for the shadow framebuffer GDI server
34405b261ecSmrg */
34505b261ecSmrg
34605b261ecSmrgstatic Bool
34705b261ecSmrgwinAllocateFBShadowGDI (ScreenPtr pScreen)
34805b261ecSmrg{
34905b261ecSmrg  winScreenPriv(pScreen);
35005b261ecSmrg  winScreenInfo		*pScreenInfo = pScreenPriv->pScreenInfo;
35105b261ecSmrg  BITMAPINFOHEADER	*pbmih = NULL;
35205b261ecSmrg  DIBSECTION		dibsection;
35305b261ecSmrg  Bool			fReturn = TRUE;
35405b261ecSmrg
35505b261ecSmrg  /* Get device contexts for the screen and shadow bitmap */
35605b261ecSmrg  pScreenPriv->hdcScreen = GetDC (pScreenPriv->hwndScreen);
35705b261ecSmrg  pScreenPriv->hdcShadow = CreateCompatibleDC (pScreenPriv->hdcScreen);
35805b261ecSmrg
35905b261ecSmrg  /* Allocate bitmap info header */
36005b261ecSmrg  pbmih = (BITMAPINFOHEADER*) malloc (sizeof (BITMAPINFOHEADER)
36105b261ecSmrg				      + 256 * sizeof (RGBQUAD));
36205b261ecSmrg  if (pbmih == NULL)
36305b261ecSmrg    {
36405b261ecSmrg      ErrorF ("winAllocateFBShadowGDI - malloc () failed\n");
36505b261ecSmrg      return FALSE;
36605b261ecSmrg    }
36705b261ecSmrg
36805b261ecSmrg  /* Query the screen format */
36905b261ecSmrg  fReturn = winQueryScreenDIBFormat (pScreen, pbmih);
37005b261ecSmrg
37105b261ecSmrg  /* Describe shadow bitmap to be created */
37205b261ecSmrg  pbmih->biWidth = pScreenInfo->dwWidth;
37305b261ecSmrg  pbmih->biHeight = -pScreenInfo->dwHeight;
37405b261ecSmrg
37505b261ecSmrg  ErrorF ("winAllocateFBShadowGDI - Creating DIB with width: %d height: %d "
37605b261ecSmrg	  "depth: %d\n",
37705b261ecSmrg	  (int) pbmih->biWidth, (int) -pbmih->biHeight, pbmih->biBitCount);
37805b261ecSmrg
37905b261ecSmrg  /* Create a DI shadow bitmap with a bit pointer */
38005b261ecSmrg  pScreenPriv->hbmpShadow = CreateDIBSection (pScreenPriv->hdcScreen,
38105b261ecSmrg					      (BITMAPINFO *) pbmih,
38205b261ecSmrg					      DIB_RGB_COLORS,
38305b261ecSmrg					      (VOID**) &pScreenInfo->pfb,
38405b261ecSmrg					      NULL,
38505b261ecSmrg					      0);
38605b261ecSmrg  if (pScreenPriv->hbmpShadow == NULL || pScreenInfo->pfb == NULL)
38705b261ecSmrg    {
38805b261ecSmrg      winW32Error (2, "winAllocateFBShadowGDI - CreateDIBSection failed:");
38905b261ecSmrg      return FALSE;
39005b261ecSmrg    }
39105b261ecSmrg  else
39205b261ecSmrg    {
39305b261ecSmrg#if CYGDEBUG
39405b261ecSmrg      winDebug ("winAllocateFBShadowGDI - Shadow buffer allocated\n");
39505b261ecSmrg#endif
39605b261ecSmrg    }
39705b261ecSmrg
39805b261ecSmrg  /* Get information about the bitmap that was allocated */
39905b261ecSmrg  GetObject (pScreenPriv->hbmpShadow,
40005b261ecSmrg	     sizeof (dibsection),
40105b261ecSmrg	     &dibsection);
40205b261ecSmrg
40305b261ecSmrg#if CYGDEBUG || YES
40405b261ecSmrg  /* Print information about bitmap allocated */
40505b261ecSmrg  winDebug ("winAllocateFBShadowGDI - Dibsection width: %d height: %d "
40605b261ecSmrg	  "depth: %d size image: %d\n",
40705b261ecSmrg	  (int) dibsection.dsBmih.biWidth, (int) dibsection.dsBmih.biHeight,
40805b261ecSmrg	  dibsection.dsBmih.biBitCount,
40905b261ecSmrg	  (int) dibsection.dsBmih.biSizeImage);
41005b261ecSmrg#endif
41105b261ecSmrg
41205b261ecSmrg  /* Select the shadow bitmap into the shadow DC */
41305b261ecSmrg  SelectObject (pScreenPriv->hdcShadow,
41405b261ecSmrg		pScreenPriv->hbmpShadow);
41505b261ecSmrg
41605b261ecSmrg#if CYGDEBUG
41705b261ecSmrg  winDebug ("winAllocateFBShadowGDI - Attempting a shadow blit\n");
41805b261ecSmrg#endif
41905b261ecSmrg
42005b261ecSmrg  /* Do a test blit from the shadow to the screen, I think */
42105b261ecSmrg  fReturn = BitBlt (pScreenPriv->hdcScreen,
42205b261ecSmrg		    0, 0,
42305b261ecSmrg		    pScreenInfo->dwWidth, pScreenInfo->dwHeight,
42405b261ecSmrg		    pScreenPriv->hdcShadow,
42505b261ecSmrg		    0, 0,
42605b261ecSmrg		    SRCCOPY);
42705b261ecSmrg  if (fReturn)
42805b261ecSmrg    {
42905b261ecSmrg#if CYGDEBUG
43005b261ecSmrg      winDebug ("winAllocateFBShadowGDI - Shadow blit success\n");
43105b261ecSmrg#endif
43205b261ecSmrg    }
43305b261ecSmrg  else
43405b261ecSmrg    {
43505b261ecSmrg      winW32Error (2, "winAllocateFBShadowGDI - Shadow blit failure\n");
43605b261ecSmrg#if 0
43705b261ecSmrg      return FALSE;
43805b261ecSmrg#else
43905b261ecSmrg      /* ago: ignore this error. The blit fails with wine, but does not
44005b261ecSmrg       * cause any problems later. */
44105b261ecSmrg
44205b261ecSmrg      fReturn = TRUE;
44305b261ecSmrg#endif
44405b261ecSmrg    }
44505b261ecSmrg
44605b261ecSmrg  /* Look for height weirdness */
44705b261ecSmrg  if (dibsection.dsBmih.biHeight < 0)
44805b261ecSmrg    {
44905b261ecSmrg      dibsection.dsBmih.biHeight = -dibsection.dsBmih.biHeight;
45005b261ecSmrg    }
45105b261ecSmrg
45205b261ecSmrg  /* Set screeninfo stride */
45305b261ecSmrg  pScreenInfo->dwStride = ((dibsection.dsBmih.biSizeImage
45405b261ecSmrg			    / dibsection.dsBmih.biHeight)
45505b261ecSmrg			   * 8) / pScreenInfo->dwBPP;
45605b261ecSmrg
45705b261ecSmrg#if CYGDEBUG || YES
45805b261ecSmrg  winDebug ("winAllocateFBShadowGDI - Created shadow stride: %d\n",
45905b261ecSmrg	  (int) pScreenInfo->dwStride);
46005b261ecSmrg#endif
46105b261ecSmrg
46205b261ecSmrg  /* See if the shadow bitmap will be larger than the DIB size limit */
46305b261ecSmrg  if (pScreenInfo->dwWidth * pScreenInfo->dwHeight * pScreenInfo->dwBPP
46405b261ecSmrg      >= WIN_DIB_MAXIMUM_SIZE)
46505b261ecSmrg    {
46605b261ecSmrg      ErrorF ("winAllocateFBShadowGDI - Requested DIB (bitmap) "
46705b261ecSmrg	      "will be larger than %d MB.  The surface may fail to be "
46805b261ecSmrg	      "allocated on Windows 95, 98, or Me, due to a %d MB limit in "
46905b261ecSmrg	      "DIB size.  This limit does not apply to Windows NT/2000, and "
47005b261ecSmrg	      "this message may be ignored on those platforms.\n",
47105b261ecSmrg	      WIN_DIB_MAXIMUM_SIZE_MB, WIN_DIB_MAXIMUM_SIZE_MB);
47205b261ecSmrg    }
47305b261ecSmrg
47405b261ecSmrg  /* Determine our color masks */
47505b261ecSmrg  if (!winQueryRGBBitsAndMasks (pScreen))
47605b261ecSmrg    {
47705b261ecSmrg      ErrorF ("winAllocateFBShadowGDI - winQueryRGBBitsAndMasks failed\n");
47805b261ecSmrg      return FALSE;
47905b261ecSmrg    }
48005b261ecSmrg
48105b261ecSmrg#ifdef XWIN_MULTIWINDOW
48205b261ecSmrg  /* Redraw all windows */
48305b261ecSmrg  if (pScreenInfo->fMultiWindow)
48405b261ecSmrg    EnumThreadWindows (g_dwCurrentThreadID, winRedrawAllProcShadowGDI, 0);
48505b261ecSmrg#endif
48605b261ecSmrg
48705b261ecSmrg  return fReturn;
48805b261ecSmrg}
48905b261ecSmrg
49005b261ecSmrg
49105b261ecSmrg/*
49205b261ecSmrg * Blit the damaged regions of the shadow fb to the screen
49305b261ecSmrg */
49405b261ecSmrg
49505b261ecSmrgstatic void
49605b261ecSmrgwinShadowUpdateGDI (ScreenPtr pScreen,
49705b261ecSmrg		    shadowBufPtr pBuf)
49805b261ecSmrg{
49905b261ecSmrg  winScreenPriv(pScreen);
50005b261ecSmrg  winScreenInfo		*pScreenInfo = pScreenPriv->pScreenInfo;
50105b261ecSmrg  RegionPtr		damage = &pBuf->damage;
50205b261ecSmrg  DWORD			dwBox = REGION_NUM_RECTS (damage);
50305b261ecSmrg  BoxPtr		pBox = REGION_RECTS (damage);
50405b261ecSmrg  int			x, y, w, h;
50505b261ecSmrg  HRGN			hrgnTemp = NULL, hrgnCombined = NULL;
50605b261ecSmrg#ifdef XWIN_UPDATESTATS
50705b261ecSmrg  static DWORD		s_dwNonUnitRegions = 0;
50805b261ecSmrg  static DWORD		s_dwTotalUpdates = 0;
50905b261ecSmrg  static DWORD		s_dwTotalBoxes = 0;
51005b261ecSmrg#endif
51105b261ecSmrg  BoxPtr		pBoxExtents = REGION_EXTENTS (pScreen, damage);
51205b261ecSmrg
51305b261ecSmrg  /*
51405b261ecSmrg   * Return immediately if the app is not active
51505b261ecSmrg   * and we are fullscreen, or if we have a bad display depth
51605b261ecSmrg   */
51705b261ecSmrg  if ((!pScreenPriv->fActive && pScreenInfo->fFullScreen)
51805b261ecSmrg      || pScreenPriv->fBadDepth) return;
51905b261ecSmrg
52005b261ecSmrg#ifdef XWIN_UPDATESTATS
52105b261ecSmrg  ++s_dwTotalUpdates;
52205b261ecSmrg  s_dwTotalBoxes += dwBox;
52305b261ecSmrg
52405b261ecSmrg  if (dwBox != 1)
52505b261ecSmrg    {
52605b261ecSmrg      ++s_dwNonUnitRegions;
52705b261ecSmrg      ErrorF ("winShadowUpdatGDI - dwBox: %d\n", dwBox);
52805b261ecSmrg    }
52905b261ecSmrg
53005b261ecSmrg  if ((s_dwTotalUpdates % 100) == 0)
53105b261ecSmrg    ErrorF ("winShadowUpdateGDI - %d%% non-unity regions, avg boxes: %d "
53205b261ecSmrg	    "nu: %d tu: %d\n",
53305b261ecSmrg	    (s_dwNonUnitRegions * 100) / s_dwTotalUpdates,
53405b261ecSmrg	    s_dwTotalBoxes / s_dwTotalUpdates,
53505b261ecSmrg	    s_dwNonUnitRegions, s_dwTotalUpdates);
53605b261ecSmrg#endif /* XWIN_UPDATESTATS */
53705b261ecSmrg
53805b261ecSmrg  /*
53905b261ecSmrg   * Handle small regions with multiple blits,
54005b261ecSmrg   * handle large regions by creating a clipping region and
54105b261ecSmrg   * doing a single blit constrained to that clipping region.
54205b261ecSmrg   */
54305b261ecSmrg  if (!pScreenInfo->fMultiWindow &&
54405b261ecSmrg      (pScreenInfo->dwClipUpdatesNBoxes == 0 ||
54505b261ecSmrg      dwBox < pScreenInfo->dwClipUpdatesNBoxes))
54605b261ecSmrg    {
54705b261ecSmrg      /* Loop through all boxes in the damaged region */
54805b261ecSmrg      while (dwBox--)
54905b261ecSmrg	{
55005b261ecSmrg	  /*
55105b261ecSmrg	   * Calculate x offset, y offset, width, and height for
55205b261ecSmrg	   * current damage box
55305b261ecSmrg	   */
55405b261ecSmrg	  x = pBox->x1;
55505b261ecSmrg	  y = pBox->y1;
55605b261ecSmrg	  w = pBox->x2 - pBox->x1;
55705b261ecSmrg	  h = pBox->y2 - pBox->y1;
55805b261ecSmrg
55905b261ecSmrg	  BitBlt (pScreenPriv->hdcScreen,
56005b261ecSmrg		  x, y,
56105b261ecSmrg		  w, h,
56205b261ecSmrg		  pScreenPriv->hdcShadow,
56305b261ecSmrg		  x, y,
56405b261ecSmrg		  SRCCOPY);
56505b261ecSmrg
56605b261ecSmrg	  /* Get a pointer to the next box */
56705b261ecSmrg	  ++pBox;
56805b261ecSmrg	}
56905b261ecSmrg    }
57005b261ecSmrg  else if (!pScreenInfo->fMultiWindow)
57105b261ecSmrg    {
57205b261ecSmrg      /* Compute a GDI region from the damaged region */
57305b261ecSmrg      hrgnCombined = CreateRectRgn (pBox->x1, pBox->y1, pBox->x2, pBox->y2);
57405b261ecSmrg      dwBox--;
57505b261ecSmrg      pBox++;
57605b261ecSmrg      while (dwBox--)
57705b261ecSmrg	{
57805b261ecSmrg	  hrgnTemp = CreateRectRgn (pBox->x1, pBox->y1, pBox->x2, pBox->y2);
57905b261ecSmrg	  CombineRgn (hrgnCombined, hrgnCombined, hrgnTemp, RGN_OR);
58005b261ecSmrg	  DeleteObject (hrgnTemp);
58105b261ecSmrg	  pBox++;
58205b261ecSmrg	}
58305b261ecSmrg
58405b261ecSmrg      /* Install the GDI region as a clipping region */
58505b261ecSmrg      SelectClipRgn (pScreenPriv->hdcScreen, hrgnCombined);
58605b261ecSmrg      DeleteObject (hrgnCombined);
58705b261ecSmrg      hrgnCombined = NULL;
58805b261ecSmrg
58905b261ecSmrg      /*
59005b261ecSmrg       * Blit the shadow buffer to the screen,
59105b261ecSmrg       * constrained to the clipping region.
59205b261ecSmrg       */
59305b261ecSmrg      BitBlt (pScreenPriv->hdcScreen,
59405b261ecSmrg	      pBoxExtents->x1, pBoxExtents->y1,
59505b261ecSmrg	      pBoxExtents->x2 - pBoxExtents->x1,
59605b261ecSmrg	      pBoxExtents->y2 - pBoxExtents->y1,
59705b261ecSmrg	      pScreenPriv->hdcShadow,
59805b261ecSmrg	      pBoxExtents->x1, pBoxExtents->y1,
59905b261ecSmrg	      SRCCOPY);
60005b261ecSmrg
60105b261ecSmrg      /* Reset the clip region */
60205b261ecSmrg      SelectClipRgn (pScreenPriv->hdcScreen, NULL);
60305b261ecSmrg    }
60405b261ecSmrg
60505b261ecSmrg#ifdef XWIN_MULTIWINDOW
60605b261ecSmrg  /* Redraw all multiwindow windows */
60705b261ecSmrg  if (pScreenInfo->fMultiWindow)
60805b261ecSmrg    EnumThreadWindows (g_dwCurrentThreadID,
60905b261ecSmrg		       winRedrawDamagedWindowShadowGDI,
61005b261ecSmrg		       (LPARAM)pBoxExtents);
61105b261ecSmrg#endif
61205b261ecSmrg}
61305b261ecSmrg
61405b261ecSmrg
61505b261ecSmrg/* See Porting Layer Definition - p. 33 */
61605b261ecSmrg/*
61705b261ecSmrg * We wrap whatever CloseScreen procedure was specified by fb;
61805b261ecSmrg * a pointer to said procedure is stored in our privates.
61905b261ecSmrg */
62005b261ecSmrg
62105b261ecSmrgstatic Bool
62205b261ecSmrgwinCloseScreenShadowGDI (int nIndex, ScreenPtr pScreen)
62305b261ecSmrg{
62405b261ecSmrg  winScreenPriv(pScreen);
62505b261ecSmrg  winScreenInfo		*pScreenInfo = pScreenPriv->pScreenInfo;
62605b261ecSmrg  Bool			fReturn;
62705b261ecSmrg
62805b261ecSmrg#if CYGDEBUG
62905b261ecSmrg  winDebug ("winCloseScreenShadowGDI - Freeing screen resources\n");
63005b261ecSmrg#endif
63105b261ecSmrg
63205b261ecSmrg  /* Flag that the screen is closed */
63305b261ecSmrg  pScreenPriv->fClosed = TRUE;
63405b261ecSmrg  pScreenPriv->fActive = FALSE;
63505b261ecSmrg
63605b261ecSmrg  /* Call the wrapped CloseScreen procedure */
63705b261ecSmrg  WIN_UNWRAP(CloseScreen);
63805b261ecSmrg  fReturn = (*pScreen->CloseScreen) (nIndex, pScreen);
63905b261ecSmrg
64005b261ecSmrg  /* Delete the window property */
64105b261ecSmrg  RemoveProp (pScreenPriv->hwndScreen, WIN_SCR_PROP);
64205b261ecSmrg
64305b261ecSmrg  /* Free the shadow DC; which allows the bitmap to be freed */
64405b261ecSmrg  DeleteDC (pScreenPriv->hdcShadow);
64505b261ecSmrg
64605b261ecSmrg  /* Free the shadow bitmap */
64705b261ecSmrg  DeleteObject (pScreenPriv->hbmpShadow);
64805b261ecSmrg
64905b261ecSmrg  /* Free the screen DC */
65005b261ecSmrg  ReleaseDC (pScreenPriv->hwndScreen, pScreenPriv->hdcScreen);
65105b261ecSmrg
65205b261ecSmrg  /* Delete tray icon, if we have one */
65305b261ecSmrg  if (!pScreenInfo->fNoTrayIcon)
65405b261ecSmrg    winDeleteNotifyIcon (pScreenPriv);
65505b261ecSmrg
65605b261ecSmrg  /* Free the exit confirmation dialog box, if it exists */
65705b261ecSmrg  if (g_hDlgExit != NULL)
65805b261ecSmrg    {
65905b261ecSmrg      DestroyWindow (g_hDlgExit);
66005b261ecSmrg      g_hDlgExit = NULL;
66105b261ecSmrg    }
66205b261ecSmrg
66305b261ecSmrg  /* Kill our window */
66405b261ecSmrg  if (pScreenPriv->hwndScreen)
66505b261ecSmrg    {
66605b261ecSmrg      DestroyWindow (pScreenPriv->hwndScreen);
66705b261ecSmrg      pScreenPriv->hwndScreen = NULL;
66805b261ecSmrg    }
66905b261ecSmrg
67005b261ecSmrg#if defined(XWIN_CLIPBOARD) || defined(XWIN_MULTIWINDOW)
67105b261ecSmrg  /* Destroy the thread startup mutex */
67205b261ecSmrg  pthread_mutex_destroy (&pScreenPriv->pmServerStarted);
67305b261ecSmrg#endif
67405b261ecSmrg
67505b261ecSmrg  /* Invalidate our screeninfo's pointer to the screen */
67605b261ecSmrg  pScreenInfo->pScreen = NULL;
67705b261ecSmrg
67805b261ecSmrg  /* Invalidate the ScreenInfo's fb pointer */
67905b261ecSmrg  pScreenInfo->pfb = NULL;
68005b261ecSmrg
68105b261ecSmrg  /* Free the screen privates for this screen */
68205b261ecSmrg  free ((pointer) pScreenPriv);
68305b261ecSmrg
68405b261ecSmrg  return fReturn;
68505b261ecSmrg}
68605b261ecSmrg
68705b261ecSmrg
68805b261ecSmrg/*
68905b261ecSmrg * Tell mi what sort of visuals we need.
69005b261ecSmrg *
69105b261ecSmrg * Generally we only need one visual, as our screen can only
69205b261ecSmrg * handle one format at a time, I believe.  You may want
69305b261ecSmrg * to verify that last sentence.
69405b261ecSmrg */
69505b261ecSmrg
69605b261ecSmrgstatic Bool
69705b261ecSmrgwinInitVisualsShadowGDI (ScreenPtr pScreen)
69805b261ecSmrg{
69905b261ecSmrg  winScreenPriv(pScreen);
70005b261ecSmrg  winScreenInfo		*pScreenInfo = pScreenPriv->pScreenInfo;
70105b261ecSmrg
70205b261ecSmrg  /* Display debugging information */
70305b261ecSmrg  ErrorF ("winInitVisualsShadowGDI - Masks %08x %08x %08x BPRGB %d d %d "
70405b261ecSmrg	  "bpp %d\n",
70505b261ecSmrg	  (unsigned int) pScreenPriv->dwRedMask,
70605b261ecSmrg	  (unsigned int) pScreenPriv->dwGreenMask,
70705b261ecSmrg	  (unsigned int) pScreenPriv->dwBlueMask,
70805b261ecSmrg	  (int) pScreenPriv->dwBitsPerRGB,
70905b261ecSmrg	  (int) pScreenInfo->dwDepth,
71005b261ecSmrg	  (int) pScreenInfo->dwBPP);
71105b261ecSmrg
71205b261ecSmrg  /* Create a single visual according to the Windows screen depth */
71305b261ecSmrg  switch (pScreenInfo->dwDepth)
71405b261ecSmrg    {
71505b261ecSmrg    case 24:
71605b261ecSmrg    case 16:
71705b261ecSmrg    case 15:
71805b261ecSmrg#if defined(XFree86Server)
71905b261ecSmrg      /* Setup the real visual */
72005b261ecSmrg      if (!miSetVisualTypesAndMasks (pScreenInfo->dwDepth,
72105b261ecSmrg				     TrueColorMask,
72205b261ecSmrg				     pScreenPriv->dwBitsPerRGB,
72305b261ecSmrg				     -1,
72405b261ecSmrg				     pScreenPriv->dwRedMask,
72505b261ecSmrg				     pScreenPriv->dwGreenMask,
72605b261ecSmrg				     pScreenPriv->dwBlueMask))
72705b261ecSmrg	{
72805b261ecSmrg	  ErrorF ("winInitVisualsShadowGDI - miSetVisualTypesAndMasks "
72905b261ecSmrg		  "failed\n");
73005b261ecSmrg	  return FALSE;
73105b261ecSmrg	}
73205b261ecSmrg
73305b261ecSmrg#ifdef XWIN_EMULATEPSEUDO
73405b261ecSmrg      if (!pScreenInfo->fEmulatePseudo)
73505b261ecSmrg	break;
73605b261ecSmrg
73705b261ecSmrg      /* Setup a pseudocolor visual */
73805b261ecSmrg      if (!miSetVisualTypesAndMasks (8,
73905b261ecSmrg				     PseudoColorMask,
74005b261ecSmrg				     8,
74105b261ecSmrg				     -1,
74205b261ecSmrg				     0,
74305b261ecSmrg				     0,
74405b261ecSmrg				     0))
74505b261ecSmrg	{
74605b261ecSmrg	  ErrorF ("winInitVisualsShadowGDI - miSetVisualTypesAndMasks "
74705b261ecSmrg		  "failed for PseudoColor\n");
74805b261ecSmrg	  return FALSE;
74905b261ecSmrg	}
75005b261ecSmrg#endif
75105b261ecSmrg#else /* XFree86Server */
75205b261ecSmrg      /* Setup the real visual */
75305b261ecSmrg      if (!fbSetVisualTypesAndMasks (pScreenInfo->dwDepth,
75405b261ecSmrg				     TrueColorMask,
75505b261ecSmrg				     pScreenPriv->dwBitsPerRGB,
75605b261ecSmrg				     pScreenPriv->dwRedMask,
75705b261ecSmrg				     pScreenPriv->dwGreenMask,
75805b261ecSmrg				     pScreenPriv->dwBlueMask))
75905b261ecSmrg	{
76005b261ecSmrg	  ErrorF ("winInitVisualsShadowGDI - fbSetVisualTypesAndMasks "
76105b261ecSmrg		  "failed for TrueColor\n");
76205b261ecSmrg	  return FALSE;
76305b261ecSmrg	}
76405b261ecSmrg
76505b261ecSmrg#ifdef XWIN_EMULATEPSEUDO
76605b261ecSmrg      if (!pScreenInfo->fEmulatePseudo)
76705b261ecSmrg	break;
76805b261ecSmrg
76905b261ecSmrg      /* Setup a pseudocolor visual */
77005b261ecSmrg      if (!fbSetVisualTypesAndMasks (8,
77105b261ecSmrg				     PseudoColorMask,
77205b261ecSmrg				     8,
77305b261ecSmrg				     0,
77405b261ecSmrg				     0,
77505b261ecSmrg				     0))
77605b261ecSmrg	{
77705b261ecSmrg	  ErrorF ("winInitVisualsShadowGDI - fbSetVisualTypesAndMasks "
77805b261ecSmrg		  "failed for PseudoColor\n");
77905b261ecSmrg	  return FALSE;
78005b261ecSmrg	}
78105b261ecSmrg#endif
78205b261ecSmrg#endif /* XFree86Server */
78305b261ecSmrg      break;
78405b261ecSmrg
78505b261ecSmrg    case 8:
78605b261ecSmrg#if defined(XFree86Server)
78705b261ecSmrg      if (!miSetVisualTypesAndMasks (pScreenInfo->dwDepth,
78805b261ecSmrg				     PseudoColorMask,
78905b261ecSmrg				     pScreenPriv->dwBitsPerRGB,
79005b261ecSmrg				     PseudoColor,
79105b261ecSmrg				     pScreenPriv->dwRedMask,
79205b261ecSmrg				     pScreenPriv->dwGreenMask,
79305b261ecSmrg				     pScreenPriv->dwBlueMask))
79405b261ecSmrg	{
79505b261ecSmrg	  ErrorF ("winInitVisualsShadowGDI - miSetVisualTypesAndMasks "
79605b261ecSmrg		  "failed\n");
79705b261ecSmrg	  return FALSE;
79805b261ecSmrg	}
79905b261ecSmrg#else /* XFree86Server */
80005b261ecSmrg      if (!fbSetVisualTypesAndMasks (pScreenInfo->dwDepth,
80105b261ecSmrg				     PseudoColorMask,
80205b261ecSmrg				     pScreenPriv->dwBitsPerRGB,
80305b261ecSmrg				     pScreenPriv->dwRedMask,
80405b261ecSmrg				     pScreenPriv->dwGreenMask,
80505b261ecSmrg				     pScreenPriv->dwBlueMask))
80605b261ecSmrg	{
80705b261ecSmrg	  ErrorF ("winInitVisualsShadowGDI - fbSetVisualTypesAndMasks "
80805b261ecSmrg		  "failed\n");
80905b261ecSmrg	  return FALSE;
81005b261ecSmrg	}
81105b261ecSmrg#endif
81205b261ecSmrg      break;
81305b261ecSmrg
81405b261ecSmrg    default:
81505b261ecSmrg      ErrorF ("winInitVisualsShadowGDI - Unknown screen depth\n");
81605b261ecSmrg      return FALSE;
81705b261ecSmrg    }
81805b261ecSmrg
81905b261ecSmrg#if CYGDEBUG
82005b261ecSmrg  winDebug ("winInitVisualsShadowGDI - Returning\n");
82105b261ecSmrg#endif
82205b261ecSmrg
82305b261ecSmrg  return TRUE;
82405b261ecSmrg}
82505b261ecSmrg
82605b261ecSmrg
82705b261ecSmrg/*
82805b261ecSmrg * Adjust the proposed video mode
82905b261ecSmrg */
83005b261ecSmrg
83105b261ecSmrgstatic Bool
83205b261ecSmrgwinAdjustVideoModeShadowGDI (ScreenPtr pScreen)
83305b261ecSmrg{
83405b261ecSmrg  winScreenPriv(pScreen);
83505b261ecSmrg  winScreenInfo		*pScreenInfo = pScreenPriv->pScreenInfo;
83605b261ecSmrg  HDC			hdc;
83705b261ecSmrg  DWORD			dwBPP;
83805b261ecSmrg
83905b261ecSmrg  hdc = GetDC (NULL);
84005b261ecSmrg
84105b261ecSmrg  /* We're in serious trouble if we can't get a DC */
84205b261ecSmrg  if (hdc == NULL)
84305b261ecSmrg    {
84405b261ecSmrg      ErrorF ("winAdjustVideoModeShadowGDI - GetDC () failed\n");
84505b261ecSmrg      return FALSE;
84605b261ecSmrg    }
84705b261ecSmrg
84805b261ecSmrg  /* Query GDI for current display depth */
84905b261ecSmrg  dwBPP = GetDeviceCaps (hdc, BITSPIXEL);
85005b261ecSmrg
85105b261ecSmrg  /* GDI cannot change the screen depth */
85205b261ecSmrg  if (pScreenInfo->dwBPP == WIN_DEFAULT_BPP)
85305b261ecSmrg    {
85405b261ecSmrg      /* No -depth parameter passed, let the user know the depth being used */
85505b261ecSmrg      ErrorF ("winAdjustVideoModeShadowGDI - Using Windows display "
85605b261ecSmrg	      "depth of %d bits per pixel\n", (int) dwBPP);
85705b261ecSmrg
85805b261ecSmrg      /* Use GDI's depth */
85905b261ecSmrg      pScreenInfo->dwBPP = dwBPP;
86005b261ecSmrg    }
86105b261ecSmrg  else if (dwBPP != pScreenInfo->dwBPP)
86205b261ecSmrg    {
86305b261ecSmrg      /* Warn user if GDI depth is different than -depth parameter */
86405b261ecSmrg      ErrorF ("winAdjustVideoModeShadowGDI - Command line bpp: %d, "\
86505b261ecSmrg	      "using bpp: %d\n", (int) pScreenInfo->dwBPP, (int) dwBPP);
86605b261ecSmrg
86705b261ecSmrg      /* We'll use GDI's depth */
86805b261ecSmrg      pScreenInfo->dwBPP = dwBPP;
86905b261ecSmrg    }
87005b261ecSmrg
87105b261ecSmrg  /* Release our DC */
87205b261ecSmrg  ReleaseDC (NULL, hdc);
87305b261ecSmrg  hdc = NULL;
87405b261ecSmrg
87505b261ecSmrg  return TRUE;
87605b261ecSmrg}
87705b261ecSmrg
87805b261ecSmrg
87905b261ecSmrg/*
88005b261ecSmrg * Blt exposed regions to the screen
88105b261ecSmrg */
88205b261ecSmrg
88305b261ecSmrgstatic Bool
88405b261ecSmrgwinBltExposedRegionsShadowGDI (ScreenPtr pScreen)
88505b261ecSmrg{
88605b261ecSmrg  winScreenPriv(pScreen);
88705b261ecSmrg  winScreenInfo		*pScreenInfo = pScreenPriv->pScreenInfo;
88805b261ecSmrg  winPrivCmapPtr	pCmapPriv = NULL;
88905b261ecSmrg  HDC			hdcUpdate;
89005b261ecSmrg  PAINTSTRUCT		ps;
89105b261ecSmrg
89205b261ecSmrg  /* BeginPaint gives us an hdc that clips to the invalidated region */
89305b261ecSmrg  hdcUpdate = BeginPaint (pScreenPriv->hwndScreen, &ps);
89405b261ecSmrg
89505b261ecSmrg  /* Realize the palette, if we have one */
89605b261ecSmrg  if (pScreenPriv->pcmapInstalled != NULL)
89705b261ecSmrg    {
89805b261ecSmrg      pCmapPriv = winGetCmapPriv (pScreenPriv->pcmapInstalled);
89905b261ecSmrg
90005b261ecSmrg      SelectPalette (hdcUpdate, pCmapPriv->hPalette, FALSE);
90105b261ecSmrg      RealizePalette (hdcUpdate);
90205b261ecSmrg    }
90305b261ecSmrg
90405b261ecSmrg  /* Our BitBlt will be clipped to the invalidated region */
90505b261ecSmrg  BitBlt (hdcUpdate,
90605b261ecSmrg	  0, 0,
90705b261ecSmrg	  pScreenInfo->dwWidth, pScreenInfo->dwHeight,
90805b261ecSmrg	  pScreenPriv->hdcShadow,
90905b261ecSmrg	  0, 0,
91005b261ecSmrg	  SRCCOPY);
91105b261ecSmrg
91205b261ecSmrg  /* EndPaint frees the DC */
91305b261ecSmrg  EndPaint (pScreenPriv->hwndScreen, &ps);
91405b261ecSmrg
91505b261ecSmrg#ifdef XWIN_MULTIWINDOW
91605b261ecSmrg  /* Redraw all windows */
91705b261ecSmrg  if (pScreenInfo->fMultiWindow)
91805b261ecSmrg    EnumThreadWindows(g_dwCurrentThreadID, winRedrawAllProcShadowGDI,
91905b261ecSmrg            (LPARAM)pScreenPriv->hwndScreen);
92005b261ecSmrg#endif
92105b261ecSmrg
92205b261ecSmrg  return TRUE;
92305b261ecSmrg}
92405b261ecSmrg
92505b261ecSmrg
92605b261ecSmrg/*
92705b261ecSmrg * Do any engine-specific appliation-activation processing
92805b261ecSmrg */
92905b261ecSmrg
93005b261ecSmrgstatic Bool
93105b261ecSmrgwinActivateAppShadowGDI (ScreenPtr pScreen)
93205b261ecSmrg{
93305b261ecSmrg  winScreenPriv(pScreen);
93405b261ecSmrg  winScreenInfo		*pScreenInfo = pScreenPriv->pScreenInfo;
93505b261ecSmrg
93605b261ecSmrg  /*
93705b261ecSmrg   * 2004/04/12 - Harold - We perform the restoring or minimizing
93805b261ecSmrg   * manually for ShadowGDI in fullscreen modes so that this engine
93905b261ecSmrg   * will perform just like ShadowDD and ShadowDDNL in fullscreen mode;
94005b261ecSmrg   * if we do not do this then our fullscreen window will appear in the
94105b261ecSmrg   * z-order when it is deactivated and it can be uncovered by resizing
94205b261ecSmrg   * or minimizing another window that is on top of it, which is not how
94305b261ecSmrg   * the DirectDraw engines work.  Therefore we keep this code here to
94405b261ecSmrg   * make sure that all engines work the same in fullscreen mode.
94505b261ecSmrg   */
94605b261ecSmrg
94705b261ecSmrg  /*
94805b261ecSmrg   * Are we active?
94905b261ecSmrg   * Are we fullscreen?
95005b261ecSmrg   */
95105b261ecSmrg  if (pScreenPriv->fActive
95205b261ecSmrg      && pScreenInfo->fFullScreen)
95305b261ecSmrg    {
95405b261ecSmrg      /*
95505b261ecSmrg       * Activating, attempt to bring our window
95605b261ecSmrg       * to the top of the display
95705b261ecSmrg       */
95805b261ecSmrg      ShowWindow (pScreenPriv->hwndScreen, SW_RESTORE);
95905b261ecSmrg    }
96005b261ecSmrg  else if (!pScreenPriv->fActive
96105b261ecSmrg	   && pScreenInfo->fFullScreen)
96205b261ecSmrg    {
96305b261ecSmrg      /*
96405b261ecSmrg       * Deactivating, stuff our window onto the
96505b261ecSmrg       * task bar.
96605b261ecSmrg       */
96705b261ecSmrg      ShowWindow (pScreenPriv->hwndScreen, SW_MINIMIZE);
96805b261ecSmrg    }
96905b261ecSmrg
97005b261ecSmrg  return TRUE;
97105b261ecSmrg}
97205b261ecSmrg
97305b261ecSmrg
97405b261ecSmrg/*
97505b261ecSmrg * Reblit the shadow framebuffer to the screen.
97605b261ecSmrg */
97705b261ecSmrg
97805b261ecSmrgstatic Bool
97905b261ecSmrgwinRedrawScreenShadowGDI (ScreenPtr pScreen)
98005b261ecSmrg{
98105b261ecSmrg  winScreenPriv(pScreen);
98205b261ecSmrg  winScreenInfo		*pScreenInfo = pScreenPriv->pScreenInfo;
98305b261ecSmrg
98405b261ecSmrg  /* Redraw the whole window, to take account for the new colors */
98505b261ecSmrg  BitBlt (pScreenPriv->hdcScreen,
98605b261ecSmrg	  0, 0,
98705b261ecSmrg	  pScreenInfo->dwWidth, pScreenInfo->dwHeight,
98805b261ecSmrg	  pScreenPriv->hdcShadow,
98905b261ecSmrg	  0, 0,
99005b261ecSmrg	  SRCCOPY);
99105b261ecSmrg
99205b261ecSmrg#ifdef XWIN_MULTIWINDOW
99305b261ecSmrg  /* Redraw all windows */
99405b261ecSmrg  if (pScreenInfo->fMultiWindow)
99505b261ecSmrg    EnumThreadWindows(g_dwCurrentThreadID, winRedrawAllProcShadowGDI, 0);
99605b261ecSmrg#endif
99705b261ecSmrg
99805b261ecSmrg  return TRUE;
99905b261ecSmrg}
100005b261ecSmrg
100105b261ecSmrg
100205b261ecSmrg
100305b261ecSmrg/*
100405b261ecSmrg * Realize the currently installed colormap
100505b261ecSmrg */
100605b261ecSmrg
100705b261ecSmrgstatic Bool
100805b261ecSmrgwinRealizeInstalledPaletteShadowGDI (ScreenPtr pScreen)
100905b261ecSmrg{
101005b261ecSmrg  winScreenPriv(pScreen);
101105b261ecSmrg  winPrivCmapPtr	pCmapPriv = NULL;
101205b261ecSmrg
101305b261ecSmrg#if CYGDEBUG
101405b261ecSmrg  winDebug ("winRealizeInstalledPaletteShadowGDI\n");
101505b261ecSmrg#endif
101605b261ecSmrg
101705b261ecSmrg  /* Don't do anything if there is not a colormap */
101805b261ecSmrg  if (pScreenPriv->pcmapInstalled == NULL)
101905b261ecSmrg    {
102005b261ecSmrg#if CYGDEBUG
102105b261ecSmrg      winDebug ("winRealizeInstalledPaletteShadowGDI - No colormap "
102205b261ecSmrg	      "installed\n");
102305b261ecSmrg#endif
102405b261ecSmrg      return TRUE;
102505b261ecSmrg    }
102605b261ecSmrg
102705b261ecSmrg  pCmapPriv = winGetCmapPriv (pScreenPriv->pcmapInstalled);
102805b261ecSmrg
102905b261ecSmrg  /* Realize our palette for the screen */
103005b261ecSmrg  if (RealizePalette (pScreenPriv->hdcScreen) == GDI_ERROR)
103105b261ecSmrg    {
103205b261ecSmrg      ErrorF ("winRealizeInstalledPaletteShadowGDI - RealizePalette () "
103305b261ecSmrg	      "failed\n");
103405b261ecSmrg      return FALSE;
103505b261ecSmrg    }
103605b261ecSmrg
103705b261ecSmrg  /* Set the DIB color table */
103805b261ecSmrg  if (SetDIBColorTable (pScreenPriv->hdcShadow,
103905b261ecSmrg			0,
104005b261ecSmrg			WIN_NUM_PALETTE_ENTRIES,
104105b261ecSmrg			pCmapPriv->rgbColors) == 0)
104205b261ecSmrg    {
104305b261ecSmrg      ErrorF ("winRealizeInstalledPaletteShadowGDI - SetDIBColorTable () "
104405b261ecSmrg	      "failed\n");
104505b261ecSmrg      return FALSE;
104605b261ecSmrg    }
104705b261ecSmrg
104805b261ecSmrg  return TRUE;
104905b261ecSmrg}
105005b261ecSmrg
105105b261ecSmrg
105205b261ecSmrg/*
105305b261ecSmrg * Install the specified colormap
105405b261ecSmrg */
105505b261ecSmrg
105605b261ecSmrgstatic Bool
105705b261ecSmrgwinInstallColormapShadowGDI (ColormapPtr pColormap)
105805b261ecSmrg{
105905b261ecSmrg  ScreenPtr		pScreen = pColormap->pScreen;
106005b261ecSmrg  winScreenPriv(pScreen);
106105b261ecSmrg  winScreenInfo		*pScreenInfo = pScreenPriv->pScreenInfo;
106205b261ecSmrg  winCmapPriv(pColormap);
106305b261ecSmrg
106405b261ecSmrg  /*
106505b261ecSmrg   * Tell Windows to install the new colormap
106605b261ecSmrg   */
106705b261ecSmrg  if (SelectPalette (pScreenPriv->hdcScreen,
106805b261ecSmrg		     pCmapPriv->hPalette,
106905b261ecSmrg		     FALSE) == NULL)
107005b261ecSmrg    {
107105b261ecSmrg      ErrorF ("winInstallColormapShadowGDI - SelectPalette () failed\n");
107205b261ecSmrg      return FALSE;
107305b261ecSmrg    }
107405b261ecSmrg
107505b261ecSmrg  /* Realize the palette */
107605b261ecSmrg  if (GDI_ERROR == RealizePalette (pScreenPriv->hdcScreen))
107705b261ecSmrg    {
107805b261ecSmrg      ErrorF ("winInstallColormapShadowGDI - RealizePalette () failed\n");
107905b261ecSmrg      return FALSE;
108005b261ecSmrg    }
108105b261ecSmrg
108205b261ecSmrg  /* Set the DIB color table */
108305b261ecSmrg  if (SetDIBColorTable (pScreenPriv->hdcShadow,
108405b261ecSmrg			0,
108505b261ecSmrg			WIN_NUM_PALETTE_ENTRIES,
108605b261ecSmrg			pCmapPriv->rgbColors) == 0)
108705b261ecSmrg    {
108805b261ecSmrg      ErrorF ("winInstallColormapShadowGDI - SetDIBColorTable () failed\n");
108905b261ecSmrg      return FALSE;
109005b261ecSmrg    }
109105b261ecSmrg
109205b261ecSmrg  /* Redraw the whole window, to take account for the new colors */
109305b261ecSmrg  BitBlt (pScreenPriv->hdcScreen,
109405b261ecSmrg	  0, 0,
109505b261ecSmrg	  pScreenInfo->dwWidth, pScreenInfo->dwHeight,
109605b261ecSmrg	  pScreenPriv->hdcShadow,
109705b261ecSmrg	  0, 0,
109805b261ecSmrg	  SRCCOPY);
109905b261ecSmrg
110005b261ecSmrg  /* Save a pointer to the newly installed colormap */
110105b261ecSmrg  pScreenPriv->pcmapInstalled = pColormap;
110205b261ecSmrg
110305b261ecSmrg#ifdef XWIN_MULTIWINDOW
110405b261ecSmrg  /* Redraw all windows */
110505b261ecSmrg  if (pScreenInfo->fMultiWindow)
110605b261ecSmrg    EnumThreadWindows (g_dwCurrentThreadID, winRedrawAllProcShadowGDI, 0);
110705b261ecSmrg#endif
110805b261ecSmrg
110905b261ecSmrg  return TRUE;
111005b261ecSmrg}
111105b261ecSmrg
111205b261ecSmrg
111305b261ecSmrg/*
111405b261ecSmrg * Store the specified colors in the specified colormap
111505b261ecSmrg */
111605b261ecSmrg
111705b261ecSmrgstatic Bool
111805b261ecSmrgwinStoreColorsShadowGDI (ColormapPtr pColormap,
111905b261ecSmrg			 int ndef,
112005b261ecSmrg			 xColorItem *pdefs)
112105b261ecSmrg{
112205b261ecSmrg  ScreenPtr		pScreen = pColormap->pScreen;
112305b261ecSmrg  winScreenPriv(pScreen);
112405b261ecSmrg  winCmapPriv(pColormap);
112505b261ecSmrg  ColormapPtr curpmap = pScreenPriv->pcmapInstalled;
112605b261ecSmrg
112705b261ecSmrg  /* Put the X colormap entries into the Windows logical palette */
112805b261ecSmrg  if (SetPaletteEntries (pCmapPriv->hPalette,
112905b261ecSmrg			 pdefs[0].pixel,
113005b261ecSmrg			 ndef,
113105b261ecSmrg			 pCmapPriv->peColors + pdefs[0].pixel) == 0)
113205b261ecSmrg    {
113305b261ecSmrg      ErrorF ("winStoreColorsShadowGDI - SetPaletteEntries () failed\n");
113405b261ecSmrg      return FALSE;
113505b261ecSmrg    }
113605b261ecSmrg
113705b261ecSmrg  /* Don't install the Windows palette if the colormap is not installed */
113805b261ecSmrg  if (pColormap != curpmap)
113905b261ecSmrg    {
114005b261ecSmrg      return TRUE;
114105b261ecSmrg    }
114205b261ecSmrg
114305b261ecSmrg  /* Try to install the newly modified colormap */
114405b261ecSmrg  if (!winInstallColormapShadowGDI (pColormap))
114505b261ecSmrg    {
114605b261ecSmrg      ErrorF ("winInstallColormapShadowGDI - winInstallColormapShadowGDI "
114705b261ecSmrg	      "failed\n");
114805b261ecSmrg      return FALSE;
114905b261ecSmrg    }
115005b261ecSmrg
115105b261ecSmrg#if 0
115205b261ecSmrg  /* Tell Windows that the palette has changed */
115305b261ecSmrg  RealizePalette (pScreenPriv->hdcScreen);
115405b261ecSmrg
115505b261ecSmrg  /* Set the DIB color table */
115605b261ecSmrg  if (SetDIBColorTable (pScreenPriv->hdcShadow,
115705b261ecSmrg			pdefs[0].pixel,
115805b261ecSmrg			ndef,
115905b261ecSmrg			pCmapPriv->rgbColors + pdefs[0].pixel) == 0)
116005b261ecSmrg    {
116105b261ecSmrg      ErrorF ("winInstallColormapShadowGDI - SetDIBColorTable () failed\n");
116205b261ecSmrg      return FALSE;
116305b261ecSmrg    }
116405b261ecSmrg
116505b261ecSmrg  /* Save a pointer to the newly installed colormap */
116605b261ecSmrg  pScreenPriv->pcmapInstalled = pColormap;
116705b261ecSmrg#endif
116805b261ecSmrg
116905b261ecSmrg  return TRUE;
117005b261ecSmrg}
117105b261ecSmrg
117205b261ecSmrg
117305b261ecSmrg/*
117405b261ecSmrg * Colormap initialization procedure
117505b261ecSmrg */
117605b261ecSmrg
117705b261ecSmrgstatic Bool
117805b261ecSmrgwinCreateColormapShadowGDI (ColormapPtr pColormap)
117905b261ecSmrg{
118005b261ecSmrg  LPLOGPALETTE		lpPaletteNew = NULL;
118105b261ecSmrg  DWORD			dwEntriesMax;
118205b261ecSmrg  VisualPtr		pVisual;
118305b261ecSmrg  HPALETTE		hpalNew = NULL;
118405b261ecSmrg  winCmapPriv(pColormap);
118505b261ecSmrg
118605b261ecSmrg  /* Get a pointer to the visual that the colormap belongs to */
118705b261ecSmrg  pVisual = pColormap->pVisual;
118805b261ecSmrg
118905b261ecSmrg  /* Get the maximum number of palette entries for this visual */
119005b261ecSmrg  dwEntriesMax = pVisual->ColormapEntries;
119105b261ecSmrg
119205b261ecSmrg  /* Allocate a Windows logical color palette with max entries */
119305b261ecSmrg  lpPaletteNew = malloc (sizeof (LOGPALETTE)
119405b261ecSmrg			 + (dwEntriesMax - 1) * sizeof (PALETTEENTRY));
119505b261ecSmrg  if (lpPaletteNew == NULL)
119605b261ecSmrg    {
119705b261ecSmrg      ErrorF ("winCreateColormapShadowGDI - Couldn't allocate palette "
119805b261ecSmrg	      "with %d entries\n",
119905b261ecSmrg	      (int) dwEntriesMax);
120005b261ecSmrg      return FALSE;
120105b261ecSmrg    }
120205b261ecSmrg
120305b261ecSmrg  /* Zero out the colormap */
120405b261ecSmrg  ZeroMemory (lpPaletteNew, sizeof (LOGPALETTE)
120505b261ecSmrg	      + (dwEntriesMax - 1) * sizeof (PALETTEENTRY));
120605b261ecSmrg
120705b261ecSmrg  /* Set the logical palette structure */
120805b261ecSmrg  lpPaletteNew->palVersion = 0x0300;
120905b261ecSmrg  lpPaletteNew->palNumEntries = dwEntriesMax;
121005b261ecSmrg
121105b261ecSmrg  /* Tell Windows to create the palette */
121205b261ecSmrg  hpalNew = CreatePalette (lpPaletteNew);
121305b261ecSmrg  if (hpalNew == NULL)
121405b261ecSmrg    {
121505b261ecSmrg      ErrorF ("winCreateColormapShadowGDI - CreatePalette () failed\n");
121605b261ecSmrg      free (lpPaletteNew);
121705b261ecSmrg      return FALSE;
121805b261ecSmrg    }
121905b261ecSmrg
122005b261ecSmrg  /* Save the Windows logical palette handle in the X colormaps' privates */
122105b261ecSmrg  pCmapPriv->hPalette = hpalNew;
122205b261ecSmrg
122305b261ecSmrg  /* Free the palette initialization memory */
122405b261ecSmrg  free (lpPaletteNew);
122505b261ecSmrg
122605b261ecSmrg  return TRUE;
122705b261ecSmrg}
122805b261ecSmrg
122905b261ecSmrg
123005b261ecSmrg/*
123105b261ecSmrg * Colormap destruction procedure
123205b261ecSmrg */
123305b261ecSmrg
123405b261ecSmrgstatic Bool
123505b261ecSmrgwinDestroyColormapShadowGDI (ColormapPtr pColormap)
123605b261ecSmrg{
123705b261ecSmrg  winScreenPriv(pColormap->pScreen);
123805b261ecSmrg  winCmapPriv(pColormap);
123905b261ecSmrg
124005b261ecSmrg  /*
124105b261ecSmrg   * Is colormap to be destroyed the default?
124205b261ecSmrg   *
124305b261ecSmrg   * Non-default colormaps should have had winUninstallColormap
124405b261ecSmrg   * called on them before we get here.  The default colormap
124505b261ecSmrg   * will not have had winUninstallColormap called on it.  Thus,
124605b261ecSmrg   * we need to handle the default colormap in a special way.
124705b261ecSmrg   */
124805b261ecSmrg  if (pColormap->flags & IsDefault)
124905b261ecSmrg    {
125005b261ecSmrg#if CYGDEBUG
125105b261ecSmrg      winDebug ("winDestroyColormapShadowGDI - Destroying default "
125205b261ecSmrg	      "colormap\n");
125305b261ecSmrg#endif
125405b261ecSmrg
125505b261ecSmrg      /*
125605b261ecSmrg       * FIXME: Walk the list of all screens, popping the default
125705b261ecSmrg       * palette out of each screen device context.
125805b261ecSmrg       */
125905b261ecSmrg
126005b261ecSmrg      /* Pop the palette out of the device context */
126105b261ecSmrg      SelectPalette (pScreenPriv->hdcScreen,
126205b261ecSmrg		     GetStockObject (DEFAULT_PALETTE),
126305b261ecSmrg		     FALSE);
126405b261ecSmrg
126505b261ecSmrg      /* Clear our private installed colormap pointer */
126605b261ecSmrg      pScreenPriv->pcmapInstalled = NULL;
126705b261ecSmrg    }
126805b261ecSmrg
126905b261ecSmrg  /* Try to delete the logical palette */
127005b261ecSmrg  if (DeleteObject (pCmapPriv->hPalette) == 0)
127105b261ecSmrg    {
127205b261ecSmrg      ErrorF ("winDestroyColormap - DeleteObject () failed\n");
127305b261ecSmrg      return FALSE;
127405b261ecSmrg    }
127505b261ecSmrg
127605b261ecSmrg  /* Invalidate the colormap privates */
127705b261ecSmrg  pCmapPriv->hPalette = NULL;
127805b261ecSmrg
127905b261ecSmrg  return TRUE;
128005b261ecSmrg}
128105b261ecSmrg
128205b261ecSmrg
128305b261ecSmrg/*
128405b261ecSmrg * Set engine specific funtions
128505b261ecSmrg */
128605b261ecSmrg
128705b261ecSmrgBool
128805b261ecSmrgwinSetEngineFunctionsShadowGDI (ScreenPtr pScreen)
128905b261ecSmrg{
129005b261ecSmrg  winScreenPriv(pScreen);
129105b261ecSmrg  winScreenInfo		*pScreenInfo = pScreenPriv->pScreenInfo;
129205b261ecSmrg
129305b261ecSmrg  /* Set our pointers */
129405b261ecSmrg  pScreenPriv->pwinAllocateFB = winAllocateFBShadowGDI;
129505b261ecSmrg  pScreenPriv->pwinShadowUpdate = winShadowUpdateGDI;
129605b261ecSmrg  pScreenPriv->pwinCloseScreen = winCloseScreenShadowGDI;
129705b261ecSmrg  pScreenPriv->pwinInitVisuals = winInitVisualsShadowGDI;
129805b261ecSmrg  pScreenPriv->pwinAdjustVideoMode = winAdjustVideoModeShadowGDI;
129905b261ecSmrg  if (pScreenInfo->fFullScreen)
130005b261ecSmrg    pScreenPriv->pwinCreateBoundingWindow = winCreateBoundingWindowFullScreen;
130105b261ecSmrg  else
130205b261ecSmrg    pScreenPriv->pwinCreateBoundingWindow = winCreateBoundingWindowWindowed;
130305b261ecSmrg  pScreenPriv->pwinFinishScreenInit = winFinishScreenInitFB;
130405b261ecSmrg  pScreenPriv->pwinBltExposedRegions = winBltExposedRegionsShadowGDI;
130505b261ecSmrg  pScreenPriv->pwinActivateApp = winActivateAppShadowGDI;
130605b261ecSmrg  pScreenPriv->pwinRedrawScreen = winRedrawScreenShadowGDI;
130705b261ecSmrg  pScreenPriv->pwinRealizeInstalledPalette =
130805b261ecSmrg    winRealizeInstalledPaletteShadowGDI;
130905b261ecSmrg  pScreenPriv->pwinInstallColormap = winInstallColormapShadowGDI;
131005b261ecSmrg  pScreenPriv->pwinStoreColors = winStoreColorsShadowGDI;
131105b261ecSmrg  pScreenPriv->pwinCreateColormap = winCreateColormapShadowGDI;
131205b261ecSmrg  pScreenPriv->pwinDestroyColormap = winDestroyColormapShadowGDI;
131305b261ecSmrg  pScreenPriv->pwinHotKeyAltTab = (winHotKeyAltTabProcPtr) (void (*)(void))NoopDDA;
131405b261ecSmrg  pScreenPriv->pwinCreatePrimarySurface
131505b261ecSmrg    = (winCreatePrimarySurfaceProcPtr) (void (*)(void))NoopDDA;
131605b261ecSmrg  pScreenPriv->pwinReleasePrimarySurface
131705b261ecSmrg    = (winReleasePrimarySurfaceProcPtr) (void (*)(void))NoopDDA;
131805b261ecSmrg#ifdef XWIN_MULTIWINDOW
131905b261ecSmrg  pScreenPriv->pwinFinishCreateWindowsWindow =
132005b261ecSmrg    (winFinishCreateWindowsWindowProcPtr) (void (*)(void))NoopDDA;
132105b261ecSmrg#endif
132205b261ecSmrg
132305b261ecSmrg  return TRUE;
132405b261ecSmrg}
1325