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>2011-10-05 17:08:35 +0100
commit1821220c4dfb5c9776b6e3cc5236574b6d28b9ef (patch)
treec84a7fc1fb3e5c54e3b0f8b8a547c2b38c1cf3b9
parent9128f60f4a87728fa5366e82fc067d8f682d6341 (diff)
Cygwin/X: 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 It's not clear if this is worthwhile at all, USB mice seem to report as having 5 buttons anyhow 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>
-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 3f3b7938a..80cfc3151 100644
--- a/hw/xwin/InitOutput.c
+++ b/hw/xwin/InitOutput.c
@@ -736,8 +736,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)
@@ -769,7 +796,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 f993fa437..b0ce366b5 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 43e8aeeac..5ae6ff524 100644
--- a/hw/xwin/winprocarg.c
+++ b/hw/xwin/winprocarg.c
@@ -142,7 +142,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;
@@ -796,6 +796,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"))