diff --git a/Cargo.toml b/Cargo.toml index 3a7bb419..25e34d44 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "winit" -version = "0.7.4" +version = "0.7.5" authors = ["The winit contributors, Pierre Krieger "] description = "Cross-platform window creation library." keywords = ["windowing"] diff --git a/src/platform/linux/x11/mod.rs b/src/platform/linux/x11/mod.rs index cddbd265..726bd271 100644 --- a/src/platform/linux/x11/mod.rs +++ b/src/platform/linux/x11/mod.rs @@ -266,8 +266,16 @@ impl EventsLoop { let xkev: &mut ffi::XKeyEvent = xev.as_mut(); - - let mut ev_mods = ModifiersState::default(); + let ev_mods = { + // Translate x event state to mods + let state = xkev.state; + ModifiersState { + alt: state & ffi::Mod1Mask != 0, + shift: state & ffi::ShiftMask != 0, + ctrl: state & ffi::ControlMask != 0, + logo: state & ffi::Mod4Mask != 0, + } + }; let keysym = unsafe { (self.display.xlib.XKeycodeToKeysym)(self.display.display, xkev.keycode as ffi::KeyCode, 0) @@ -311,26 +319,6 @@ impl EventsLoop { &mut keysym, &mut status); } - { - // Translate x event state to mods - let state = xkev.state; - if (state & ffi::Mod1Mask) != 0 { - ev_mods.alt = true; - } - - if (state & ffi::ShiftMask) != 0 { - ev_mods.shift = true; - } - - if (state & ffi::ControlMask) != 0 { - ev_mods.ctrl = true; - } - - if (state & ffi::Mod4Mask) != 0 { - ev_mods.logo = true; - } - } - str::from_utf8(&buffer[..count as usize]).unwrap_or("").to_string() };