surfaceHandleEnter() and surfaceHandleLeave() passed the event's output
argument straight to wl_output_get_user_data(). Wayland delivers object
arguments as NULL when the object was destroyed client-side before the
event was dispatched, even for arguments declared non-nullable, so this
segfaults whenever a wl_output global goes away while a window is open.
Easily reproduced with a hardware KVM or a monitor input switch.
Also fixes two pre-existing problems in surfaceHandleLeave():
- The removal loop stopped at monitorsCount - 1, so it never compared the
last entry, and the trailing unconditional
window->wl.monitors[--window->wl.monitorsCount] = NULL
dropped the last monitor whether or not it was the one that was left.
A leave for a monitor not in the list therefore evicted an unrelated
one.
- That same statement ran even when monitorsCount was 0, writing to
monitors[-1] and leaving the count negative.
Both are replaced with the remove_i_from_array() loop already used for
this array in registryHandleGlobalRemove().
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
On X11 glfw_xkb_compile_keymap() gets its state from
xkb_x11_state_new_from_device(), which seeds it with the server's physical
modifier mask. Every other path into that state goes through
glfw_xkb_update_modifiers(), where the permutation is applied, so after a
keymap reload the state held physical modifiers until the next XkbStateNotify
happened to arrive. Any key pressed in that window was encoded with the
modifier on the keycap: with ctrl held across a reload under
`remap_modifiers ctrl:super`, Ctrl+A reached the child as a literal 0x01.
Keymap reloads are routine - switching layout causes one, and so does any
client asking X for a keysym it must bind to a spare keycode.
Re-apply the permutation to the freshly loaded state, after
glfw_xkb_update_masks() has computed the modifier indices it is expressed in.
On Wayland the new state is empty, so this is a no-op there.
Adds remap_modifier config option to present one modifier key to kitty
as another, as discussed in issue #1077. Resolves merge conflicts by
adopting master's formatting style (multi-line macros, pointer spacing)
while preserving all new PR functionality.
Co-Authored-By: Bjoern <bjohas@users.noreply.github.com>