Extend glfwGetKeyboardRepeatDelay() to return both initial delay and repeat interval

Co-authored-by: kovidgoyal <1308621+kovidgoyal@users.noreply.github.com>
Agent-Logs-Url: https://github.com/kovidgoyal/kitty/sessions/bde9bf2e-a0dd-4ccd-8385-6a37be1e025f
This commit is contained in:
copilot-swe-agent[bot] 2026-03-23 11:58:48 +00:00
parent 998ee22ecb
commit 6b86e7db5d
9 changed files with 24 additions and 18 deletions

View file

@ -178,7 +178,7 @@ Detailed list of changes
- Command palette: Improve searching to use word level matching (:pull:`9727`)
- GLFW: Add ``glfwGetKeyboardRepeatDelay()`` to the GLFW API to query the current keyboard key-repeat delay from the OS, implemented for X11, Wayland and Cocoa backends
- GLFW: Add ``glfwGetKeyboardRepeatDelay()`` to the GLFW API to query the current keyboard key-repeat initial delay and repeat interval from the OS, implemented for X11, Wayland and Cocoa backends
0.46.2 [2026-03-21]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

View file

@ -2782,9 +2782,10 @@ monotonic_t _glfwPlatformGetDoubleClickInterval(_GLFWwindow* window UNUSED)
return s_double_to_monotonic_t([NSEvent doubleClickInterval]);
}
monotonic_t _glfwPlatformGetKeyboardRepeatDelay(void)
void _glfwPlatformGetKeyboardRepeatDelay(monotonic_t *delay, monotonic_t *interval)
{
return s_double_to_monotonic_t([NSEvent keyRepeatDelay]);
if (delay) *delay = s_double_to_monotonic_t([NSEvent keyRepeatDelay]);
if (interval) *interval = s_double_to_monotonic_t([NSEvent keyRepeatInterval]);
}
void _glfwPlatformIconifyWindow(_GLFWwindow* window)

2
glfw/glfw3.h vendored
View file

@ -4370,7 +4370,7 @@ GLFWAPI void glfwPostEmptyEvent(void);
GLFWAPI bool glfwGetIgnoreOSKeyboardProcessing(void);
GLFWAPI void glfwSetIgnoreOSKeyboardProcessing(bool enabled);
GLFWAPI bool glfwGrabKeyboard(int grab);
GLFWAPI monotonic_t glfwGetKeyboardRepeatDelay(void);
GLFWAPI void glfwGetKeyboardRepeatDelay(monotonic_t *delay, monotonic_t *interval);
/*! @brief Returns the value of an input option for the specified window.
*

8
glfw/input.c vendored
View file

@ -720,9 +720,11 @@ GLFWAPI bool glfwGrabKeyboard(int grab) {
return _glfw.keyboard_grabbed;
}
GLFWAPI monotonic_t glfwGetKeyboardRepeatDelay(void) {
_GLFW_REQUIRE_INIT_OR_RETURN(ms_to_monotonic_t(500ll));
return _glfwPlatformGetKeyboardRepeatDelay();
GLFWAPI void glfwGetKeyboardRepeatDelay(monotonic_t *delay, monotonic_t *interval) {
_GLFW_REQUIRE_INIT();
if (delay) *delay = ms_to_monotonic_t(500ll);
if (interval) *interval = ms_to_monotonic_t(30ll);
_glfwPlatformGetKeyboardRepeatDelay(delay, interval);
}
GLFWAPI int glfwGetInputMode(GLFWwindow* handle, int mode)

2
glfw/internal.h vendored
View file

@ -745,7 +745,7 @@ void _glfwPlatformGetWindowFrameSize(_GLFWwindow* window,
void _glfwPlatformGetWindowContentScale(_GLFWwindow* window,
float* xscale, float* yscale);
monotonic_t _glfwPlatformGetDoubleClickInterval(_GLFWwindow* window);
monotonic_t _glfwPlatformGetKeyboardRepeatDelay(void);
void _glfwPlatformGetKeyboardRepeatDelay(monotonic_t *delay, monotonic_t *interval);
void _glfwPlatformIconifyWindow(_GLFWwindow* window);
void _glfwPlatformRestoreWindow(_GLFWwindow* window);
void _glfwPlatformMaximizeWindow(_GLFWwindow* window);

5
glfw/null_window.c vendored
View file

@ -311,9 +311,10 @@ monotonic_t _glfwPlatformGetDoubleClickInterval(_GLFWwindow* window UNUSED)
return ms_to_monotonic_t(500ll);
}
monotonic_t _glfwPlatformGetKeyboardRepeatDelay(void)
void _glfwPlatformGetKeyboardRepeatDelay(monotonic_t *delay, monotonic_t *interval)
{
return ms_to_monotonic_t(500ll);
if (delay) *delay = ms_to_monotonic_t(500ll);
if (interval) *interval = ms_to_monotonic_t(30ll);
}
void _glfwPlatformIconifyWindow(_GLFWwindow* window)

6
glfw/wl_window.c vendored
View file

@ -1769,9 +1769,11 @@ monotonic_t _glfwPlatformGetDoubleClickInterval(_GLFWwindow* window UNUSED)
return ms_to_monotonic_t(500ll);
}
monotonic_t _glfwPlatformGetKeyboardRepeatDelay(void)
void _glfwPlatformGetKeyboardRepeatDelay(monotonic_t *delay, monotonic_t *interval)
{
return _glfw.wl.keyboardRepeatDelay;
if (delay) *delay = _glfw.wl.keyboardRepeatDelay;
if (interval && _glfw.wl.keyboardRepeatRate > 0)
*interval = s_to_monotonic_t(1ll) / (monotonic_t)_glfw.wl.keyboardRepeatRate;
}
void _glfwPlatformIconifyWindow(_GLFWwindow* window)

10
glfw/x11_window.c vendored
View file

@ -2876,16 +2876,16 @@ monotonic_t _glfwPlatformGetDoubleClickInterval(_GLFWwindow* window UNUSED)
return ms_to_monotonic_t(500ll);
}
monotonic_t _glfwPlatformGetKeyboardRepeatDelay(void)
void _glfwPlatformGetKeyboardRepeatDelay(monotonic_t *delay, monotonic_t *interval)
{
monotonic_t delay = ms_to_monotonic_t(500ll);
XkbDescPtr xkb = XkbAllocKeyboard();
if (xkb) {
if (XkbGetControls(_glfw.x11.display, XkbRepeatKeysMask, xkb) == Success)
delay = ms_to_monotonic_t(xkb->ctrls->repeat_delay);
if (XkbGetControls(_glfw.x11.display, XkbRepeatKeysMask, xkb) == Success) {
if (delay) *delay = ms_to_monotonic_t(xkb->ctrls->repeat_delay);
if (interval) *interval = ms_to_monotonic_t(xkb->ctrls->repeat_interval);
}
XkbFreeKeyboard(xkb, 0, True);
}
return delay;
}
void _glfwPlatformIconifyWindow(_GLFWwindow* window)

2
kitty/glfw-wrapper.h generated
View file

@ -2206,7 +2206,7 @@ typedef bool (*glfwGrabKeyboard_func)(int);
GFW_EXTERN glfwGrabKeyboard_func glfwGrabKeyboard_impl;
#define glfwGrabKeyboard glfwGrabKeyboard_impl
typedef monotonic_t (*glfwGetKeyboardRepeatDelay_func)(void);
typedef void (*glfwGetKeyboardRepeatDelay_func)(monotonic_t*, monotonic_t*);
GFW_EXTERN glfwGetKeyboardRepeatDelay_func glfwGetKeyboardRepeatDelay_impl;
#define glfwGetKeyboardRepeatDelay glfwGetKeyboardRepeatDelay_impl