Skip to content

Commit

Permalink
On X11, update keymap on XkbMapNotify
Browse files Browse the repository at this point in the history
This is required to handle xmodmap.

Fixes #3338.
  • Loading branch information
kchibisov committed Dec 31, 2023
1 parent 63d52aa commit 2e61011
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Unreleased` header.

# Unreleased

- On X11, keymap not updated from xmodmap.
- On X11, reduce the amount of time spent fetching screen resources.
- On Wayland, fix `Window::request_inner_size` being overwritten by resize.
- On Wayland, fix `Window::inner_size` not using the correct rounding.
Expand Down
15 changes: 15 additions & 0 deletions src/platform_impl/linux/x11/event_processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) };
Expand Down
4 changes: 3 additions & 1 deletion src/platform_impl/linux/x11/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,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();

Expand Down

0 comments on commit 2e61011

Please sign in to comment.