[PATCH]hotkey for mousegrab
Fabian Bieler <[email protected]> Tue, 12 Apr 2005 23:43:20 +0200
| Newsgroups | gmane.comp.emulators.winex.devel |
|---|---|
| Message-ID | <[email protected]> |
This is a small hack to disable and re-enable DXGrab via Ctrl-F9. fabian
patch.diff
(text/x-diff, 4.2 KB)
Index: dlls/x11drv/x11ddraw.c
===================================================================
RCS file: /cvsroot/winex/dlls/x11drv/x11ddraw.c,v
retrieving revision 1.111
diff -u -p -r1.111 x11ddraw.c
--- dlls/x11drv/x11ddraw.c 20 Jan 2005 16:15:18 -0000 1.111
+++ dlls/x11drv/x11ddraw.c 12 Apr 2005 20:16:40 -0000
@@ -10,6 +10,8 @@
#include <errno.h>
#include <unistd.h>
#include <sys/poll.h>
+#include <X11/Xatom.h>
+#include <X11/keysym.h>
#include "ts_xlib.h"
#include "x11drv.h"
@@ -53,6 +55,8 @@ extern unsigned int videoram;
extern int app_resolution_change;
+extern int hotkeys;
+
HHOOK x11drv_mouse_hhook;
LPDDRAWI_DDRAWSURFACE_LCL X11DRV_DD_Primary;
@@ -78,6 +82,8 @@ X11DRV_MODE_SWITCH X11DRV_DD_ModeSwitch;
#define FAKE_REFRESH_RATE 60
+void X11DRV_ToggleSuppressGrabs(void);
+
/* this is a list of fake modes used when XF86VidMode, DGA2,
* or future equivalent, is not available. */
static DDHALMODEINFO default_mode_info[] = {
@@ -417,7 +423,7 @@ void X11DRV_DD_Update(void);
void X11DRV_DD_InstallNewRoot(void);
void X11DRV_DD_ContinueReparent(Window win);
-static BOOL has_focus, has_grab, want_grab, propagate;
+static BOOL has_focus, has_grab, want_grab, suppress_grab, propagate;
LRESULT CALLBACK x11drv_mouse_hook( int code, WPARAM wparam, LPARAM lparam )
{
@@ -484,6 +490,18 @@ void X11DRV_DD_ThreadEvent(Display *disp
break;
}
/* fall through */
+
+ if(hotkeys)
+ {
+ if(event->xkey.state & ControlMask)
+ switch(XKeycodeToKeysym(display, event->xkey.keycode, 0))
+ {
+ case XK_F9:
+ TRACE("Ctrl-F9 was pressed\n");
+ X11DRV_ToggleSuppressGrabs();
+ break;
+ }
+ }
case KeyRelease:
#if 1
event->xany.window = root_window;
@@ -1144,7 +1162,8 @@ void X11DRV_EnableGrabs(void)
if (!dxgrab) return;
want_grab = TRUE;
if (X11DRV_DD_PrimaryFrame) {
- X11DRV_DD_PostCmd(DDMSG_GRAB);
+ if (!suppress_grab)
+ X11DRV_DD_PostCmd(DDMSG_GRAB);
return;
}
}
@@ -1160,6 +1179,27 @@ void X11DRV_DisableGrabs(void)
}
}
+void X11DRV_ToggleSuppressGrabs(void)
+{
+ TRACE("\n");
+ if (!dxgrab) return;
+ if (!suppress_grab)
+ {
+ suppress_grab = TRUE;
+ if (X11DRV_DD_PrimaryFrame)
+ X11DRV_DD_PostCmd(DDMSG_UNGRAB);
+ }
+ else
+ {
+ suppress_grab = FALSE;
+ if (want_grab)
+ {
+ if (X11DRV_DD_PrimaryFrame)
+ X11DRV_DD_PostCmd(DDMSG_GRAB);
+ }
+ }
+}
+
void X11DRV_RetargetGrabs(void)
{
TRACE("\n");
Index: dlls/x11drv/x11drv_main.c
===================================================================
RCS file: /cvsroot/winex/dlls/x11drv/x11drv_main.c,v
retrieving revision 1.44
diff -u -p -r1.44 x11drv_main.c
--- dlls/x11drv/x11drv_main.c 2 Nov 2004 19:14:52 -0000 1.44
+++ dlls/x11drv/x11drv_main.c 12 Apr 2005 20:16:42 -0000
@@ -68,7 +68,7 @@ unsigned int screen_height;
unsigned int screen_depth;
unsigned int screen_bpp;
Window root_window;
-int dxgrab, usedga, usexvidmode, usexrandr, show_fps, show_mem;
+int dxgrab, usedga, usexvidmode, usexrandr, hotkeys, show_fps, show_mem;
unsigned int videoram = 32;
unsigned int agpvertexarrayram = 32;
@@ -318,6 +318,9 @@ static void setup_options(void)
if (!get_config_key( hkey, appkey, "UseXRandR", buffer, sizeof(buffer) ))
usexrandr = IS_OPTION_TRUE( buffer[0] );
+ if (!get_config_key( hkey, appkey, "HotKeys", buffer, sizeof(buffer) ))
+ hotkeys = IS_OPTION_TRUE( buffer[0] );
+
if (!get_config_key( hkey, appkey, "VideoRam", buffer, sizeof(buffer) )) {
videoram = atoi(buffer);
Index: documentation/samples/config
===================================================================
RCS file: /cvsroot/winex/documentation/samples/config,v
retrieving revision 1.7
diff -u -p -r1.7 config
--- documentation/samples/config 23 Sep 2003 01:46:58 -0000 1.7
+++ documentation/samples/config 12 Apr 2005 20:16:44 -0000
@@ -143,6 +143,10 @@ WINE REGISTRY Version 2
"DXGrab" = "Y"
; Use XVidMode extension if present
"UseXVidMode" = "Y"
+; Use XRandR extension if present
+"UseXRandR" = "N"
+; Enable Ctrl-F9 to suppress DXGrab and Ctrl-F11 to suppress DXFullscreen
+"HotKeys" = "Y"
; Create the desktop window with a double-buffered visual
; (useful to play OpenGL games)
"DesktopDoubleBuffered" = "Y"