On X11, update keymap on XkbMapNotify

This is required to handle xmodmap.

Fixes #3338.
This commit is contained in:
Kirill Chibisov 2023-12-30 01:10:38 +04:00 committed by GitHub
parent 8f6de4ef4b
commit 5a1d3e4656
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 1 deletions

View file

@ -1282,6 +1282,21 @@ impl<T: 'static> EventProcessor<T> {
unsafe { self.kb_state.init_with_x11_keymap() };
}
}
ffi::XkbMapNotify => {
let prev_mods = self.kb_state.mods_state();
unsafe { self.kb_state.init_with_x11_keymap() };
let new_mods = self.kb_state.mods_state();
if prev_mods != new_mods {
if let Some(window) = self.active_window {
callback(Event::WindowEvent {
window_id: mkwid(window),
event: WindowEvent::ModifiersChanged(
Into::<ModifiersState>::into(new_mods).into(),
),
});
}
}
}
ffi::XkbStateNotify => {
let xev =
unsafe { &*(xev as *const _ as *const ffi::XkbStateNotifyEvent) };

View file

@ -365,7 +365,9 @@ impl<T: 'static> EventLoop<T> {
.xconn
.select_xkb_events(
0x100, // Use the "core keyboard device"
xkb::EventType::NEW_KEYBOARD_NOTIFY | xkb::EventType::STATE_NOTIFY,
xkb::EventType::NEW_KEYBOARD_NOTIFY
| xkb::EventType::MAP_NOTIFY
| xkb::EventType::STATE_NOTIFY,
)
.unwrap();