From 63702a308aa68a08ae36f01c3d0dd4031c6abd07 Mon Sep 17 00:00:00 2001 From: Victor Berger Date: Wed, 1 Apr 2020 11:03:54 +0200 Subject: [PATCH] backend.libinput: fix tracking of removed devices --- src/backend/libinput.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/backend/libinput.rs b/src/backend/libinput.rs index 8e7f7db..a227631 100644 --- a/src/backend/libinput.rs +++ b/src/backend/libinput.rs @@ -315,6 +315,7 @@ impl InputBackend for LibinputInputBackend { }; let device_seat = added.seat(); + info!(self.logger, "New device {:?} on seat {:?}", added.sysname(), device_seat.logical_name()); self.devices.push(added); match self.seats.entry(device_seat.clone()) { @@ -354,9 +355,10 @@ impl InputBackend for LibinputInputBackend { let removed = device_removed_event.device(); // remove device - self.devices.retain(|dev| *dev == removed); + self.devices.retain(|dev| *dev != removed); 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`. 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) { // it has not, lets destroy it 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 { trace!(self.logger, "Calling on_seat_destroyed with {:?}", seat); handler.on_seat_destroyed(&seat);