Fix x11 ModifiersState

This commit is contained in:
Rukai 2017-07-15 23:25:19 +10:00 committed by Benjamin Saunders
parent a1d2ee6ecf
commit e1e21ded28
2 changed files with 11 additions and 23 deletions

View file

@ -1,6 +1,6 @@
[package]
name = "winit"
version = "0.7.4"
version = "0.7.5"
authors = ["The winit contributors, Pierre Krieger <pierre.krieger1708@gmail.com>"]
description = "Cross-platform window creation library."
keywords = ["windowing"]

View file

@ -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()
};