summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJon TURNEY <jon.turney@dronecode.org.uk>2010-03-24 22:41:22 +0000
committerJon TURNEY <jon.turney@dronecode.org.uk>2012-01-26 14:40:25 +0000
commit74af860f9a59332f6ed1ac9b3e7867fbbb3d7305 (patch)
treea29dc35b02d59666919f57367528623df483b22b
parentc0f3709501a0afd3bf77e783f11d2c2e5f489d3b (diff)
hw/xwin: turn on -emulate3buttons if less than 3 mouse buttons are reported
Try to be more intelligent with default options, turn on -emulate3buttons by default if less than 3 mouse buttons are reported by Windows Also, add -noemulate3buttons option so this default setting can be reversed if desired Also, correctly report the number of mouse buttons windows is reporting, rather than always at least 3 Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk> Reviewed-by: Colin Harrison <colin.harrison@virgin.net>
-rw-r--r--hw/xwin/InitOutput.c31
-rw-r--r--hw/xwin/man/XWin.man3
-rw-r--r--hw/xwin/win.h2
-rw-r--r--hw/xwin/winmouse.c2
-rw-r--r--hw/xwin/winprocarg.c13
5 files changed, 46 insertions, 5 deletions
diff --git a/hw/xwin/InitOutput.c b/hw/xwin/InitOutput.c
index 770439258..4a601b222 100644
--- a/hw/xwin/InitOutput.c
+++ b/hw/xwin/InitOutput.c
@@ -673,8 +673,35 @@ OsVendorInit (void)
/* We have to flag this as an explicit screen, even though it isn't */
g_ScreenInfo[0].fExplicitScreen = TRUE;
}
-}
+ /* Work out what the default emulate3buttons setting should be, and apply
+ it if nothing was explicitly specified */
+ {
+ int mouseButtons = GetSystemMetrics(SM_CMOUSEBUTTONS);
+ int j;
+
+ for (j = 0; j < g_iNumScreens; j++)
+ {
+ if (g_ScreenInfo[j].iE3BTimeout == WIN_E3B_DEFAULT)
+ {
+ if (mouseButtons < 3)
+ {
+ static Bool reportOnce = TRUE;
+ g_ScreenInfo[j].iE3BTimeout = WIN_DEFAULT_E3B_TIME;
+ if (reportOnce)
+ {
+ reportOnce = FALSE;
+ winMsg(X_PROBED, "Windows reports only %d mouse buttons, defaulting to -emulate3buttons\n", mouseButtons);
+ }
+ }
+ else
+ {
+ g_ScreenInfo[j].iE3BTimeout = WIN_E3B_OFF;
+ }
+ }
+ }
+ }
+}
static void
winUseMsg (void)
@@ -706,7 +733,7 @@ winUseMsg (void)
"\tSpecify an optional bitdepth to use in fullscreen mode\n"
"\twith a DirectDraw engine.\n");
- ErrorF ("-emulate3buttons [timeout]\n"
+ ErrorF ("-[no]emulate3buttons [timeout]\n"
"\tEmulate 3 button mouse with an optional timeout in\n"
"\tmilliseconds.\n");
diff --git a/hw/xwin/man/XWin.man b/hw/xwin/man/XWin.man
index 6e69a185d..d03a36521 100644
--- a/hw/xwin/man/XWin.man
+++ b/hw/xwin/man/XWin.man
@@ -176,7 +176,8 @@ milliseconds causes an emulated middle button press. The default
.I timeout
is 50 milliseconds. Note that most mice with scroll wheel have middle
button functionality, usually you will need this option only if you have
-a two button mouse without scroll wheel.
+a two button mouse without scroll wheel. Default is to enable this
+option if \fIWindows\fP reports a two button mouse, disabled otherwise.
.TP 8
.B \-[no]keyhook
Enable [disable] a low-level keyboard hook for catching
diff --git a/hw/xwin/win.h b/hw/xwin/win.h
index ac26d0181..583906442 100644
--- a/hw/xwin/win.h
+++ b/hw/xwin/win.h
@@ -102,6 +102,8 @@
#define MOUSE_POLLING_INTERVAL 50
#define WIN_E3B_OFF -1
+#define WIN_E3B_DEFAULT 0
+
#define WIN_FD_INVALID -1
#define WIN_SERVER_NONE 0x0L /* 0 */
diff --git a/hw/xwin/winmouse.c b/hw/xwin/winmouse.c
index 752334a31..3193e3e51 100644
--- a/hw/xwin/winmouse.c
+++ b/hw/xwin/winmouse.c
@@ -79,6 +79,7 @@ winMouseProc (DeviceIntPtr pDeviceInt, int iState)
case DEVICE_INIT:
/* Get number of mouse buttons */
lngMouseButtons = GetSystemMetrics(SM_CMOUSEBUTTONS);
+ winMsg(X_PROBED, "%d mouse buttons found\n", lngMouseButtons);
/* Mapping of windows events to X events:
* LEFT:1 MIDDLE:2 RIGHT:3
@@ -89,7 +90,6 @@ winMouseProc (DeviceIntPtr pDeviceInt, int iState)
*/
if (lngMouseButtons < 3)
lngMouseButtons = 3;
- winMsg(X_PROBED, "%d mouse buttons found\n", lngMouseButtons);
/* allocate memory:
* number of buttons + 2x mouse wheel event + 1 extra (offset for map)
diff --git a/hw/xwin/winprocarg.c b/hw/xwin/winprocarg.c
index 6553e72f8..9bec84141 100644
--- a/hw/xwin/winprocarg.c
+++ b/hw/xwin/winprocarg.c
@@ -141,7 +141,7 @@ winInitializeScreenDefaults(void)
defaultScreenInfo.fLessPointer = FALSE;
defaultScreenInfo.iResizeMode = notAllowed;
defaultScreenInfo.fNoTrayIcon = FALSE;
- defaultScreenInfo.iE3BTimeout = WIN_E3B_OFF;
+ defaultScreenInfo.iE3BTimeout = WIN_E3B_DEFAULT;
defaultScreenInfo.fUseWinKillKey = WIN_DEFAULT_WIN_KILL;
defaultScreenInfo.fUseUnixKillKey = WIN_DEFAULT_UNIX_KILL;
defaultScreenInfo.fIgnoreInput = FALSE;
@@ -789,6 +789,17 @@ ddxProcessArgument (int argc, char *argv[], int i)
}
/*
+ * Look for the '-noemulate3buttons' argument
+ */
+ if (IS_OPTION ("-noemulate3buttons"))
+ {
+ screenInfoPtr->iE3BTimeout = WIN_E3B_OFF;
+
+ /* Indicate that we have processed this argument */
+ return 1;
+ }
+
+ /*
* Look for the '-depth n' argument
*/
if (IS_OPTION ("-depth"))