Merge pull request #170 from Smithay/vberger/fix-libinput-device-drop

backend.libinput: fix tracking of removed devices
This commit is contained in:
Victor Brekenfeld 2020-04-01 18:24:41 +02:00 committed by GitHub
commit fbe20d6c1f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 1 deletions

View File

@ -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);