mirror of
https://github.com/rust-windowing/winit.git
synced 2026-09-01 14:20:05 -04:00
winit-x11: replace XQueryKeymap with equivalent x11rb call (#4497)
And slightly optimize the first_bit helper function.
This commit is contained in:
@@ -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()
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user