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>
This commit is contained in:
Jon TURNEY 2010-03-24 22:41:22 +00:00
parent c0f3709501
commit 74af860f9a
5 changed files with 46 additions and 5 deletions

View File

@ -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");

View File

@ -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

View File

@ -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 */

View File

@ -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)

View File

@ -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;
@ -788,6 +788,17 @@ ddxProcessArgument (int argc, char *argv[], int i)
return iArgsProcessed;
}
/*
* 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
*/