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
This commit is contained in:
Kovid Goyal 2026-08-19 04:56:27 +05:30
parent 0ecb10d158
commit 406a92fc69
No known key found for this signature in database
GPG key ID: 06BC317B515ACE7C
4 changed files with 11 additions and 2 deletions

View file

@ -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()))

2
kitty/glfw-wrapper.h generated
View file

@ -898,7 +898,7 @@ typedef enum {
GLFW_GRAB_CURSOR,
GLFW_GRABBING_CURSOR,
GLFW_INVALID_CURSOR,
/* end mouse cursor shapes */
/* end mouse cursor shapes */
} GLFWCursorShape;
/*! @} */

View file

@ -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);

View file

@ -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 == '<':