diff --git a/docs/changelog.rst b/docs/changelog.rst index 342cdda4b..97981cc33 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -38,6 +38,8 @@ Changelog - macOS: Fix incorrect text sizes calculated when using an external display that is set to mirror the main display (:iss:`1056`) +- macOS: Use the system default double click interval (:pull:`1090`) + - Linux: Fix match rules used as aliases in Fontconfig configuration not being respected (:iss:`1085`) diff --git a/glfw/cocoa_window.m b/glfw/cocoa_window.m index c83d8c8b5..cc5b068f4 100644 --- a/glfw/cocoa_window.m +++ b/glfw/cocoa_window.m @@ -1583,6 +1583,11 @@ void _glfwPlatformGetWindowContentScale(_GLFWwindow* window, *yscale = (float) (pixels.size.height / points.size.height); } +double _glfwPlatformGetDoubleClickInterval(_GLFWwindow* window) +{ + return [NSEvent doubleClickInterval]; +} + void _glfwPlatformIconifyWindow(_GLFWwindow* window) { [window->ns.object miniaturize:nil]; diff --git a/glfw/glfw3.h b/glfw/glfw3.h index 0dc05cf34..e728023af 100644 --- a/glfw/glfw3.h +++ b/glfw/glfw3.h @@ -2930,6 +2930,32 @@ GLFWAPI void glfwGetWindowFrameSize(GLFWwindow* window, int* left, int* top, int */ GLFWAPI void glfwGetWindowContentScale(GLFWwindow* window, float* xscale, float* yscale); +/*! @brief Returns the double click time interval. + * + * This function returns the maximum time between clicks to count as a + * double click. + * + * The double click interval is a positive finite number greater than zero, + * where zero means that no click is ever recognized as a double click. If the + * system does not support a double click interval, this function always returns one half. + * + * @return The double click interval. + * + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref + * GLFW_PLATFORM_ERROR. + * + * @thread_safety This function must only be called from the main thread. + * + * @sa @ref double_click + * @sa @ref click_interval + * @sa @ref double_click_interval + * + * @since Added in version 3.3. + * + * @ingroup window + */ +GLFWAPI double glfwGetDoubleClickInterval(GLFWwindow* window); + /*! @brief Returns the opacity of the whole window. * * This function returns the opacity of the window, including any decorations. diff --git a/glfw/internal.h b/glfw/internal.h index b949d306b..6b064c664 100644 --- a/glfw/internal.h +++ b/glfw/internal.h @@ -653,6 +653,7 @@ void _glfwPlatformGetWindowFrameSize(_GLFWwindow* window, int* right, int* bottom); void _glfwPlatformGetWindowContentScale(_GLFWwindow* window, float* xscale, float* yscale); +double _glfwPlatformGetDoubleClickInterval(_GLFWwindow* window); void _glfwPlatformIconifyWindow(_GLFWwindow* window); void _glfwPlatformRestoreWindow(_GLFWwindow* window); void _glfwPlatformMaximizeWindow(_GLFWwindow* window); diff --git a/glfw/null_window.c b/glfw/null_window.c index 82f414934..2823e1775 100644 --- a/glfw/null_window.c +++ b/glfw/null_window.c @@ -148,6 +148,11 @@ void _glfwPlatformGetWindowContentScale(_GLFWwindow* window, *yscale = 1.f; } +double _glfwPlatformGetDoubleClickInterval(_GLFWwindow* window) +{ + return 0.5; +} + void _glfwPlatformIconifyWindow(_GLFWwindow* window) { } diff --git a/glfw/win32_window.c b/glfw/win32_window.c index a1f24e786..0e6cbcecf 100644 --- a/glfw/win32_window.c +++ b/glfw/win32_window.c @@ -1602,6 +1602,11 @@ void _glfwPlatformGetWindowContentScale(_GLFWwindow* window, _glfwGetMonitorContentScaleWin32(handle, xscale, yscale); } +double _glfwPlatformGetDoubleClickInterval(_GLFWwindow* window) +{ + return 0.5; +} + void _glfwPlatformIconifyWindow(_GLFWwindow* window) { ShowWindow(window->win32.handle, SW_MINIMIZE); diff --git a/glfw/window.c b/glfw/window.c index 10c510e15..dcdbef7d0 100644 --- a/glfw/window.c +++ b/glfw/window.c @@ -721,6 +721,15 @@ GLFWAPI void glfwGetWindowContentScale(GLFWwindow* handle, _glfwPlatformGetWindowContentScale(window, xscale, yscale); } +GLFWAPI double glfwGetDoubleClickInterval(GLFWwindow* handle) +{ + _GLFWwindow* window = (_GLFWwindow*) handle; + assert(window != NULL); + + _GLFW_REQUIRE_INIT_OR_RETURN(0.5f); + return _glfwPlatformGetDoubleClickInterval(window); +} + GLFWAPI float glfwGetWindowOpacity(GLFWwindow* handle) { _GLFWwindow* window = (_GLFWwindow*) handle; diff --git a/glfw/wl_window.c b/glfw/wl_window.c index e8057fddf..6e69a14e6 100644 --- a/glfw/wl_window.c +++ b/glfw/wl_window.c @@ -1091,6 +1091,11 @@ void _glfwPlatformGetWindowContentScale(_GLFWwindow* window, *yscale = (float) window->wl.scale; } +double _glfwPlatformGetDoubleClickInterval(_GLFWwindow* window) +{ + return 0.5; +} + void _glfwPlatformIconifyWindow(_GLFWwindow* window) { if (_glfw.wl.wmBase) diff --git a/glfw/x11_window.c b/glfw/x11_window.c index 53fa8fc88..cdc8c063a 100644 --- a/glfw/x11_window.c +++ b/glfw/x11_window.c @@ -2108,6 +2108,11 @@ void _glfwPlatformGetWindowContentScale(_GLFWwindow* window, *yscale = _glfw.x11.contentScaleY; } +double _glfwPlatformGetDoubleClickInterval(_GLFWwindow* window) +{ + return 0.5; +} + void _glfwPlatformIconifyWindow(_GLFWwindow* window) { if (window->x11.overrideRedirect) diff --git a/kitty/config_data.py b/kitty/config_data.py index 169776f64..5669d1c3c 100644 --- a/kitty/config_data.py +++ b/kitty/config_data.py @@ -399,9 +399,9 @@ Characters considered part of a word when double clicking. In addition to these any character that is marked as an alpha-numeric character in the unicode database will be matched.''')) -o('click_interval', 0.5, option_type=positive_float, long_text=_(''' -The interval between successive clicks to detect -double/triple clicks (in seconds)''')) +o('click_interval', -1.0, option_type=float, long_text=_(''' +The interval between successive clicks to detect double/triple clicks (in seconds). +Negative numbers will use the system default instead, if available, or fallback to 0.5.''')) o('mouse_hide_wait', 3.0, option_type=positive_float, long_text=_(''' Hide mouse cursor after the specified number of seconds diff --git a/kitty/glfw-wrapper.c b/kitty/glfw-wrapper.c index 0b1e51f8c..1772cb262 100644 --- a/kitty/glfw-wrapper.c +++ b/kitty/glfw-wrapper.c @@ -131,6 +131,9 @@ load_glfw(const char* path) { *(void **) (&glfwGetWindowContentScale_impl) = dlsym(handle, "glfwGetWindowContentScale"); if (glfwGetWindowContentScale_impl == NULL) fail("Failed to load glfw function glfwGetWindowContentScale with error: %s", dlerror()); + *(void **) (&glfwGetDoubleClickInterval_impl) = dlsym(handle, "glfwGetDoubleClickInterval"); + if (glfwGetDoubleClickInterval_impl == NULL) fail("Failed to load glfw function glfwGetDoubleClickInterval with error: %s", dlerror()); + *(void **) (&glfwGetWindowOpacity_impl) = dlsym(handle, "glfwGetWindowOpacity"); if (glfwGetWindowOpacity_impl == NULL) fail("Failed to load glfw function glfwGetWindowOpacity with error: %s", dlerror()); diff --git a/kitty/glfw-wrapper.h b/kitty/glfw-wrapper.h index 1dff47962..e0634f008 100644 --- a/kitty/glfw-wrapper.h +++ b/kitty/glfw-wrapper.h @@ -1544,6 +1544,10 @@ typedef void (*glfwGetWindowContentScale_func)(GLFWwindow*, float*, float*); glfwGetWindowContentScale_func glfwGetWindowContentScale_impl; #define glfwGetWindowContentScale glfwGetWindowContentScale_impl +typedef double (*glfwGetDoubleClickInterval_func)(GLFWwindow*); +glfwGetDoubleClickInterval_func glfwGetDoubleClickInterval_impl; +#define glfwGetDoubleClickInterval glfwGetDoubleClickInterval_impl + typedef float (*glfwGetWindowOpacity_func)(GLFWwindow*); glfwGetWindowOpacity_func glfwGetWindowOpacity_impl; #define glfwGetWindowOpacity glfwGetWindowOpacity_impl diff --git a/kitty/glfw.c b/kitty/glfw.c index e0e0667dd..c800c5de2 100644 --- a/kitty/glfw.c +++ b/kitty/glfw.c @@ -545,6 +545,7 @@ create_os_window(PyObject UNUSED *self, PyObject *args) { }} CC(standard, IBEAM); CC(click, HAND); CC(arrow, ARROW); #undef CC + if (OPT(click_interval) < 0) OPT(click_interval) = glfwGetDoubleClickInterval(glfw_window); is_first_window = false; } OSWindow *w = add_os_window();