From 6753dea682b368198a1e3bd6dfbe4fa5e58298fa Mon Sep 17 00:00:00 2001 From: Ove Kaaven Date: Fri, 27 Apr 2001 18:00:06 +0000 Subject: [PATCH] Reimplemented DXGrab with improvements; it no longer depends on XVidMode, and it releases the grab if the app exits full-screen DirectDraw. Also made the UseDGA option available for AppDefaults configuration. --- dlls/x11drv/dga2.c | 5 +++-- dlls/x11drv/x11ddraw.c | 27 +++++++++++++++++++++++++++ dlls/x11drv/x11drv_main.c | 7 +++++++ dlls/x11drv/xvidmode.c | 4 ++++ 4 files changed, 41 insertions(+), 2 deletions(-) diff --git a/dlls/x11drv/dga2.c b/dlls/x11drv/dga2.c index 9a1f62b3623..939cb6a15f5 100644 --- a/dlls/x11drv/dga2.c +++ b/dlls/x11drv/dga2.c @@ -18,10 +18,11 @@ #include "wingdi.h" #include "ddrawi.h" #include "debugtools.h" -#include "options.h" DEFAULT_DEBUG_CHANNEL(x11drv); +extern int usedga; + LPDDHALMODEINFO xf86dga2_modes; unsigned xf86dga2_mode_count; static XDGAMode* modes; @@ -52,7 +53,7 @@ void X11DRV_XF86DGA2_Init(void) /* if in desktop mode, don't use DGA */ if (X11DRV_GetXRootWindow() != DefaultRootWindow(display)) return; - if (!PROFILE_GetWineIniBool("x11drv", "UseDGA", 1)) return; + if (!usedga) return; if (!TSXDGAQueryExtension(display, &dga_event, &dga_error)) return; diff --git a/dlls/x11drv/x11ddraw.c b/dlls/x11drv/x11ddraw.c index 47f2ce98ba3..cad9e4df53e 100644 --- a/dlls/x11drv/x11ddraw.c +++ b/dlls/x11drv/x11ddraw.c @@ -18,10 +18,13 @@ #include "wingdi.h" #include "ddrawi.h" #include "bitmap.h" +#include "win.h" #include "debugtools.h" DEFAULT_DEBUG_CHANNEL(x11drv); +extern int dxgrab; + LPDDRAWI_DDRAWSURFACE_LCL X11DRV_DD_Primary; LPDDRAWI_DDRAWSURFACE_GBL X11DRV_DD_PrimaryGbl; HWND X11DRV_DD_PrimaryWnd; @@ -43,6 +46,28 @@ static void SetPrimaryDIB(HBITMAP hBmp) } } +static void GrabPointer(HWND hWnd) +{ + if (hWnd) { + WND *tmpWnd; + Window win; + /* find the X11 window that ddraw uses */ + tmpWnd = WIN_FindWndPtr(hWnd); + win = X11DRV_WND_GetXWindow(tmpWnd); + TRACE("WND: %p win: %ld\n", tmpWnd, win); + WIN_ReleaseWndPtr(tmpWnd); + if (!win) { + TRACE("host off desktop\n"); + tmpWnd = WIN_FindWndPtr(GetDesktopWindow()); + win = X11DRV_WND_GetXWindow(tmpWnd); + TRACE("Owner WND: %p win: %ld\n", tmpWnd, win); + WIN_ReleaseWndPtr(tmpWnd); + } + TSXGrabPointer(display, win, True, 0, GrabModeAsync, GrabModeAsync, win, None, CurrentTime); + } + else TSXUngrabPointer(display, CurrentTime); +} + static DWORD PASCAL X11DRV_DDHAL_DestroyDriver(LPDDHAL_DESTROYDRIVERDATA data) { data->ddRVal = DD_OK; @@ -57,6 +82,7 @@ static DWORD PASCAL X11DRV_DDHAL_CreateSurface(LPDDHAL_CREATESURFACEDATA data) X11DRV_DD_PrimaryGbl = X11DRV_DD_Primary->lpGbl; SetPrimaryDIB(GET_LPDDRAWSURFACE_GBL_MORE(X11DRV_DD_PrimaryGbl)->hKernelSurface); X11DRV_DD_UserClass = GlobalFindAtomA("WINE_DDRAW"); + if (dxgrab) GrabPointer(X11DRV_DD_PrimaryWnd); } data->ddRVal = DD_OK; return DDHAL_DRIVER_NOTHANDLED; @@ -94,6 +120,7 @@ static DWORD PASCAL X11DRV_DDHAL_DestroySurface(LPDDHAL_DESTROYSURFACEDATA data) X11DRV_DD_PrimaryGbl = NULL; SetPrimaryDIB(0); X11DRV_DD_UserClass = 0; + if (dxgrab) GrabPointer(0); } data->ddRVal = DD_OK; return DDHAL_DRIVER_HANDLED; diff --git a/dlls/x11drv/x11drv_main.c b/dlls/x11drv/x11drv_main.c index 014c0403b6e..631f801efab 100644 --- a/dlls/x11drv/x11drv_main.c +++ b/dlls/x11drv/x11drv_main.c @@ -56,6 +56,7 @@ unsigned int screen_width; unsigned int screen_height; unsigned int screen_depth; Window root_window; +int dxgrab, usedga; unsigned int X11DRV_server_startticks; @@ -207,6 +208,12 @@ static void setup_options(void) if (!IS_OPTION_FALSE(buffer[0])) desktop_geometry = strdup(buffer); } + if (!get_config_key( hkey, appkey, "DXGrab", buffer, sizeof(buffer) )) + dxgrab = IS_OPTION_TRUE( buffer[0] ); + + if (!get_config_key( hkey, appkey, "UseDGA", buffer, sizeof(buffer) )) + usedga = IS_OPTION_TRUE( buffer[0] ); + screen_depth = 0; if (!get_config_key( hkey, appkey, "ScreenDepth", buffer, sizeof(buffer) )) screen_depth = atoi(buffer); diff --git a/dlls/x11drv/xvidmode.c b/dlls/x11drv/xvidmode.c index 09fa8994ed1..40980fa50c9 100644 --- a/dlls/x11drv/xvidmode.c +++ b/dlls/x11drv/xvidmode.c @@ -116,7 +116,11 @@ void X11DRV_XF86VM_SetCurrentMode(int mode) if (!xf86vm_modes) return; /* no XVidMode */ TSXF86VidModeSwitchToMode(display, DefaultScreen(display), modes[mode]); +#if 0 /* it is said that SetViewPort causes problems with some X servers */ TSXF86VidModeSetViewPort(display, DefaultScreen(display), 0, 0); +#else + TSXWarpPointer(display, None, DefaultRootWindow(display), 0, 0, 0, 0, 0, 0); +#endif TSXSync(display, False); }