Skip to content

Commit

Permalink
Don't listen to XkbMapNotify
Browse files Browse the repository at this point in the history
This event appears to be subsumed by XkbNewKeyboardNotify when we start
listening to XkbNewKeyboardNotify, although the documentation feels a
little unclear on the matter.
  • Loading branch information
maroider committed Jul 6, 2022
1 parent ba8023a commit 0676c39
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 24 deletions.
37 changes: 14 additions & 23 deletions src/platform_impl/linux/x11/event_processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1178,30 +1178,21 @@ impl<T: 'static> EventProcessor<T> {
_ => {
if event_type == self.xkbext.first_event_id {
let xev = unsafe { &*(xev as *const _ as *const ffi::XkbAnyEvent) };
match xev.xkb_type {
ffi::XkbNewKeyboardNotify => {
let xev = unsafe {
&*(xev as *const _ as *const ffi::XkbNewKeyboardNotifyEvent)
};
let keycodes_changed_flag = 0x1;
let geometry_changed_flag = 0x1 << 1;

// TODO: What do we do about the "geometry changed" case?
let keycodes_changed =
util::has_flag(xev.changed, keycodes_changed_flag);
let geometry_changed =
util::has_flag(xev.changed, geometry_changed_flag);

if xev.device == self.kb_state.core_keyboard_id
&& (keycodes_changed || geometry_changed)
{
unsafe { self.kb_state.init_with_x11_keymap() };
}
}
ffi::XkbMapNotify => {
todo!("Handle this");
if let ffi::XkbNewKeyboardNotify = xev.xkb_type {
let xev =
unsafe { &*(xev as *const _ as *const ffi::XkbNewKeyboardNotifyEvent) };
let keycodes_changed_flag = 0x1;
let geometry_changed_flag = 0x1 << 1;

// TODO: What do we do about the "geometry changed" case?
let keycodes_changed = util::has_flag(xev.changed, keycodes_changed_flag);
let geometry_changed = util::has_flag(xev.changed, geometry_changed_flag);

if xev.device == self.kb_state.core_keyboard_id
&& (keycodes_changed || geometry_changed)
{
unsafe { self.kb_state.init_with_x11_keymap() };
}
_ => {}
}
}
if event_type == self.randr_event_offset {
Expand Down
2 changes: 1 addition & 1 deletion src/platform_impl/linux/x11/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ impl<T: 'static> EventLoop<T> {
.xconn
.select_xkb_events(
0x100, // Use the "core keyboard device"
ffi::XkbNewKeyboardNotifyMask | ffi::XkbMapNotifyMask,
ffi::XkbNewKeyboardNotifyMask,
)
.unwrap()
.queue();
Expand Down

0 comments on commit 0676c39

Please sign in to comment.