From badbd103ae9387912189f2aedf888fd89770ea10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Nusser?= Date: Sun, 1 Jan 2017 19:47:45 +0100 Subject: Add a workaround for JUCE hosts. The event time for them is always '0' and thus we couldn't recognize double-clicks. --- plugingui/nativewindow_x11.cc | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'plugingui/nativewindow_x11.cc') diff --git a/plugingui/nativewindow_x11.cc b/plugingui/nativewindow_x11.cc index f50551e..a4e9659 100644 --- a/plugingui/nativewindow_x11.cc +++ b/plugingui/nativewindow_x11.cc @@ -28,6 +28,7 @@ #include #include +#include #include @@ -459,6 +460,15 @@ std::shared_ptr NativeWindowX11::translateXMessage(XEvent& xevent, (xevent.type == ButtonPress) ? Direction::down : Direction::up; + // This is a fix for hosts (e.g. those using JUCE) that set the + // event time to '0'. + if(xevent.xbutton.time == 0) + { + auto now = std::chrono::system_clock::now().time_since_epoch(); + xevent.xbutton.time = + std::chrono::duration_cast(now).count(); + } + buttonEvent->doubleClick = (xevent.type == ButtonPress) && ((xevent.xbutton.time - last_click) < 200); -- cgit v1.2.3