From 7aca2edb1361dec2429ecdec3c5848020a798790 Mon Sep 17 00:00:00 2001 From: Drakulix Date: Sat, 15 Apr 2017 00:24:23 +0200 Subject: [PATCH] Adjust InputBackend for libinput compatibility - Make id be an `u64` to be able to populate it by a hash - Add internal interface to get a mutable capabilities reference from a `Seat`. - `InputConfig` type does not need to be `Sized` on `InputBackend` --- src/backend/input.rs | 11 ++++++++--- src/backend/mod.rs | 3 ++- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/backend/input.rs b/src/backend/input.rs index 03d0ca5..65a0210 100644 --- a/src/backend/input.rs +++ b/src/backend/input.rs @@ -12,19 +12,24 @@ use std::error::Error; /// separated users, all with their own focus, input and cursor available. /// /// Seats can be checked for equality and hashed for differentiation. +// FIXME: Impl PartialEq, Eq and Hash only dependant on `id`. #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub struct Seat { - id: u32, + id: u64, capabilities: SeatCapabilities, } impl SeatInternal for Seat { - fn new(id: u32, capabilities: SeatCapabilities) -> Seat { + fn new(id: u64, capabilities: SeatCapabilities) -> Seat { Seat { id: id, capabilities: capabilities, } } + + fn capabilities_mut(&mut self) -> &mut SeatCapabilities { + &mut self.capabilities + } } impl Seat { @@ -182,7 +187,7 @@ pub enum TouchEvent { /// given events. pub trait InputBackend: Sized { /// Type of input device associated with the backend - type InputConfig; + type InputConfig: ?Sized; /// Type representing errors that may be returned when processing events type EventError: Error; diff --git a/src/backend/mod.rs b/src/backend/mod.rs index 4b79aed..bf235bb 100644 --- a/src/backend/mod.rs +++ b/src/backend/mod.rs @@ -28,7 +28,8 @@ pub use glium::*; /// Internal functions that need to be accessible by the different backend implementations trait SeatInternal { - fn new(id: u32, capabilities: input::SeatCapabilities) -> Self; + fn new(id: u64, capabilities: input::SeatCapabilities) -> Self; + fn capabilities_mut(&mut self) -> &mut input::SeatCapabilities; } trait TouchSlotInternal {