2001-02-14 01:27:34 +01:00
|
|
|
/*
|
|
|
|
* DirectDraw driver interface
|
|
|
|
*
|
|
|
|
* Copyright 2001 TransGaming Technologies, Inc.
|
2002-03-10 00:29:33 +01:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2001-02-14 01:27:34 +01:00
|
|
|
*/
|
|
|
|
|
2001-04-25 21:54:21 +02:00
|
|
|
#include "config.h"
|
|
|
|
|
2001-03-22 20:33:57 +01:00
|
|
|
#include <string.h>
|
2003-11-21 22:50:59 +01:00
|
|
|
#include <X11/Xlib.h>
|
2001-04-25 21:54:21 +02:00
|
|
|
|
2003-01-07 21:36:20 +01:00
|
|
|
#define NONAMELESSUNION
|
|
|
|
#define NONAMELESSSTRUCT
|
2001-03-20 02:24:08 +01:00
|
|
|
#include "x11drv.h"
|
|
|
|
#include "x11ddraw.h"
|
2001-04-16 21:54:07 +02:00
|
|
|
#include "dga2.h"
|
2001-03-20 02:24:08 +01:00
|
|
|
|
2001-02-14 01:27:34 +01:00
|
|
|
#include "windef.h"
|
2004-03-04 21:41:12 +01:00
|
|
|
#include "gdi.h"
|
2002-03-10 00:29:33 +01:00
|
|
|
#include "wine/debug.h"
|
2001-02-14 01:27:34 +01:00
|
|
|
|
2002-03-10 00:29:33 +01:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(x11drv);
|
2001-02-14 01:27:34 +01:00
|
|
|
|
2001-04-27 20:00:06 +02:00
|
|
|
extern int dxgrab;
|
|
|
|
|
2001-03-20 02:24:08 +01:00
|
|
|
LPDDRAWI_DDRAWSURFACE_LCL X11DRV_DD_Primary;
|
|
|
|
LPDDRAWI_DDRAWSURFACE_GBL X11DRV_DD_PrimaryGbl;
|
2001-04-16 21:54:07 +02:00
|
|
|
HWND X11DRV_DD_PrimaryWnd;
|
2001-03-20 02:24:08 +01:00
|
|
|
HBITMAP X11DRV_DD_PrimaryDIB;
|
|
|
|
Drawable X11DRV_DD_PrimaryDrawable;
|
|
|
|
ATOM X11DRV_DD_UserClass;
|
|
|
|
BOOL X11DRV_DD_IsDirect;
|
2001-08-06 20:47:25 +02:00
|
|
|
static UINT X11DRV_DD_GrabMessage;
|
|
|
|
static WNDPROC X11DRV_DD_GrabOldProcedure;
|
2001-03-20 02:24:08 +01:00
|
|
|
|
|
|
|
static void SetPrimaryDIB(HBITMAP hBmp)
|
|
|
|
{
|
|
|
|
X11DRV_DD_PrimaryDIB = hBmp;
|
|
|
|
if (hBmp) {
|
2005-03-27 20:30:51 +02:00
|
|
|
X11DRV_DD_PrimaryDrawable = X11DRV_get_pixmap( hBmp );
|
2001-03-20 02:24:08 +01:00
|
|
|
} else {
|
|
|
|
X11DRV_DD_PrimaryDrawable = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
static LRESULT WINAPI GrabWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
2005-03-21 13:37:00 +01:00
|
|
|
struct x11drv_thread_data *data = x11drv_thread_data();
|
2001-08-06 20:47:25 +02:00
|
|
|
|
|
|
|
if(message != X11DRV_DD_GrabMessage)
|
|
|
|
return CallWindowProcA(X11DRV_DD_GrabOldProcedure, hWnd, message, wParam, lParam);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2002-10-31 03:38:20 +01:00
|
|
|
TRACE("hwnd=%p, grab=%d\n", hWnd, wParam);
|
2001-08-06 20:47:25 +02:00
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
if (wParam)
|
|
|
|
{
|
|
|
|
/* find the X11 window that ddraw uses */
|
|
|
|
Window win = X11DRV_get_whole_window(hWnd);
|
|
|
|
TRACE("X11 window: %ld\n", win);
|
|
|
|
if (!win) {
|
|
|
|
TRACE("host off desktop\n");
|
|
|
|
win = root_window;
|
|
|
|
}
|
|
|
|
|
2003-11-21 01:17:33 +01:00
|
|
|
wine_tsx11_lock();
|
2005-03-21 13:37:00 +01:00
|
|
|
XGrabPointer(data->display, win, True, 0, GrabModeAsync, GrabModeAsync, win, None, CurrentTime);
|
2003-11-21 01:17:33 +01:00
|
|
|
wine_tsx11_unlock();
|
2005-03-21 13:37:00 +01:00
|
|
|
data->grab_window = win;
|
2002-06-01 01:06:46 +02:00
|
|
|
}
|
|
|
|
else
|
2001-08-06 20:47:25 +02:00
|
|
|
{
|
2003-11-21 01:17:33 +01:00
|
|
|
wine_tsx11_lock();
|
2005-03-21 13:37:00 +01:00
|
|
|
XUngrabPointer(data->display, CurrentTime);
|
2003-11-21 01:17:33 +01:00
|
|
|
wine_tsx11_unlock();
|
2005-03-21 13:37:00 +01:00
|
|
|
data->grab_window = None;
|
2002-06-01 01:06:46 +02:00
|
|
|
}
|
2001-08-06 20:47:25 +02:00
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
return 0;
|
|
|
|
}
|
2001-08-06 20:47:25 +02:00
|
|
|
|
|
|
|
static void GrabPointer(BOOL grab)
|
|
|
|
{
|
2002-06-01 01:06:46 +02:00
|
|
|
if(grab) {
|
|
|
|
Window window = X11DRV_get_whole_window(GetFocus());
|
2001-08-06 20:47:25 +02:00
|
|
|
if(window)
|
2005-03-21 13:37:00 +01:00
|
|
|
{
|
|
|
|
wine_tsx11_lock();
|
2002-06-01 01:06:46 +02:00
|
|
|
XSetInputFocus(thread_display(), window, RevertToParent, CurrentTime);
|
2005-03-21 13:37:00 +01:00
|
|
|
wine_tsx11_unlock();
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
}
|
2001-08-06 20:47:25 +02:00
|
|
|
|
|
|
|
if(!X11DRV_DD_GrabMessage)
|
|
|
|
X11DRV_DD_GrabMessage = RegisterWindowMessageA("WINE_X11DRV_GRABPOINTER");
|
|
|
|
|
2004-09-22 21:14:08 +02:00
|
|
|
X11DRV_DD_GrabOldProcedure = (WNDPROC)SetWindowLongPtrA(X11DRV_DD_PrimaryWnd,
|
|
|
|
GWLP_WNDPROC, (LONG_PTR)GrabWndProc);
|
2001-08-06 20:47:25 +02:00
|
|
|
|
2005-03-21 13:37:00 +01:00
|
|
|
SendMessageW(X11DRV_DD_PrimaryWnd, X11DRV_DD_GrabMessage, grab, 0);
|
2001-08-06 20:47:25 +02:00
|
|
|
|
2004-09-22 21:14:08 +02:00
|
|
|
if(SetWindowLongPtrA(X11DRV_DD_PrimaryWnd, GWLP_WNDPROC,
|
|
|
|
(LONG_PTR)X11DRV_DD_GrabOldProcedure) != (LONG_PTR)GrabWndProc)
|
2001-08-06 20:47:25 +02:00
|
|
|
ERR("Window procedure has been changed!\n");
|
2001-04-27 20:00:06 +02:00
|
|
|
}
|
|
|
|
|
2001-02-14 01:27:34 +01:00
|
|
|
static DWORD PASCAL X11DRV_DDHAL_DestroyDriver(LPDDHAL_DESTROYDRIVERDATA data)
|
|
|
|
{
|
|
|
|
data->ddRVal = DD_OK;
|
|
|
|
return DDHAL_DRIVER_HANDLED;
|
|
|
|
}
|
|
|
|
|
2001-03-20 02:24:08 +01:00
|
|
|
static DWORD PASCAL X11DRV_DDHAL_CreateSurface(LPDDHAL_CREATESURFACEDATA data)
|
2001-02-14 01:27:34 +01:00
|
|
|
{
|
2001-03-20 02:24:08 +01:00
|
|
|
if (data->lpDDSurfaceDesc->ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE) {
|
|
|
|
X11DRV_DD_Primary = *data->lplpSList;
|
2001-04-16 21:54:07 +02:00
|
|
|
X11DRV_DD_PrimaryWnd = (HWND)X11DRV_DD_Primary->lpSurfMore->lpDDRAWReserved;
|
2001-03-20 02:24:08 +01:00
|
|
|
X11DRV_DD_PrimaryGbl = X11DRV_DD_Primary->lpGbl;
|
2002-10-31 03:12:18 +01:00
|
|
|
SetPrimaryDIB((HBITMAP)GET_LPDDRAWSURFACE_GBL_MORE(X11DRV_DD_PrimaryGbl)->hKernelSurface);
|
2001-03-20 02:24:08 +01:00
|
|
|
X11DRV_DD_UserClass = GlobalFindAtomA("WINE_DDRAW");
|
2001-08-06 20:47:25 +02:00
|
|
|
if (dxgrab) GrabPointer(TRUE);
|
2001-02-14 01:27:34 +01:00
|
|
|
}
|
2001-03-20 02:24:08 +01:00
|
|
|
data->ddRVal = DD_OK;
|
2001-02-14 01:27:34 +01:00
|
|
|
return DDHAL_DRIVER_NOTHANDLED;
|
|
|
|
}
|
|
|
|
|
2001-03-20 02:24:08 +01:00
|
|
|
static DWORD PASCAL X11DRV_DDHAL_CreatePalette(LPDDHAL_CREATEPALETTEDATA data)
|
|
|
|
{
|
|
|
|
FIXME("stub\n");
|
|
|
|
/* only makes sense to do anything if the X server is running at 8bpp,
|
|
|
|
* which few people do nowadays */
|
|
|
|
data->ddRVal = DD_OK;
|
|
|
|
return DDHAL_DRIVER_HANDLED;
|
|
|
|
}
|
|
|
|
|
2001-02-14 01:27:34 +01:00
|
|
|
static DDHAL_DDCALLBACKS hal_ddcallbacks = {
|
|
|
|
sizeof(DDHAL_DDCALLBACKS),
|
|
|
|
0x3ff, /* all callbacks are 32-bit */
|
|
|
|
X11DRV_DDHAL_DestroyDriver,
|
2001-03-20 02:24:08 +01:00
|
|
|
X11DRV_DDHAL_CreateSurface,
|
2001-02-14 01:27:34 +01:00
|
|
|
NULL, /* SetColorKey */
|
2001-03-20 02:24:08 +01:00
|
|
|
NULL, /* SetMode */
|
2001-02-14 01:27:34 +01:00
|
|
|
NULL, /* WaitForVerticalBlank */
|
|
|
|
NULL, /* CanCreateSurface */
|
2001-03-20 02:24:08 +01:00
|
|
|
X11DRV_DDHAL_CreatePalette,
|
2001-02-14 01:27:34 +01:00
|
|
|
NULL, /* GetScanLine */
|
|
|
|
NULL, /* SetExclusiveMode */
|
|
|
|
NULL /* FlipToGDISurface */
|
|
|
|
};
|
|
|
|
|
2001-03-20 02:24:08 +01:00
|
|
|
static DWORD PASCAL X11DRV_DDHAL_DestroySurface(LPDDHAL_DESTROYSURFACEDATA data)
|
|
|
|
{
|
|
|
|
if (data->lpDDSurface == X11DRV_DD_Primary) {
|
2001-08-06 20:47:25 +02:00
|
|
|
if (dxgrab) GrabPointer(FALSE);
|
2001-03-20 02:24:08 +01:00
|
|
|
X11DRV_DD_Primary = NULL;
|
2001-04-16 21:54:07 +02:00
|
|
|
X11DRV_DD_PrimaryWnd = 0;
|
2001-03-20 02:24:08 +01:00
|
|
|
X11DRV_DD_PrimaryGbl = NULL;
|
|
|
|
SetPrimaryDIB(0);
|
|
|
|
X11DRV_DD_UserClass = 0;
|
|
|
|
}
|
|
|
|
data->ddRVal = DD_OK;
|
|
|
|
return DDHAL_DRIVER_HANDLED;
|
|
|
|
}
|
|
|
|
|
|
|
|
static DWORD PASCAL X11DRV_DDHAL_SetPalette(LPDDHAL_SETPALETTEDATA data)
|
|
|
|
{
|
2002-02-26 01:36:21 +01:00
|
|
|
if (data->lpDDPalette && data->lpDDPalette->u1.dwReserved1) {
|
2001-03-20 02:24:08 +01:00
|
|
|
if (data->lpDDSurface == X11DRV_DD_Primary) {
|
|
|
|
FIXME("stub\n");
|
|
|
|
/* we should probably find the ddraw window (maybe data->lpDD->lpExclusiveOwner->hWnd),
|
2002-02-26 01:36:21 +01:00
|
|
|
* and attach the palette to it
|
|
|
|
*
|
|
|
|
* Colormap pal = data->lpDDPalette->u1.dwReserved1;
|
|
|
|
*/
|
2001-03-20 02:24:08 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
data->ddRVal = DD_OK;
|
|
|
|
return DDHAL_DRIVER_HANDLED;
|
|
|
|
}
|
|
|
|
|
|
|
|
static DDHAL_DDSURFACECALLBACKS hal_ddsurfcallbacks = {
|
|
|
|
sizeof(DDHAL_DDSURFACECALLBACKS),
|
|
|
|
0x3fff, /* all callbacks are 32-bit */
|
|
|
|
X11DRV_DDHAL_DestroySurface,
|
|
|
|
NULL, /* Flip */
|
|
|
|
NULL, /* SetClipList */
|
|
|
|
NULL, /* Lock */
|
|
|
|
NULL, /* Unlock */
|
|
|
|
NULL, /* Blt */
|
|
|
|
NULL, /* SetColorKey */
|
|
|
|
NULL, /* AddAttachedSurface */
|
|
|
|
NULL, /* GetBltStatus */
|
|
|
|
NULL, /* GetFlipStatus */
|
|
|
|
NULL, /* UpdateOverlay */
|
|
|
|
NULL, /* SetOverlayPosition */
|
|
|
|
NULL, /* reserved4 */
|
|
|
|
X11DRV_DDHAL_SetPalette
|
|
|
|
};
|
|
|
|
|
|
|
|
static DWORD PASCAL X11DRV_DDHAL_DestroyPalette(LPDDHAL_DESTROYPALETTEDATA data)
|
|
|
|
{
|
|
|
|
Colormap pal = data->lpDDPalette->u1.dwReserved1;
|
2003-11-21 01:17:33 +01:00
|
|
|
if (pal)
|
|
|
|
{
|
|
|
|
wine_tsx11_lock();
|
|
|
|
XFreeColormap(gdi_display, pal);
|
|
|
|
wine_tsx11_unlock();
|
|
|
|
}
|
2001-03-20 02:24:08 +01:00
|
|
|
data->ddRVal = DD_OK;
|
|
|
|
return DDHAL_DRIVER_HANDLED;
|
|
|
|
}
|
|
|
|
|
|
|
|
static DWORD PASCAL X11DRV_DDHAL_SetPaletteEntries(LPDDHAL_SETENTRIESDATA data)
|
|
|
|
{
|
|
|
|
X11DRV_DDHAL_SetPalEntries(data->lpDDPalette->u1.dwReserved1,
|
|
|
|
data->dwBase, data->dwNumEntries,
|
|
|
|
data->lpEntries);
|
|
|
|
data->ddRVal = DD_OK;
|
|
|
|
return DDHAL_DRIVER_HANDLED;
|
|
|
|
}
|
|
|
|
|
|
|
|
static DDHAL_DDPALETTECALLBACKS hal_ddpalcallbacks = {
|
|
|
|
sizeof(DDHAL_DDPALETTECALLBACKS),
|
|
|
|
0x3, /* all callbacks are 32-bit */
|
|
|
|
X11DRV_DDHAL_DestroyPalette,
|
|
|
|
X11DRV_DDHAL_SetPaletteEntries
|
|
|
|
};
|
|
|
|
|
2001-04-16 21:54:07 +02:00
|
|
|
static X11DEVICE x11device = {
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
|
|
|
static DWORD PASCAL X11DRV_DDHAL_GetDriverInfo(LPDDHAL_GETDRIVERINFODATA data)
|
|
|
|
{
|
|
|
|
LPX11DRIVERINFO info = x11device.lpInfo;
|
|
|
|
while (info) {
|
|
|
|
if (IsEqualGUID(&data->guidInfo, info->lpGuid)) {
|
|
|
|
DWORD dwSize = info->dwSize;
|
|
|
|
data->dwActualSize = dwSize;
|
|
|
|
if (data->dwExpectedSize < dwSize) dwSize = data->dwExpectedSize;
|
|
|
|
memcpy(data->lpvData, info->lpvData, dwSize);
|
|
|
|
data->ddRVal = DD_OK;
|
|
|
|
return DDHAL_DRIVER_HANDLED;
|
|
|
|
}
|
|
|
|
info = info->lpNext;
|
|
|
|
}
|
|
|
|
data->ddRVal = DDERR_CURRENTLYNOTAVAIL;
|
|
|
|
return DDHAL_DRIVER_HANDLED;
|
|
|
|
}
|
|
|
|
|
2001-02-14 01:27:34 +01:00
|
|
|
static DDHALINFO hal_info = {
|
|
|
|
sizeof(DDHALINFO),
|
|
|
|
&hal_ddcallbacks,
|
2001-03-20 02:24:08 +01:00
|
|
|
&hal_ddsurfcallbacks,
|
|
|
|
&hal_ddpalcallbacks,
|
|
|
|
{ /* vmiData */
|
|
|
|
0 /* fpPrimary */
|
|
|
|
},
|
2001-04-16 21:54:07 +02:00
|
|
|
{ /* ddCaps (only stuff the HAL implements here) */
|
|
|
|
sizeof(DDCORECAPS), /* dwSize */
|
|
|
|
DDCAPS_GDI | DDCAPS_PALETTE, /* dwCaps */
|
2002-11-30 02:53:13 +01:00
|
|
|
DDCAPS2_CERTIFIED | DDCAPS2_NONLOCALVIDMEM | DDCAPS2_NOPAGELOCKREQUIRED | DDCAPS2_CANRENDERWINDOWED |
|
2001-04-16 21:54:07 +02:00
|
|
|
DDCAPS2_WIDESURFACES | DDCAPS2_PRIMARYGAMMA | DDCAPS2_FLIPNOVSYNC, /* dwCaps2 */
|
|
|
|
0, /* dwCKeyCaps */
|
|
|
|
0, /* dwFXCaps */
|
|
|
|
0, /* dwFXAlphaCaps */
|
|
|
|
DDPCAPS_8BIT | DDPCAPS_PRIMARYSURFACE, /* dwPalCaps */
|
|
|
|
0, /* dwSVCaps */
|
|
|
|
0, /* dwAlphaBltConstBitDepths */
|
|
|
|
0, /* dwAlphaBltPixelBitDepths */
|
|
|
|
0, /* dwAlphaBltSurfaceBitDepths */
|
|
|
|
0, /* dwAlphaOverlayBltConstBitDepths */
|
|
|
|
0, /* dwAlphaOverlayBltPixelBitDepths */
|
|
|
|
0, /* dwAlphaOverlayBltSurfaceBitDepths */
|
|
|
|
0, /* dwZBufferBitDepths */
|
|
|
|
16*1024*1024, /* dwVidMemTotal */
|
|
|
|
16*1024*1024, /* dwVidMemFree */
|
|
|
|
0, /* dwMaxVisibleOverlays */
|
|
|
|
0, /* dwCurrVisibleOverlays */
|
|
|
|
0, /* dwNumFourCCCodes */
|
|
|
|
0, /* dwAlignBoundarySrc */
|
|
|
|
0, /* dwAlignSizeSrc */
|
|
|
|
0, /* dwAlignBoundaryDest */
|
|
|
|
0, /* dwAlignSizeDest */
|
|
|
|
0, /* dwAlignStrideAlign */
|
|
|
|
{0}, /* dwRops */
|
|
|
|
{ /* ddsCaps */
|
|
|
|
DDSCAPS_BACKBUFFER | DDSCAPS_FLIP | DDSCAPS_FRONTBUFFER |
|
|
|
|
DDSCAPS_OFFSCREENPLAIN | DDSCAPS_PALETTE | DDSCAPS_PRIMARYSURFACE |
|
|
|
|
DDSCAPS_SYSTEMMEMORY | DDSCAPS_TEXTURE | DDSCAPS_VIDEOMEMORY |
|
|
|
|
DDSCAPS_VISIBLE | DDSCAPS_LOCALVIDMEM | DDSCAPS_NONLOCALVIDMEM /* dwCaps */
|
|
|
|
},
|
|
|
|
0, /* dwMinOverlayStretch */
|
|
|
|
0, /* dwMaxOverlayStretch */
|
|
|
|
0, /* dwMinLiveVideoStretch */
|
|
|
|
0, /* dwMaxLiveVideoStretch */
|
|
|
|
0, /* dwMinHwCodecStretch */
|
|
|
|
0, /* dwMaxHwCodecStretch */
|
|
|
|
0, /* dwReserved1 */
|
|
|
|
0, /* dwReserved2 */
|
|
|
|
0, /* dwReserved2 */
|
|
|
|
0, /* dwSVBCaps */
|
|
|
|
0, /* dwSVBCKeyCaps */
|
|
|
|
0, /* dwSVBFXCaps */
|
|
|
|
{0}, /* dwSVBRops */
|
|
|
|
0, /* dwVSBCaps */
|
|
|
|
0, /* dwVSBCKeyCaps */
|
|
|
|
0, /* dwVSBFXCaps */
|
|
|
|
{0}, /* dwVSBRops */
|
|
|
|
0, /* dwSSBCaps */
|
|
|
|
0, /* dwSSBCKeyCaps */
|
|
|
|
0, /* dwSSBFXCaps */
|
|
|
|
{0}, /* dwSSBRops */
|
|
|
|
0, /* dwMaxVideoPorts */
|
|
|
|
0, /* dwCurrVideoPorts */
|
|
|
|
0 /* dwSVBCaps */
|
2001-03-20 02:24:08 +01:00
|
|
|
},
|
|
|
|
0, /* dwMonitorFrequency */
|
2001-04-16 21:54:07 +02:00
|
|
|
X11DRV_DDHAL_GetDriverInfo,
|
2001-03-20 02:24:08 +01:00
|
|
|
0, /* dwModeIndex */
|
|
|
|
NULL, /* lpdwFourCC */
|
|
|
|
0, /* dwNumModes */
|
|
|
|
NULL, /* lpModeInfo */
|
2001-04-16 21:54:07 +02:00
|
|
|
DDHALINFO_ISPRIMARYDISPLAY | DDHALINFO_MODEXILLEGAL | DDHALINFO_GETDRIVERINFOSET, /* dwFlags */
|
|
|
|
&x11device,
|
|
|
|
0, /* hInstance */
|
|
|
|
0, /* lpD3DGlobalDriverData */
|
|
|
|
0, /* lpD3DHALCallbacks */
|
|
|
|
NULL /* lpDDExeBufCallbacks */
|
2001-02-14 01:27:34 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
static LPDDHALDDRAWFNS ddraw_fns;
|
|
|
|
static DWORD ddraw_ver;
|
|
|
|
|
2001-03-20 02:24:08 +01:00
|
|
|
static void X11DRV_DDHAL_SetInfo(void)
|
|
|
|
{
|
|
|
|
(ddraw_fns->lpSetInfo)(&hal_info, FALSE);
|
|
|
|
}
|
|
|
|
|
2001-07-29 22:25:14 +02:00
|
|
|
INT X11DRV_DCICommand(INT cbInput, const DCICMD *lpCmd, LPVOID lpOutData)
|
2001-02-14 01:27:34 +01:00
|
|
|
{
|
|
|
|
TRACE("(%d,(%ld,%ld,%ld),%p)\n", cbInput, lpCmd->dwCommand,
|
|
|
|
lpCmd->dwParam1, lpCmd->dwParam2, lpOutData);
|
|
|
|
|
|
|
|
switch (lpCmd->dwCommand) {
|
|
|
|
case DDNEWCALLBACKFNS:
|
|
|
|
ddraw_fns = (LPDDHALDDRAWFNS)lpCmd->dwParam1;
|
|
|
|
return TRUE;
|
|
|
|
case DDVERSIONINFO:
|
|
|
|
{
|
|
|
|
LPDDVERSIONDATA lpVer = (LPDDVERSIONDATA)lpOutData;
|
|
|
|
ddraw_ver = lpCmd->dwParam1;
|
|
|
|
if (!lpVer) break;
|
|
|
|
/* well, whatever... the DDK says so */
|
|
|
|
lpVer->dwHALVersion = DD_RUNTIME_VERSION;
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
case DDGET32BITDRIVERNAME:
|
|
|
|
{
|
|
|
|
LPDD32BITDRIVERDATA lpData = (LPDD32BITDRIVERDATA)lpOutData;
|
|
|
|
/* here, we could ask ddraw to load a separate DLL, that
|
|
|
|
* would contain the 32-bit ddraw HAL */
|
|
|
|
strcpy(lpData->szName,"x11drv");
|
|
|
|
/* the entry point named here should initialize our hal_info
|
2001-03-20 02:24:08 +01:00
|
|
|
* with 32-bit entry points (ignored for now) */
|
2001-02-14 01:27:34 +01:00
|
|
|
strcpy(lpData->szEntryPoint,"DriverInit");
|
|
|
|
lpData->dwContext = 0;
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
case DDCREATEDRIVEROBJECT:
|
|
|
|
{
|
|
|
|
LPDWORD lpInstance = (LPDWORD)lpOutData;
|
|
|
|
|
2001-03-20 02:24:08 +01:00
|
|
|
/* FIXME: get x11drv's hInstance */
|
|
|
|
#ifdef HAVE_LIBXXF86DGA2
|
2001-04-16 21:54:07 +02:00
|
|
|
if (!X11DRV_XF86DGA2_CreateDriver(&hal_info))
|
2001-03-20 02:24:08 +01:00
|
|
|
#endif
|
|
|
|
{
|
2003-10-16 02:21:42 +02:00
|
|
|
X11DRV_Settings_CreateDriver(&hal_info);
|
2001-03-20 02:24:08 +01:00
|
|
|
}
|
2001-04-16 21:54:07 +02:00
|
|
|
#ifdef HAVE_OPENGL
|
|
|
|
/*X11DRV_GLX_CreateDriver(&hal_info);*/
|
|
|
|
#endif
|
2001-02-14 01:27:34 +01:00
|
|
|
|
|
|
|
(ddraw_fns->lpSetInfo)(&hal_info, FALSE);
|
|
|
|
*lpInstance = hal_info.hInstance;
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
2001-03-20 02:24:08 +01:00
|
|
|
|
2001-04-16 21:54:07 +02:00
|
|
|
void X11DRV_DDHAL_SwitchMode(DWORD dwModeIndex, LPVOID fb_addr, LPVIDMEM fb_mem)
|
2001-03-20 02:24:08 +01:00
|
|
|
{
|
|
|
|
LPDDHALMODEINFO info = &hal_info.lpModeInfo[dwModeIndex];
|
|
|
|
|
|
|
|
hal_info.dwModeIndex = dwModeIndex;
|
|
|
|
hal_info.dwMonitorFrequency = info->wRefreshRate;
|
|
|
|
hal_info.vmiData.fpPrimary = (FLATPTR)fb_addr;
|
|
|
|
hal_info.vmiData.dwDisplayWidth = info->dwWidth;
|
|
|
|
hal_info.vmiData.dwDisplayHeight = info->dwHeight;
|
|
|
|
hal_info.vmiData.lDisplayPitch = info->lPitch;
|
|
|
|
hal_info.vmiData.ddpfDisplay.dwSize = info->dwBPP ? sizeof(hal_info.vmiData.ddpfDisplay) : 0;
|
|
|
|
hal_info.vmiData.ddpfDisplay.dwFlags = (info->wFlags & DDMODEINFO_PALETTIZED) ? DDPF_PALETTEINDEXED8 : 0;
|
|
|
|
hal_info.vmiData.ddpfDisplay.u1.dwRGBBitCount = (info->dwBPP > 24) ? 24 : info->dwBPP;
|
|
|
|
hal_info.vmiData.ddpfDisplay.u2.dwRBitMask = info->dwRBitMask;
|
|
|
|
hal_info.vmiData.ddpfDisplay.u3.dwGBitMask = info->dwGBitMask;
|
|
|
|
hal_info.vmiData.ddpfDisplay.u4.dwBBitMask = info->dwBBitMask;
|
2001-04-16 21:54:07 +02:00
|
|
|
hal_info.vmiData.dwNumHeaps = fb_mem ? 1 : 0;
|
|
|
|
hal_info.vmiData.pvmList = fb_mem;
|
2001-03-20 02:24:08 +01:00
|
|
|
|
|
|
|
X11DRV_DDHAL_SetInfo();
|
|
|
|
}
|
|
|
|
|
|
|
|
void X11DRV_DDHAL_SetPalEntries(Colormap pal, DWORD dwBase, DWORD dwNumEntries,
|
|
|
|
LPPALETTEENTRY lpEntries)
|
|
|
|
{
|
|
|
|
XColor c;
|
2004-08-12 01:45:34 +02:00
|
|
|
unsigned int n;
|
2001-03-20 02:24:08 +01:00
|
|
|
|
|
|
|
if (pal) {
|
2003-11-21 01:17:33 +01:00
|
|
|
wine_tsx11_lock();
|
2001-03-20 02:24:08 +01:00
|
|
|
c.flags = DoRed|DoGreen|DoBlue;
|
|
|
|
c.pixel = dwBase;
|
|
|
|
for (n=0; n<dwNumEntries; n++,c.pixel++) {
|
|
|
|
c.red = lpEntries[n].peRed << 8;
|
|
|
|
c.green = lpEntries[n].peGreen << 8;
|
|
|
|
c.blue = lpEntries[n].peBlue << 8;
|
2003-11-21 01:17:33 +01:00
|
|
|
XStoreColor(gdi_display, pal, &c);
|
2001-03-20 02:24:08 +01:00
|
|
|
}
|
2003-11-21 01:17:33 +01:00
|
|
|
XFlush(gdi_display); /* update display immediately */
|
|
|
|
wine_tsx11_unlock();
|
2001-03-20 02:24:08 +01:00
|
|
|
}
|
|
|
|
}
|