Add glfwGetKeyboardRepeatDelay() to the GLFW API for X11, Wayland and Cocoa

Co-authored-by: kovidgoyal <1308621+kovidgoyal@users.noreply.github.com>
Agent-Logs-Url: https://github.com/kovidgoyal/kitty/sessions/4765810b-ecf5-4348-ae3a-ff0ff481aaae
This commit is contained in:
copilot-swe-agent[bot]
2026-03-23 11:46:35 +00:00
parent 23b5e44ce5
commit 998ee22ecb
10 changed files with 43 additions and 0 deletions

View File

@@ -2782,6 +2782,11 @@ monotonic_t _glfwPlatformGetDoubleClickInterval(_GLFWwindow* window UNUSED)
return s_double_to_monotonic_t([NSEvent doubleClickInterval]);
}
monotonic_t _glfwPlatformGetKeyboardRepeatDelay(void)
{
return s_double_to_monotonic_t([NSEvent keyRepeatDelay]);
}
void _glfwPlatformIconifyWindow(_GLFWwindow* window)
{
[window->ns.object miniaturize:nil];

1
glfw/glfw3.h vendored
View File

@@ -4370,6 +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);
/*! @brief Returns the value of an input option for the specified window.
*

5
glfw/input.c vendored
View File

@@ -720,6 +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 int glfwGetInputMode(GLFWwindow* handle, int mode)
{
_GLFWwindow* window = (_GLFWwindow*) handle;

1
glfw/internal.h vendored
View File

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

5
glfw/null_window.c vendored
View File

@@ -311,6 +311,11 @@ monotonic_t _glfwPlatformGetDoubleClickInterval(_GLFWwindow* window UNUSED)
return ms_to_monotonic_t(500ll);
}
monotonic_t _glfwPlatformGetKeyboardRepeatDelay(void)
{
return ms_to_monotonic_t(500ll);
}
void _glfwPlatformIconifyWindow(_GLFWwindow* window)
{
if (_glfw.null.focusedWindow == window)

5
glfw/wl_window.c vendored
View File

@@ -1769,6 +1769,11 @@ monotonic_t _glfwPlatformGetDoubleClickInterval(_GLFWwindow* window UNUSED)
return ms_to_monotonic_t(500ll);
}
monotonic_t _glfwPlatformGetKeyboardRepeatDelay(void)
{
return _glfw.wl.keyboardRepeatDelay;
}
void _glfwPlatformIconifyWindow(_GLFWwindow* window)
{
if (window->wl.xdg.toplevel) {

12
glfw/x11_window.c vendored
View File

@@ -2876,6 +2876,18 @@ monotonic_t _glfwPlatformGetDoubleClickInterval(_GLFWwindow* window UNUSED)
return ms_to_monotonic_t(500ll);
}
monotonic_t _glfwPlatformGetKeyboardRepeatDelay(void)
{
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);
XkbFreeKeyboard(xkb, 0, True);
}
return delay;
}
void _glfwPlatformIconifyWindow(_GLFWwindow* window)
{
XIconifyWindow(_glfw.x11.display, window->x11.handle, _glfw.x11.screen);