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:
parent
998ee22ecb
commit
6b86e7db5d
9 changed files with 24 additions and 18 deletions
|
|
@ -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]
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
|
|
|||
|
|
@ -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
2
glfw/glfw3.h
vendored
|
|
@ -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
8
glfw/input.c
vendored
|
|
@ -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
2
glfw/internal.h
vendored
|
|
@ -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
5
glfw/null_window.c
vendored
|
|
@ -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
6
glfw/wl_window.c
vendored
|
|
@ -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
10
glfw/x11_window.c
vendored
|
|
@ -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
2
kitty/glfw-wrapper.h
generated
|
|
@ -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
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue