Skip to content

Commit b11c608

Browse files
authored
(#116) Respect configured double click time on Windows (#117)
1 parent 6fca0a1 commit b11c608

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

Diff for: src/win32/mouse.c

+9-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include "../mouse.h"
22
#include "../screen.h"
33
#include "../microsleep.h"
4+
#include "../deadbeef_rand.h"
45

56
#include <math.h> /* For floor() */
67

@@ -16,7 +17,6 @@
1617
*/
1718
#define ABSOLUTE_COORD_CONST 65536
1819

19-
2020
#define MMMouseToMEventF(down, button) \
2121
(down ? MMMouseDownToMEventF(button) : MMMouseUpToMEventF(button))
2222

@@ -30,6 +30,8 @@
3030
: ((button) == RIGHT_BUTTON ? MOUSEEVENTF_RIGHTDOWN \
3131
: MOUSEEVENTF_MIDDLEDOWN))
3232

33+
static int32_t DEFAULT_DOUBLE_CLICK_INTERVAL_MS = 200;
34+
3335
MMPoint CalculateAbsoluteCoordinates(MMPoint point) {
3436
MMSize displaySize = getMainDisplaySize();
3537
return MMPointMake(((float) point.x / displaySize.width) * ABSOLUTE_COORD_CONST, ((float) point.y / displaySize.height) * ABSOLUTE_COORD_CONST);
@@ -95,9 +97,14 @@ void clickMouse(MMMouseButton button)
9597
*/
9698
void doubleClick(MMMouseButton button)
9799
{
100+
UINT maxDoubleClickTime = GetDoubleClickTime();
98101
/* Double click for everything else. */
99102
clickMouse(button);
100-
microsleep(200);
103+
if (maxDoubleClickTime > DEFAULT_DOUBLE_CLICK_INTERVAL_MS) {
104+
microsleep(DEFAULT_DOUBLE_CLICK_INTERVAL_MS);
105+
} else {
106+
microsleep(DEADBEEF_RANDRANGE(1, maxDoubleClickTime));
107+
}
101108
clickMouse(button);
102109
}
103110

0 commit comments

Comments
 (0)