Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wayland: Implement key repetition #371

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ dwmapi-sys = "0.1"
wayland-client = { version = "0.12.0", features = ["dlopen"] }
wayland-protocols = { version = "0.12.0", features = ["unstable_protocols"] }
wayland-kbd = "0.13.0"
wayland-window = "0.13.0"
wayland-window = "0.13.2"
x11-dl = "2.8"
percent-encoding = "1.0"
tokio-core = "0.1"
tokio-timer = "0.1"
futures = "0.1"
14 changes: 14 additions & 0 deletions src/events.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
use std::path::PathBuf;
use {WindowId, DeviceId};

#[cfg(any(target_os = "linux", target_os = "freebsd", target_os = "dragonfly", target_os = "openbsd"))]
use wayland_client::protocol::wl_keyboard;

/// Describes a generic event.
#[derive(Clone, Debug)]
pub enum Event {
Expand Down Expand Up @@ -213,6 +216,17 @@ pub enum ElementState {
Released,
}

#[cfg(any(target_os = "linux", target_os = "freebsd", target_os = "dragonfly", target_os = "openbsd"))]
impl From<wl_keyboard::KeyState> for ElementState {
#[inline(always)]
fn from(state: wl_keyboard::KeyState) -> ElementState {
match state {
wl_keyboard::KeyState::Pressed => ElementState::Pressed,
wl_keyboard::KeyState::Released => ElementState::Released,
}
}
}

/// Describes a button of a mouse controller.
#[derive(Debug, Hash, PartialEq, Eq, Clone, Copy)]
pub enum MouseButton {
Expand Down
6 changes: 6 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,12 @@ extern crate percent_encoding;
#[cfg(any(target_os = "linux", target_os = "freebsd", target_os = "dragonfly", target_os = "openbsd"))]
#[macro_use]
extern crate wayland_client;
#[cfg(any(target_os = "linux", target_os = "freebsd", target_os = "dragonfly", target_os = "openbsd"))]
extern crate tokio_core;
#[cfg(any(target_os = "linux", target_os = "freebsd", target_os = "dragonfly", target_os = "openbsd"))]
extern crate tokio_timer;
#[cfg(any(target_os = "linux", target_os = "freebsd", target_os = "dragonfly", target_os = "openbsd"))]
extern crate futures;

pub use events::*;
pub use window::{AvailableMonitorsIter, MonitorId};
Expand Down
26 changes: 14 additions & 12 deletions src/platform/linux/wayland/event_loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,25 +128,26 @@ impl EventsLoop {

let store = event_queue.state().insert(WindowStore::new());

let seat_idata = SeatIData {
sink: sink.clone(),
keyboard: None,
pointer: None,
touch: None,
windows_token: store.clone()
};

let mut me = EventsLoop {
display: Arc::new(display),
evq: RefCell::new(event_queue),
sink: sink,
sink: sink.clone(),
pending_wakeup: Arc::new(AtomicBool::new(false)),
store: store,
store: store.clone(),
ctxt_token: ctxt_token,
env_token: env_token,
cleanup_needed: Arc::new(Mutex::new(false))
};

let seat_idata = SeatIData {
sink: sink,
keyboard: None,
pointer: None,
touch: None,
windows_token: store,
events_loop_proxy: me.create_proxy(),
};

me.init_seat(|evqh, seat| {
evqh.register(seat, seat_implementation(), seat_idata);
});
Expand Down Expand Up @@ -441,7 +442,8 @@ struct SeatIData {
pointer: Option<wl_pointer::WlPointer>,
keyboard: Option<wl_keyboard::WlKeyboard>,
touch: Option<wl_touch::WlTouch>,
windows_token: StateToken<WindowStore>
windows_token: StateToken<WindowStore>,
events_loop_proxy: EventsLoopProxy,
}

fn seat_implementation() -> wl_seat::Implementation<SeatIData> {
Expand All @@ -467,7 +469,7 @@ fn seat_implementation() -> wl_seat::Implementation<SeatIData> {
// create keyboard if applicable
if capabilities.contains(wl_seat::Capability::Keyboard) && idata.keyboard.is_none() {
let kbd = seat.get_keyboard().expect("Seat is not dead");
init_keyboard(evqh, &kbd, &idata.sink);
init_keyboard(evqh, idata.events_loop_proxy.clone(), &kbd, &idata.sink);
idata.keyboard = Some(kbd);
}
// destroy keyboard if applicable
Expand Down
Loading