backend.libinput: fix tracking of removed devices

This commit is contained in:
Victor Berger 2020-04-01 11:03:54 +02:00
parent e42ccc8aee
commit 63702a308a
1 changed files with 4 additions and 1 deletions

View File

@ -315,6 +315,7 @@ impl InputBackend for LibinputInputBackend {
}; };
let device_seat = added.seat(); let device_seat = added.seat();
info!(self.logger, "New device {:?} on seat {:?}", added.sysname(), device_seat.logical_name());
self.devices.push(added); self.devices.push(added);
match self.seats.entry(device_seat.clone()) { match self.seats.entry(device_seat.clone()) {
@ -354,9 +355,10 @@ impl InputBackend for LibinputInputBackend {
let removed = device_removed_event.device(); let removed = device_removed_event.device();
// remove device // remove device
self.devices.retain(|dev| *dev == removed); self.devices.retain(|dev| *dev != removed);
let device_seat = removed.seat(); let device_seat = removed.seat();
info!(self.logger, "Removed device {:?} on seat {:?}", removed.sysname(), device_seat.logical_name());
// update capabilities, so they appear correctly on `on_seat_changed` and `on_seat_destroyed`. // update capabilities, so they appear correctly on `on_seat_changed` and `on_seat_destroyed`.
if let Some(seat) = self.seats.get_mut(&device_seat) { if let Some(seat) = self.seats.get_mut(&device_seat) {
@ -385,6 +387,7 @@ impl InputBackend for LibinputInputBackend {
if !self.devices.iter().any(|x| x.seat() == device_seat) { if !self.devices.iter().any(|x| x.seat() == device_seat) {
// it has not, lets destroy it // it has not, lets destroy it
if let Some(seat) = self.seats.remove(&device_seat) { if let Some(seat) = self.seats.remove(&device_seat) {
info!(self.logger, "Removing seat {} which no longer has any device", device_seat.logical_name());
if let Some(ref mut handler) = self.handler { if let Some(ref mut handler) = self.handler {
trace!(self.logger, "Calling on_seat_destroyed with {:?}", seat); trace!(self.logger, "Calling on_seat_destroyed with {:?}", seat);
handler.on_seat_destroyed(&seat); handler.on_seat_destroyed(&seat);