#ifdef HAVE_LIBXXF86DGA2
-#include "ts_xlib.h"
-#include "ts_xf86dga2.h"
+#define NONAMELESSUNION
+#define NONAMELESSSTRUCT
+#include <X11/Xlib.h>
+#include <X11/extensions/xf86dga.h>
+
#include "x11drv.h"
#include "x11ddraw.h"
#include "dga2.h"
info->dwWidth, info->dwHeight, info->dwBPP, info->wRefreshRate);
}
+static int DGA2ErrorHandler(Display *dpy, XErrorEvent *event, void *arg)
+{
+ return 1;
+}
+
void X11DRV_XF86DGA2_Init(void)
{
int nmodes, major, minor, i;
+ Bool ok;
+
+ TRACE("\n");
if (xf86dga2_modes) return; /* already initialized? */
if (!usedga) return;
- if (!TSXDGAQueryExtension(gdi_display, &dga_event, &dga_error)) return;
+ wine_tsx11_lock();
+ ok = XDGAQueryExtension(gdi_display, &dga_event, &dga_error);
+ if (ok)
+ {
+ X11DRV_expect_error(gdi_display, DGA2ErrorHandler, NULL);
+ ok = XDGAQueryVersion(gdi_display, &major, &minor);
+ if (X11DRV_check_error()) ok = FALSE;
+ }
+ wine_tsx11_unlock();
+ if (!ok) return;
- if (!TSXDGAQueryVersion(gdi_display, &major, &minor)) return;
-
if (major < 2) return; /* only bother with DGA 2+ */
/* test that it works */
- if (!TSXDGAOpenFramebuffer(gdi_display, DefaultScreen(gdi_display))) {
- WARN("disabling XF86DGA2 (insufficient permissions?)\n");
- return;
+ wine_tsx11_lock();
+ X11DRV_expect_error(gdi_display, DGA2ErrorHandler, NULL);
+ ok = XDGAOpenFramebuffer(gdi_display, DefaultScreen(gdi_display));
+ if (X11DRV_check_error()) ok = FALSE;
+ if (ok)
+ {
+ XDGACloseFramebuffer(gdi_display, DefaultScreen(gdi_display));
+ /* retrieve modes */
+ modes = XDGAQueryModes(gdi_display, DefaultScreen(gdi_display), &nmodes);
+ if (!modes) ok = FALSE;
}
- TSXDGACloseFramebuffer(gdi_display, DefaultScreen(gdi_display));
-
- /* retrieve modes */
- modes = TSXDGAQueryModes(gdi_display, DefaultScreen(gdi_display), &nmodes);
- if (!modes) return;
+ else WARN("disabling XF86DGA2 (insufficient permissions?)\n");
+ wine_tsx11_unlock();
+ if (!ok) return;
TRACE("DGA modes: count=%d\n", nmodes);
void X11DRV_XF86DGA2_Cleanup(void)
{
- if (modes) TSXFree(modes);
+ wine_tsx11_lock();
+ if (modes) XFree(modes);
+ wine_tsx11_unlock();
}
static XDGADevice *dga_dev;
Display *display = gdi_display;
data->ddRVal = DD_OK;
+ wine_tsx11_lock();
if (data->dwModeIndex) {
/* enter DGA */
XDGADevice *new_dev = NULL;
- if (dga_dev || TSXDGAOpenFramebuffer(display, DefaultScreen(display)))
- new_dev = TSXDGASetMode(display, DefaultScreen(display), modes[data->dwModeIndex-1].num);
+ if (dga_dev || XDGAOpenFramebuffer(display, DefaultScreen(display)))
+ new_dev = XDGASetMode(display, DefaultScreen(display), modes[data->dwModeIndex-1].num);
if (new_dev) {
- TSXDGASetViewport(display, DefaultScreen(display), 0, 0, XDGAFlipImmediate);
+ XDGASetViewport(display, DefaultScreen(display), 0, 0, XDGAFlipImmediate);
if (dga_dev) {
VirtualFree(dga_dev->data, 0, MEM_RELEASE);
- TSXFree(dga_dev);
+ XFree(dga_dev);
} else {
- TSXDGASelectInput(display, DefaultScreen(display),
+ XDGASelectInput(display, DefaultScreen(display),
KeyPressMask|KeyReleaseMask|
ButtonPressMask|ButtonReleaseMask|
PointerMotionMask);
- X11DRV_EVENT_SetDGAStatus(ddlocal->hWnd, dga_event);
+ X11DRV_EVENT_SetDGAStatus((HWND)ddlocal->hWnd, dga_event);
X11DRV_EVENT_SetInputMethod(X11DRV_INPUT_RELATIVE);
}
dga_dev = new_dev;
vram = dga_dev->mode.bytesPerScanline * dga_dev->mode.imageHeight;
- VirtualAlloc(dga_dev->data, vram, MEM_RESERVE|MEM_SYSTEM, PAGE_READWRITE);
+ VirtualAlloc(dga_dev->data, vram, MEM_SYSTEM, PAGE_READWRITE);
dga_mem.fpStart = (FLATPTR)dga_dev->data;
dga_mem.u1.dwWidth = dga_dev->mode.bytesPerScanline;
dga_mem.u2.dwHeight = dga_dev->mode.imageHeight;
}
else {
ERR("failed\n");
- if (!dga_dev) TSXDGACloseFramebuffer(display, DefaultScreen(display));
+ if (!dga_dev) XDGACloseFramebuffer(display, DefaultScreen(display));
data->ddRVal = DDERR_GENERIC;
}
}
/* exit DGA */
X11DRV_DD_IsDirect = FALSE;
X11DRV_DDHAL_SwitchMode(0, NULL, NULL);
- TSXDGASetMode(display, DefaultScreen(display), 0);
+ XDGASetMode(display, DefaultScreen(display), 0);
VirtualFree(dga_dev->data, 0, MEM_RELEASE);
X11DRV_EVENT_SetInputMethod(X11DRV_INPUT_ABSOLUTE);
X11DRV_EVENT_SetDGAStatus(0, -1);
- TSXFree(dga_dev);
- TSXDGACloseFramebuffer(display, DefaultScreen(display));
+ XFree(dga_dev);
+ XDGACloseFramebuffer(display, DefaultScreen(display));
dga_dev = NULL;
}
+ wine_tsx11_unlock();
return DDHAL_DRIVER_HANDLED;
}
static DWORD PASCAL X11DRV_XF86DGA2_CreatePalette(LPDDHAL_CREATEPALETTEDATA data)
{
Display *display = gdi_display;
- data->lpDDPalette->u1.dwReserved1 = TSXDGACreateColormap(display, DefaultScreen(display), dga_dev, AllocAll);
+ wine_tsx11_lock();
+ data->lpDDPalette->u1.dwReserved1 = XDGACreateColormap(display, DefaultScreen(display),
+ dga_dev, AllocAll);
+ wine_tsx11_unlock();
if (data->lpColorTable)
X11DRV_DDHAL_SetPalEntries(data->lpDDPalette->u1.dwReserved1, 0, 256,
data->lpColorTable);
Display *display = gdi_display;
if (data->lpSurfCurr == X11DRV_DD_Primary) {
DWORD ofs = data->lpSurfCurr->lpGbl->fpVidMem - dga_mem.fpStart;
- TSXDGASetViewport(display, DefaultScreen(display),
- (ofs % dga_dev->mode.bytesPerScanline)*8/dga_dev->mode.bitsPerPixel,
- ofs / dga_dev->mode.bytesPerScanline,
- XDGAFlipImmediate);
+ wine_tsx11_lock();
+ XDGASetViewport(display, DefaultScreen(display),
+ (ofs % dga_dev->mode.bytesPerScanline)*8/dga_dev->mode.bitsPerPixel,
+ ofs / dga_dev->mode.bytesPerScanline,
+ XDGAFlipImmediate);
+ wine_tsx11_unlock();
}
data->ddRVal = DD_OK;
return DDHAL_DRIVER_HANDLED;
{
Display *display = gdi_display;
if ((data->lpDDSurface == X11DRV_DD_Primary) &&
- data->lpDDPalette && data->lpDDPalette->u1.dwReserved1) {
- TSXDGAInstallColormap(display, DefaultScreen(display), data->lpDDPalette->u1.dwReserved1);
+ data->lpDDPalette && data->lpDDPalette->u1.dwReserved1)
+ {
+ wine_tsx11_lock();
+ XDGAInstallColormap(display, DefaultScreen(display), data->lpDDPalette->u1.dwReserved1);
+ wine_tsx11_unlock();
}
data->ddRVal = DD_OK;
return DDHAL_DRIVER_HANDLED;