Skip to content

backend/x11: Only call keymap_changed for new devices

Marcus Behel requested to merge MB3hel/mutter:fix-issue-398 into main

Fixes issue #398 by avoiding unnecessary keymap_changed calls.

Follows a somewhat similar approach to !579 (merged) however instead of ignoring all XkbNewKeyboardNotify events, it ignores any that are software triggered (anything but plugging in a new keyboard).

According to this page:

If req_major and req_minor are zero, the device change was not caused by a software request 
to the server — a spontaneous change has occurred, such as hot-plugging a new device.

My interpretation is that ignoring XkbNewKeyboardNotify without req_major and req_minor both equal to zero should filter out anything but first detection of any given keyboard. Thus preventing issues when alternating keypresses between multiple keyboards (or a keyboard and a mouse). But by handling the case where req_major and req_minor are zero, the proper bindings are grabbed for each keyboard's initial layout.

I do not know the X11 codebase well / at all, but with this patch I cannot trigger #822 (closed) with limited testing (I don't actually have keyboard of another layout, but with !579 (merged)'s changes I could still trigger #822 (closed) by changing the layout; with this change I cannot).

Since there is a lot of speculation on my part with this change, I think it would be best for some more testing to occur or for someone who knows more about this to look over it before merging (hence, I have marked it as draft for now).

Edited by Marcus Behel

Merge request reports