Merge branch 'copilot/add-keyboard-repeat-delay-function' of https://github.com/kovidgoyal/kitty

This commit is contained in:
Kovid Goyal 2026-03-23 20:37:10 +05:30
commit e4b505b6ca
No known key found for this signature in database
GPG key ID: 06BC317B515ACE7C
10 changed files with 49 additions and 0 deletions

View file

@ -178,6 +178,8 @@ 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 initial delay and repeat interval from the OS, implemented for X11, Wayland and Cocoa backends
0.46.2 [2026-03-21]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

View file

@ -2782,6 +2782,12 @@ monotonic_t _glfwPlatformGetDoubleClickInterval(_GLFWwindow* window UNUSED)
return s_double_to_monotonic_t([NSEvent doubleClickInterval]);
}
void _glfwPlatformGetKeyboardRepeatDelay(monotonic_t *delay, monotonic_t *interval)
{
if (delay) *delay = s_double_to_monotonic_t([NSEvent keyRepeatDelay]);
if (interval) *interval = s_double_to_monotonic_t([NSEvent keyRepeatInterval]);
}
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 void glfwGetKeyboardRepeatDelay(monotonic_t *delay, monotonic_t *interval);
/*! @brief Returns the value of an input option for the specified window.
*

7
glfw/input.c vendored
View file

@ -720,6 +720,13 @@ GLFWAPI bool glfwGrabKeyboard(int grab) {
return _glfw.keyboard_grabbed;
}
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)
{
_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);
void _glfwPlatformGetKeyboardRepeatDelay(monotonic_t *delay, monotonic_t *interval);
void _glfwPlatformIconifyWindow(_GLFWwindow* window);
void _glfwPlatformRestoreWindow(_GLFWwindow* window);
void _glfwPlatformMaximizeWindow(_GLFWwindow* window);

6
glfw/null_window.c vendored
View file

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

7
glfw/wl_window.c vendored
View file

@ -1769,6 +1769,13 @@ monotonic_t _glfwPlatformGetDoubleClickInterval(_GLFWwindow* window UNUSED)
return ms_to_monotonic_t(500ll);
}
void _glfwPlatformGetKeyboardRepeatDelay(monotonic_t *delay, monotonic_t *interval)
{
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)
{
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);
}
void _glfwPlatformGetKeyboardRepeatDelay(monotonic_t *delay, monotonic_t *interval)
{
XkbDescPtr xkb = XkbAllocKeyboard();
if (xkb) {
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);
}
}
void _glfwPlatformIconifyWindow(_GLFWwindow* window)
{
XIconifyWindow(_glfw.x11.display, window->x11.handle, _glfw.x11.screen);

3
kitty/glfw-wrapper.c generated
View file

@ -296,6 +296,9 @@ load_glfw(const char* path) {
*(void **) (&glfwGrabKeyboard_impl) = dlsym(handle, "glfwGrabKeyboard");
if (glfwGrabKeyboard_impl == NULL) fail("Failed to load glfw function glfwGrabKeyboard with error: %s", dlerror());
*(void **) (&glfwGetKeyboardRepeatDelay_impl) = dlsym(handle, "glfwGetKeyboardRepeatDelay");
if (glfwGetKeyboardRepeatDelay_impl == NULL) fail("Failed to load glfw function glfwGetKeyboardRepeatDelay with error: %s", dlerror());
*(void **) (&glfwGetInputMode_impl) = dlsym(handle, "glfwGetInputMode");
if (glfwGetInputMode_impl == NULL) fail("Failed to load glfw function glfwGetInputMode with error: %s", dlerror());

4
kitty/glfw-wrapper.h generated
View file

@ -2206,6 +2206,10 @@ typedef bool (*glfwGrabKeyboard_func)(int);
GFW_EXTERN glfwGrabKeyboard_func glfwGrabKeyboard_impl;
#define glfwGrabKeyboard glfwGrabKeyboard_impl
typedef void (*glfwGetKeyboardRepeatDelay_func)(monotonic_t*, monotonic_t*);
GFW_EXTERN glfwGetKeyboardRepeatDelay_func glfwGetKeyboardRepeatDelay_impl;
#define glfwGetKeyboardRepeatDelay glfwGetKeyboardRepeatDelay_impl
typedef int (*glfwGetInputMode_func)(GLFWwindow*, int);
GFW_EXTERN glfwGetInputMode_func glfwGetInputMode_impl;
#define glfwGetInputMode glfwGetInputMode_impl