backends/native: Avoid redundant changes to sticky keys state mask

Sticky keys configuration changes reset the pressed modifier state mask,
even though the XKB state might already match with the expected new
state. In those cases we can avoid the XKB state mask update completely.

This also fixes a crash at initialization with sticky keys toggled on,
since configuring the device a11y settings will trigger a XKB state
mask merely reassuring the initial state with no modifiers pressed,
while the connection between the ClutterSeat and the impl object has
not been set up yet. This crash was introduced by commit 00bb4190b
("backends/native: Drop device_native->seat_impl field").

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3392>
This commit is contained in:
Carlos Garnacho 2023-11-13 10:55:46 +01:00 committed by Marge Bot
parent ad7ce7c7ca
commit 9399c984cc

View File

@ -495,6 +495,10 @@ update_internal_xkb_state (MetaInputDeviceNative *device,
xkb_mod_mask_t group_mods;
struct xkb_state *xkb_state;
if (device->stickykeys_latched_mask == new_latched_mask &&
device->stickykeys_locked_mask == new_locked_mask)
return;
g_rw_lock_writer_lock (&seat_impl->state_lock);
xkb_state = meta_seat_impl_get_xkb_state_in_impl (seat_impl);