From 406a92fc69dc0e786195e982590be2e84bfc9bf8 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Wed, 19 Aug 2026 04:56:27 +0530 Subject: [PATCH] handle unknown pointer names in OSC 22 more gracefully Also, allow using beam and arrow as aliases of text and default when setting pointer shapes. These are the names kitty itself reports, so they should be allowed in addition to the canonical list from the spec. Fixes #10372 --- gen/cursors.py | 4 ++++ kitty/glfw-wrapper.h | 2 +- kitty/screen.c | 2 ++ kitty/window.py | 5 ++++- 4 files changed, 11 insertions(+), 2 deletions(-) diff --git a/gen/cursors.py b/gen/cursors.py index 31c7faac2..fa63149c9 100755 --- a/gen/cursors.py +++ b/gen/cursors.py @@ -112,6 +112,10 @@ def main(args: list[str] = sys.argv) -> None: if x not in css_to_enum: css_to_enum[x] = v + for x, v in kitty_to_enum_map.items(): + if x not in css_to_enum: + css_to_enum[x] = v + glfw_enum.append('GLFW_INVALID_CURSOR') patch_file('glfw/glfw3.h', 'mouse cursor shapes', '\n'.join(f' {x},' for x in glfw_enum)) patch_file('glfw/wl_window.c', 'glfw to wayland mapping', '\n'.join(f' C({g}, {x});' for g, x in glfw_wayland.items())) diff --git a/kitty/glfw-wrapper.h b/kitty/glfw-wrapper.h index d13b2c6f5..c19bef2be 100644 --- a/kitty/glfw-wrapper.h +++ b/kitty/glfw-wrapper.h @@ -898,7 +898,7 @@ typedef enum { GLFW_GRAB_CURSOR, GLFW_GRABBING_CURSOR, GLFW_INVALID_CURSOR, - /* end mouse cursor shapes */ +/* end mouse cursor shapes */ } GLFWCursorShape; /*! @} */ diff --git a/kitty/screen.c b/kitty/screen.c index 7146774e6..b6c6b9429 100644 --- a/kitty/screen.c +++ b/kitty/screen.c @@ -2290,6 +2290,8 @@ change_pointer_shape(Screen *self, PyObject *args) { else if (strcmp("hand1", css_name) == 0) s = GRAB_POINTER; else if (strcmp("closedhand", css_name) == 0) s = GRABBING_POINTER; else if (strcmp("dnd-none", css_name) == 0) s = GRABBING_POINTER; + else if (strcmp("arrow", css_name) == 0) s = DEFAULT_POINTER; + else if (strcmp("beam", css_name) == 0) s = TEXT_POINTER; /* end css to enum */ if (s == INVALID_POINTER && css_name[0] != 0) { PyErr_Format(PyExc_KeyError, "Not a known pointer shape: %s", css_name); diff --git a/kitty/window.py b/kitty/window.py index 3361a22c2..4a0ccd29b 100644 --- a/kitty/window.py +++ b/kitty/window.py @@ -2856,7 +2856,10 @@ def set_pointer_shape(screen: Screen, value: str, os_window_id: int = 0) -> str: if op in '=>': for v in value.split(','): if v or op == '=': - screen.change_pointer_shape(op, v) + try: + screen.change_pointer_shape(op, v) + except KeyError: + log_error(f'Ignoring unknown pointer shape name: {v!r}') if os_window_id and current_focused_os_window_id() == os_window_id: update_pointer_shape(os_window_id) elif op == '<':