winit-x11: replace XQueryKeymap with equivalent x11rb call (#4497)

And slightly optimize the first_bit helper function.
This commit is contained in:
jgcodes2020
2026-03-16 22:15:48 -04:00
committed by GitHub
parent 0b6b794f01
commit 211ae8f6c7

View File

@@ -60,16 +60,18 @@ impl Iterator for KeymapIter<'_> {
impl XConnection { impl XConnection {
pub fn query_keymap(&self) -> Keymap { pub fn query_keymap(&self) -> Keymap {
let mut keys = [0; 32]; let keys = self
.xcb_connection()
unsafe { .query_keymap()
(self.xlib.XQueryKeymap)(self.display, keys.as_mut_ptr() as *mut c_char); .expect("Failed to query keymap")
} .reply()
.expect("Missing reply")
.keys;
Keymap { keys } Keymap { keys }
} }
} }
fn first_bit(b: u8) -> u8 { fn first_bit(b: u8) -> u8 {
1 << b.trailing_zeros() b & b.wrapping_neg()
} }