#ifdef HAVE_XWIN_CONFIG_H
#include <xwin-config.h>
#endif
#include "win.h"
extern HWND g_hDlgExit;
static Bool
winAllocateFBNativeGDI (ScreenPtr pScreen);
static void
winShadowUpdateNativeGDI (ScreenPtr pScreen,
shadowBufPtr pBuf);
static Bool
winCloseScreenNativeGDI (int nIndex, ScreenPtr pScreen);
static Bool
winInitVisualsNativeGDI (ScreenPtr pScreen);
static Bool
winAdjustVideoModeNativeGDI (ScreenPtr pScreen);
#if 0
static Bool
winBltExposedRegionsNativeGDI (ScreenPtr pScreen);
#endif
static Bool
winActivateAppNativeGDI (ScreenPtr pScreen);
static Bool
winRedrawScreenNativeGDI (ScreenPtr pScreen);
static Bool
winRealizeInstalledPaletteNativeGDI (ScreenPtr pScreen);
static Bool
winInstallColormapNativeGDI (ColormapPtr pColormap);
static Bool
winStoreColorsNativeGDI (ColormapPtr pmap,
int ndef,
xColorItem *pdefs);
static Bool
winCreateColormapNativeGDI (ColormapPtr pColormap);
static Bool
winDestroyColormapNativeGDI (ColormapPtr pColormap);
static Bool
winAllocateFBNativeGDI (ScreenPtr pScreen)
{
FatalError ("winAllocateFBNativeGDI\n");
return TRUE;
}
static Bool
winCloseScreenNativeGDI (int nIndex, ScreenPtr pScreen)
{
winScreenPriv(pScreen);
winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
ErrorF ("winCloseScreenNativeGDI - Freeing screen resources\n");
pScreenPriv->fClosed = TRUE;
pScreenPriv->fActive = FALSE;
RemoveProp (pScreenPriv->hwndScreen, WIN_SCR_PROP);
ErrorF ("winCloseScreenNativeGDI - Destroying window\n");
if (!pScreenInfo->fNoTrayIcon)
winDeleteNotifyIcon (pScreenPriv);
if (g_hDlgExit != NULL)
{
DestroyWindow (g_hDlgExit);
g_hDlgExit = NULL;
}
if (pScreenPriv->hwndScreen)
{
DestroyWindow (pScreenPriv->hwndScreen);
pScreenPriv->hwndScreen = NULL;
}
pScreenInfo->pScreen = NULL;
free (pScreenPriv);
ErrorF ("winCloseScreenNativeGDI - Returning\n");
return TRUE;
}
static void
winShadowUpdateNativeGDI (ScreenPtr pScreen,
shadowBufPtr pBuf)
{
FatalError ("winShadowUpdateNativeGDI\n");
return;
}
static Bool
winInitVisualsNativeGDI (ScreenPtr pScreen)
{
winScreenPriv(pScreen);
winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
switch (pScreenInfo->dwDepth)
{
case 24:
pScreenPriv->dwBitsPerRGB = 8;
pScreenPriv->dwRedMask = 0x00FF0000;
pScreenPriv->dwGreenMask = 0x0000FF00;
pScreenPriv->dwBlueMask = 0x000000FF;
break;
case 16:
pScreenPriv->dwBitsPerRGB = 6;
pScreenPriv->dwRedMask = 0xF800;
pScreenPriv->dwGreenMask = 0x07E0;
pScreenPriv->dwBlueMask = 0x001F;
break;
case 15:
pScreenPriv->dwBitsPerRGB = 5;
pScreenPriv->dwRedMask = 0x7C00;
pScreenPriv->dwGreenMask = 0x03E0;
pScreenPriv->dwBlueMask = 0x001F;
break;
case 8:
pScreenPriv->dwBitsPerRGB = 8;
pScreenPriv->dwRedMask = 0;
pScreenPriv->dwGreenMask = 0;
pScreenPriv->dwBlueMask = 0;
break;
default:
ErrorF ("winInitVisualsNativeGDI - Unknown screen depth\n");
return FALSE;
break;
}
ErrorF ("winInitVisualsNativeGDI - Using dwBitsPerRGB: %d\n",
(int) pScreenPriv->dwBitsPerRGB);
switch (pScreenInfo->dwDepth)
{
case 24:
case 16:
case 15:
if (!miSetVisualTypesAndMasks (pScreenInfo->dwDepth,
TrueColorMask,
pScreenPriv->dwBitsPerRGB,
TrueColor,
pScreenPriv->dwRedMask,
pScreenPriv->dwGreenMask,
pScreenPriv->dwBlueMask))
{
ErrorF ("winInitVisuals - miSetVisualTypesAndMasks failed\n");
return FALSE;
}
break;
case 8:
ErrorF ("winInitVisuals - Calling miSetVisualTypesAndMasks\n");
if (!miSetVisualTypesAndMasks (pScreenInfo->dwDepth,
StaticColorMask,
pScreenPriv->dwBitsPerRGB,
StaticColor,
pScreenPriv->dwRedMask,
pScreenPriv->dwGreenMask,
pScreenPriv->dwBlueMask))
{
ErrorF ("winInitVisuals - miSetVisualTypesAndMasks failed\n");
return FALSE;
}
break;
default:
ErrorF ("winInitVisualsNativeGDI - Unknown screen depth\n");
return FALSE;
}
#if 1
ErrorF ("winInitVisualsNativeGDI - Returning\n");
#endif
return TRUE;
}
static Bool
winAdjustVideoModeNativeGDI (ScreenPtr pScreen)
{
winScreenPriv(pScreen);
winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
HDC hdc = NULL;
DWORD dwBPP;
hdc = GetDC (NULL);
if (hdc == NULL)
{
ErrorF ("winAdjustVideoModeNativeGDI - GetDC () failed\n");
return FALSE;
}
dwBPP = GetDeviceCaps (hdc, BITSPIXEL);
pScreenInfo->dwDepth = GetDeviceCaps (hdc, PLANES);
switch (pScreenInfo->dwDepth) {
case 24:
case 16:
case 15:
case 8:
break;
default:
if (dwBPP == 32)
pScreenInfo->dwDepth = 24;
else
pScreenInfo->dwDepth = dwBPP;
break;
}
if (pScreenInfo->dwBPP == WIN_DEFAULT_BPP)
{
ErrorF ("winAdjustVideoModeNativeGDI - Using Windows display "
"depth of %d bits per pixel, %d depth\n",
(int) dwBPP, (int) pScreenInfo->dwDepth);
pScreenInfo->dwBPP = dwBPP;
}
else if (dwBPP != pScreenInfo->dwBPP)
{
ErrorF ("winAdjustVideoModeNativeGDI - Command line bpp: %d, "\
"using bpp: %d\n",
(int) pScreenInfo->dwBPP, (int) dwBPP);
pScreenInfo->dwBPP = dwBPP;
}
ReleaseDC (NULL, hdc);
return TRUE;
}
static Bool
winActivateAppNativeGDI (ScreenPtr pScreen)
{
winScreenPriv(pScreen);
winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
if (pScreenPriv != NULL
&& pScreenPriv->fActive
&& pScreenInfo->fFullScreen)
{
ShowWindow (pScreenPriv->hwndScreen, SW_RESTORE);
}
if (pScreenPriv != NULL
&& !pScreenPriv->fActive
&& pScreenInfo->fFullScreen)
{
ShowWindow (pScreenPriv->hwndScreen, SW_MINIMIZE);
}
return TRUE;
}
HBITMAP
winCreateDIBNativeGDI (int iWidth, int iHeight, int iDepth,
BYTE **ppbBits, BITMAPINFO **ppbmi)
{
BITMAPINFOHEADER *pbmih = NULL;
HBITMAP hBitmap = NULL;
BITMAPINFO *pbmi = NULL;
if (iWidth == 0
|| iHeight == 0
|| iDepth == 0)
{
ErrorF ("\nwinCreateDIBNativeGDI - Invalid specs w %d h %d d %d\n\n",
iWidth, iHeight, iDepth);
return NULL;
}
pbmih = (BITMAPINFOHEADER*) malloc (sizeof (BITMAPINFOHEADER)
+ 256 * sizeof (RGBQUAD));
if (pbmih == NULL)
{
ErrorF ("winCreateDIBNativeGDI - malloc () failed\n");
return FALSE;
}
ZeroMemory (pbmih, sizeof(BITMAPINFOHEADER) + 256 * sizeof (RGBQUAD));
pbmih->biSize = sizeof (BITMAPINFOHEADER);
pbmih->biWidth = iWidth;
pbmih->biHeight = -iHeight;
pbmih->biPlanes = 1;
pbmih->biBitCount = iDepth;
pbmih->biCompression = BI_RGB;
pbmih->biSizeImage = 0;
pbmih->biXPelsPerMeter = 0;
pbmih->biYPelsPerMeter = 0;
pbmih->biClrUsed = 0;
pbmih->biClrImportant = 0;
if (iDepth == 1)
{
pbmi = (BITMAPINFO*) pbmih;
pbmi->bmiColors[1].rgbBlue = 255;
pbmi->bmiColors[1].rgbGreen = 255;
pbmi->bmiColors[1].rgbRed = 255;
}
hBitmap = CreateDIBSection (NULL,
(BITMAPINFO *) pbmih,
DIB_RGB_COLORS,
(void **) ppbBits,
NULL,
0);
if (hBitmap == NULL)
{
ErrorF ("winCreateDIBNativeGDI - CreateDIBSection () failed\n");
return NULL;
}
if (ppbmi != NULL)
{
*ppbmi = (BITMAPINFO *) pbmih;
}
else
{
free (pbmih);
pbmih = NULL;
}
return hBitmap;
}
#if 0
static Bool
winBltExposedRegionsNativeGDI (ScreenPtr pScreen)
{
return TRUE;
}
#endif
static Bool
winRedrawScreenNativeGDI (ScreenPtr pScreen)
{
FatalError ("winRedrawScreenNativeGDI\n");
return TRUE;
}
static Bool
winRealizeInstalledPaletteNativeGDI (ScreenPtr pScreen)
{
FatalError ("winRealizeInstalledPaletteNativeGDI\n");
return TRUE;
}
static Bool
winInstallColormapNativeGDI (ColormapPtr pColormap)
{
FatalError ("winInstallColormapNativeGDI\n");
return TRUE;
}
static Bool
winStoreColorsNativeGDI (ColormapPtr pmap,
int ndef,
xColorItem *pdefs)
{
FatalError ("winStoreColorsNativeGDI\n");
return TRUE;
}
static Bool
winCreateColormapNativeGDI (ColormapPtr pColormap)
{
FatalError ("winCreateColormapNativeGDI\n");
return TRUE;
}
static Bool
winDestroyColormapNativeGDI (ColormapPtr pColormap)
{
FatalError ("winDestroyColormapNativeGDI\n");
return TRUE;
}
Bool
winSetEngineFunctionsNativeGDI (ScreenPtr pScreen)
{
winScreenPriv(pScreen);
winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
pScreenPriv->pwinAllocateFB = winAllocateFBNativeGDI;
pScreenPriv->pwinShadowUpdate = winShadowUpdateNativeGDI;
pScreenPriv->pwinCloseScreen = winCloseScreenNativeGDI;
pScreenPriv->pwinInitVisuals = winInitVisualsNativeGDI;
pScreenPriv->pwinAdjustVideoMode = winAdjustVideoModeNativeGDI;
if (pScreenInfo->fFullScreen)
pScreenPriv->pwinCreateBoundingWindow = winCreateBoundingWindowFullScreen;
else
pScreenPriv->pwinCreateBoundingWindow = winCreateBoundingWindowWindowed;
pScreenPriv->pwinFinishScreenInit = winFinishScreenInitNativeGDI;
pScreenPriv->pwinBltExposedRegions = NULL;
pScreenPriv->pwinActivateApp = winActivateAppNativeGDI;
pScreenPriv->pwinRedrawScreen = winRedrawScreenNativeGDI;
pScreenPriv->pwinRealizeInstalledPalette =
winRealizeInstalledPaletteNativeGDI;
pScreenPriv->pwinInstallColormap = winInstallColormapNativeGDI;
pScreenPriv->pwinStoreColors = winStoreColorsNativeGDI;
pScreenPriv->pwinCreateColormap = winCreateColormapNativeGDI;
pScreenPriv->pwinDestroyColormap = winDestroyColormapNativeGDI;
pScreenPriv->pwinHotKeyAltTab = (winHotKeyAltTabProcPtr) (void (*)(void))NoopDDA;
return TRUE;
}