Merge pull request #148 from vberger/master

wayland: implement modifiers
This commit is contained in:
tomaka 2017-03-04 08:47:59 +01:00 committed by GitHub
commit d0ae5bda16
3 changed files with 22 additions and 4 deletions

View file

@ -38,6 +38,6 @@ dwmapi-sys = "0.1"
[target.'cfg(any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd", target_os = "openbsd"))'.dependencies] [target.'cfg(any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd", target_os = "openbsd"))'.dependencies]
wayland-client = { version = "0.7.4", features = ["dlopen"] } wayland-client = { version = "0.7.4", features = ["dlopen"] }
wayland-kbd = "0.6.2" wayland-kbd = "0.7.0"
wayland-window = "0.4.2" wayland-window = "0.4.2"
x11-dl = "2.8" x11-dl = "2.8"

View file

@ -629,7 +629,13 @@ impl wl_keyboard::Handler for WaylandEnv {
wl_keyboard::KeyState::Released => ElementState::Released, wl_keyboard::KeyState::Released => ElementState::Released,
}; };
let mut guard = eviter.lock().unwrap(); let mut guard = eviter.lock().unwrap();
// TODO implement ModifiersState // This is fallback impl if libxkbcommon was not available
// This case should probably never happen, as most wayland
// compositors _need_ libxkbcommon anyway...
//
// In this case, we don't have the modifiers state information
// anyway, as we need libxkbcommon to interpret it (it is
// supposed to be serialized by the compositor using libxkbcommon)
guard.push_back(Event::KeyboardInput( guard.push_back(Event::KeyboardInput(
state, state,
key as u8, key as u8,

View file

@ -25,6 +25,7 @@ impl wayland_kbd::Handler for KbdHandler {
_proxy: &wl_keyboard::WlKeyboard, _proxy: &wl_keyboard::WlKeyboard,
_serial: u32, _serial: u32,
_time: u32, _time: u32,
mods: &wayland_kbd::ModifiersState,
rawkey: u32, rawkey: u32,
keysym: u32, keysym: u32,
state: wl_keyboard::KeyState, state: wl_keyboard::KeyState,
@ -37,8 +38,19 @@ impl wayland_kbd::Handler for KbdHandler {
}; };
let vkcode = key_to_vkey(rawkey, keysym); let vkcode = key_to_vkey(rawkey, keysym);
let mut guard = eviter.lock().unwrap(); let mut guard = eviter.lock().unwrap();
// TODO implement ModifiersState guard.push_back(
guard.push_back(Event::KeyboardInput(state, rawkey as u8, vkcode, ModifiersState::default())); Event::KeyboardInput(
state,
rawkey as u8,
vkcode,
ModifiersState {
shift: mods.shift,
ctrl: mods.ctrl,
alt: mods.alt,
logo: mods.logo
}
)
);
// send char event only on key press, not release // send char event only on key press, not release
if let ElementState::Released = state { return } if let ElementState::Released = state { return }
if let Some(txt) = utf8 { if let Some(txt) = utf8 {