diff --git a/src/backend/input.rs b/src/backend/input.rs index d843e92..0acb552 100644 --- a/src/backend/input.rs +++ b/src/backend/input.rs @@ -1,6 +1,7 @@ //! Common traits for input backends to receive input from. use std::error::Error; +use std::string::ToString; use wayland_server::EventLoopHandle; /// A seat describes a group of input devices and at least one @@ -14,16 +15,18 @@ use wayland_server::EventLoopHandle; /// hash, but capabilities of cloned and copied `Seat`s will not be updated by smithay. /// Always referr to the `Seat` given by a callback for up-to-date information. You may /// use this to calculate the differences since the last callback. -#[derive(Debug, Clone, Copy, Eq)] +#[derive(Debug, Clone, Eq)] pub struct Seat { id: u64, + name: String, capabilities: SeatCapabilities, } impl Seat { - pub(crate) fn new(id: u64, capabilities: SeatCapabilities) -> Seat { + pub(crate) fn new(id: u64, name: S, capabilities: SeatCapabilities) -> Seat { Seat { id: id, + name: name.to_string(), capabilities: capabilities, } } @@ -36,6 +39,11 @@ impl Seat { pub fn capabilities(&self) -> &SeatCapabilities { &self.capabilities } + + /// Get the name of this `Seat` + pub fn name(&self) -> &str { + &*self.name + } } impl ::std::cmp::PartialEq for Seat { diff --git a/src/backend/libinput.rs b/src/backend/libinput.rs index bdbb655..e81a41d 100644 --- a/src/backend/libinput.rs +++ b/src/backend/libinput.rs @@ -318,7 +318,7 @@ impl backend::InputBackend for LibinputInputBackend { let device_seat = added.seat(); self.devices.push(added); - match self.seats.entry(device_seat) { + match self.seats.entry(device_seat.clone()) { Entry::Occupied(mut seat_entry) => { let old_seat = seat_entry.get_mut(); { @@ -335,8 +335,15 @@ impl backend::InputBackend for LibinputInputBackend { Entry::Vacant(seat_entry) => { let mut hasher = DefaultHasher::default(); seat_entry.key().hash(&mut hasher); - let seat = - seat_entry.insert(backend::Seat::new(hasher.finish(), new_caps)); + let seat = seat_entry.insert(backend::Seat::new( + hasher.finish(), + format!( + "{}:{}", + device_seat.physical_name(), + device_seat.logical_name() + ), + new_caps, + )); if let Some(ref mut handler) = self.handler { trace!(self.logger, "Calling on_seat_created with {:?}", seat); handler.on_seat_created(evlh, seat); @@ -384,9 +391,9 @@ impl backend::InputBackend for LibinputInputBackend { } // it has, notify about updates } else if let Some(ref mut handler) = self.handler { - let seat = self.seats[&device_seat]; + let seat = &self.seats[&device_seat]; trace!(self.logger, "Calling on_seat_changed with {:?}", seat); - handler.on_seat_changed(evlh, &seat); + handler.on_seat_changed(evlh, seat); } } } diff --git a/src/backend/winit.rs b/src/backend/winit.rs index 3a8fceb..c5f114e 100644 --- a/src/backend/winit.rs +++ b/src/backend/winit.rs @@ -167,6 +167,7 @@ where key_counter: 0, seat: Seat::new( 0, + "winit", SeatCapabilities { pointer: true, keyboard: true,