diff -ru work/xc/programs/Xserver/hw/xfree86/input/mouse/mouse.c wk2/xc/programs/Xserver/hw/xfree86/input/mouse/mouse.c --- work/xc/programs/Xserver/hw/xfree86/input/mouse/mouse.c 2004-07-17 17:36:48.000000000 +0000 +++ wk2/xc/programs/Xserver/hw/xfree86/input/mouse/mouse.c 2004-07-19 21:16:23.791054896 +0000 @@ -199,7 +199,8 @@ OPTION_FLOW_CONTROL, OPTION_VTIME, OPTION_VMIN, - OPTION_DRAGLOCKBUTTONS + OPTION_DRAGLOCKBUTTONS, + OPTION_DOUBLECLICK_BUTTONS } MouseOpts; #ifdef XFree86LOADER @@ -240,6 +241,7 @@ { OPTION_VMIN, "VMin", OPTV_INTEGER, {0}, FALSE }, { OPTION_DRAGLOCKBUTTONS, "DragLockButtons",OPTV_STRING, {0}, FALSE }, /* end serial options */ + { OPTION_DOUBLECLICK_BUTTONS,"DoubleClickButtons", OPTV_STRING, {0}, FALSE }, { -1, NULL, OPTV_NONE, {0}, FALSE } }; #endif @@ -664,7 +666,34 @@ if (origButtons != pMse->buttons) buttons_from = X_CONFIG; xf86Msg(buttons_from, "%s: Buttons: %d\n", pInfo->name, pMse->buttons); - + + pMse->doubleClickSourceButtonMask = 0; + pMse->doubleClickTargetButtonMask = 0; + pMse->doubleClickTargetButton = 0; + s = xf86SetStrOption(pInfo->options, "DoubleClickButtons", NULL); + if (s) { + int b1 = 0, b2 = 0; + char *msg = NULL; + + if ((sscanf(s, "%d %d", &b1, &b2) == 2) && + (b1 > 0) && (b1 <= MSE_MAXBUTTONS) && (b2 > 0) && (b2 <= MSE_MAXBUTTONS)) { + msg = xstrdup("buttons XX and YY"); + if (msg) + sprintf(msg, "buttons %d and %d", b1, b2); + pMse->doubleClickTargetButton = b1; + pMse->doubleClickTargetButtonMask = 1 << (b1 - 1); + pMse->doubleClickSourceButtonMask = 1 << (b2 - 1); + if (b1 > pMse->buttons) pMse->buttons = b1; + if (b2 > pMse->buttons) pMse->buttons = b2; + } else { + xf86Msg(X_WARNING, "%s: Invalid DoubleClickButtons value: \"%s\"\n", + pInfo->name, s); + } + if (msg) { + xf86Msg(X_CONFIG, "%s: DoubleClickButtons: %s\n", pInfo->name, msg); + xfree(msg); + } + } } /* * map bits corresponding to lock buttons. @@ -2012,6 +2041,32 @@ else buttons = reverseBits(reverseMap, buttons); + /* Do single button double click */ + if (pMse->doubleClickSourceButtonMask) { + if (buttons & pMse->doubleClickSourceButtonMask) { + if (!(pMse->doubleClickOldSourceState)) { + /* double-click button has just been pressed. Ignore it if target button + * is already down. + */ + if (!(buttons & pMse->doubleClickTargetButtonMask)) { + /* Target button isn't down, so send a double-click */ + xf86PostButtonEvent(pInfo->dev, 0, pMse->doubleClickTargetButton, 1, 0, 0); + xf86PostButtonEvent(pInfo->dev, 0, pMse->doubleClickTargetButton, 0, 0, 0); + xf86PostButtonEvent(pInfo->dev, 0, pMse->doubleClickTargetButton, 1, 0, 0); + xf86PostButtonEvent(pInfo->dev, 0, pMse->doubleClickTargetButton, 0, 0, 0); + } + } + pMse->doubleClickOldSourceState = 1; + } + else + pMse->doubleClickOldSourceState = 0; + + /* Whatever happened, mask the double-click button so it doesn't get + * processed as a normal button as well. + */ + buttons &= ~(pMse->doubleClickSourceButtonMask); + } + /* Intercept wheel emulation. */ if (pMse->emulateWheel && (buttons & pMse->wheelButtonMask)) { /* Y axis movement */ diff -ru work/xc/programs/Xserver/hw/xfree86/os-support/xf86OSmouse.h wk2/xc/programs/Xserver/hw/xfree86/os-support/xf86OSmouse.h --- work/xc/programs/Xserver/hw/xfree86/os-support/xf86OSmouse.h 2004-07-17 17:36:48.000000000 +0000 +++ wk2/xc/programs/Xserver/hw/xfree86/os-support/xf86OSmouse.h 2004-07-19 21:17:25.904612200 +0000 @@ -269,6 +269,10 @@ int angleOffset; pointer pDragLock; /* drag lock area */ int xisbscale; /* buffer size for 1 event */ + int doubleClickSourceButtonMask; + int doubleClickTargetButton; + int doubleClickTargetButtonMask; + int doubleClickOldSourceState; } MouseDevRec, *MouseDevPtr; /* Z axis mapping */