diff -ru xc/programs/Xserver/hw/xfree86/input/mouse/mouse.c.orig xc/programs/Xserver/hw/xfree86/input/mouse/mouse.c --- xc/programs/Xserver/hw/xfree86/input/mouse/mouse.c.orig 2004-07-24 13:35:39.000000000 -0400 +++ xc/programs/Xserver/hw/xfree86/input/mouse/mouse.c 2005-12-27 23:54:16.000000000 -0500 @@ -186,6 +186,7 @@ OPTION_RESOLUTION, OPTION_EMULATE_WHEEL, OPTION_EMU_WHEEL_BUTTON, + OPTION_EMU_WHEEL_CLICK, OPTION_EMU_WHEEL_INERTIA, OPTION_X_AXIS_MAPPING, OPTION_Y_AXIS_MAPPING, @@ -224,6 +225,7 @@ { OPTION_RESOLUTION, "Resolution", OPTV_INTEGER, {0}, FALSE }, { OPTION_EMULATE_WHEEL, "EmulateWheel", OPTV_BOOLEAN, {0}, FALSE }, { OPTION_EMU_WHEEL_BUTTON, "EmulateWheelButton", OPTV_INTEGER, {0}, FALSE }, + { OPTION_EMU_WHEEL_CLICK, "EmulateWheelClickToo", OPTV_BOOLEAN, {0}, FALSE }, { OPTION_EMU_WHEEL_INERTIA, "EmulateWheelInertia", OPTV_INTEGER, {0}, FALSE }, { OPTION_X_AXIS_MAPPING, "XAxisMapping", OPTV_STRING, {0}, FALSE }, { OPTION_Y_AXIS_MAPPING, "YAxisMapping", OPTV_STRING, {0}, FALSE }, @@ -588,6 +590,9 @@ } pMse->wheelButtonMask = 1 << (wheelButton - 1); + pMse->wheelButtonClick = xf86SetBoolOption(pInfo->options, + "EmulateWheelClickToo", FALSE); + pMse->wheelInertia = xf86SetIntOption(pInfo->options, "EmulateWheelInertia", 10); if (pMse->wheelInertia <= 0) { @@ -658,8 +663,9 @@ pInfo->name, pMse->negativeY, pMse->positiveY); } xf86Msg(X_CONFIG, "%s: EmulateWheel, EmulateWheelButton: %d, " - "EmulateWheelInertia: %d\n", - pInfo->name, wheelButton, pMse->wheelInertia); + "EmulateWheelInertia: %d, EmulateWheelClickToo: %d\n", + pInfo->name, wheelButton, pMse->wheelInertia, + pMse->wheelButtonClick); } if (origButtons != pMse->buttons) buttons_from = X_CONFIG; @@ -2014,6 +2020,8 @@ /* Intercept wheel emulation. */ if (pMse->emulateWheel && (buttons & pMse->wheelButtonMask)) { + pMse->wheelButtonMoved = pMse->wheelButtonMoved || dx || dy; + /* Y axis movement */ if (pMse->negativeY != MSE_NOAXISMAP) { pMse->wheelYDistance += dy; @@ -2066,10 +2074,9 @@ } } - /* Absorb the mouse movement and the wheel button press. */ + /* Absorb the mouse movement. */ dx = 0; dy = 0; - buttons &= ~pMse->wheelButtonMask; } if (dx || dy) @@ -2082,6 +2089,31 @@ else change = buttons ^ reverseBits(reverseMap, pMse->lastButtons); + /* We generally swallow wheelButtonMask events, except when a wheel + * button is released, and we haven't moved the mouse since a wheel + * button was pressed, and EmulateWheelClickToo is set. */ + + if (pMse->emulateWheel && change & pMse->wheelButtonMask) { + int wheelChange = change & pMse->wheelButtonMask; + + while (wheelChange) { + id = ffs(wheelChange); + wheelChange &= ~(1 << (id - 1)); + if (pMse->wheelButtonClick && + ! (buttons & (1 << (id - 1))) && /* released */ + ! pMse->wheelButtonMoved) { + xf86PostButtonEvent(pInfo->dev, 0, id, 1, 0, 0); + xf86PostButtonEvent(pInfo->dev, 0, id, 0, 0, 0); + } + } + + if (! (buttons & pMse->wheelButtonMask)) + pMse->wheelButtonMoved = 0; + + buttons &= ~pMse->wheelButtonMask; + change &= ~pMse->wheelButtonMask; + } + /* * adjust buttons state for drag locks! * if there is drag locks diff -ru xc/programs/Xserver/hw/xfree86/input/mouse/mouse.man.orig xc/programs/Xserver/hw/xfree86/input/mouse/mouse.man --- xc/programs/Xserver/hw/xfree86/input/mouse/mouse.man.orig 2004-04-23 15:54:04.000000000 -0400 +++ xc/programs/Xserver/hw/xfree86/input/mouse/mouse.man 2005-12-27 23:48:54.000000000 -0500 @@ -112,6 +112,12 @@ .B YAxisMapping settings. Default: 4. .TP 7 +.BI "Option \*qEmulateWheelClickToo\*q \*q" boolean \*q +Causes +.B EmulateWheelButton +to generate normal clicks when the mouse isn't moved between press and +release. Default: off +.TP 7 .BI "Option \*qEmulateWheelInertia\*q \*q" integer \*q Specifies how far (in pixels) the pointer must move to generate button press/release events in wheel emulation mode. Default: 50. diff -ru xc/programs/Xserver/hw/xfree86/os-support/xf86OSmouse.h.orig xc/programs/Xserver/hw/xfree86/os-support/xf86OSmouse.h --- xc/programs/Xserver/hw/xfree86/os-support/xf86OSmouse.h.orig 2004-07-24 13:35:39.000000000 -0400 +++ xc/programs/Xserver/hw/xfree86/os-support/xf86OSmouse.h 2005-12-27 23:35:44.000000000 -0500 @@ -255,6 +255,8 @@ Bool emulateWheel; int wheelInertia; int wheelButtonMask; + Bool wheelButtonClick; + Bool wheelButtonMoved; int negativeX; /* Button values. Unlike the Z and */ int positiveX; /* W equivalents, these are button */ int negativeY; /* values rather than button masks. */