From 8bf14e4d54449294f4cf0003a99c7d08c4a8c039 Mon Sep 17 00:00:00 2001 From: Ian Douglas Scott Date: Tue, 16 Jun 2026 14:25:51 -0700 Subject: [PATCH] In `Hash` impls, hash the `Arc` ptr instead of the ID This prevents (or strictly speaking, reduces) collisions between objects on different connections with the same ID. This isn't really necessary as a bug fix because `PartialEq` already did the same pointer comparisons, and probably isn't meaningfully more efficient in reasonable use cases, but seems more correct. --- src/event.rs | 4 ++-- src/object.rs | 2 +- src/request.rs | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/event.rs b/src/event.rs index e3879ed..3fe0c5d 100644 --- a/src/event.rs +++ b/src/event.rs @@ -853,7 +853,7 @@ impl Eq for Seat {} impl std::hash::Hash for Seat { fn hash(&self, state: &mut H) { - self.0.proto_seat.0.id().hash(state); + Arc::as_ptr(&self.0).hash(state); } } @@ -997,7 +997,7 @@ impl Eq for Device {} impl std::hash::Hash for Device { fn hash(&self, state: &mut H) { - self.0.device.0.id().hash(state); + Arc::as_ptr(&self.0).hash(state); } } diff --git a/src/object.rs b/src/object.rs index 9fdbde0..f2f2daf 100644 --- a/src/object.rs +++ b/src/object.rs @@ -30,7 +30,7 @@ impl Eq for Object {} impl hash::Hash for Object { fn hash(&self, hasher: &mut H) { - self.0.id.hash(hasher); + Arc::as_ptr(&self.0).hash(hasher); } } diff --git a/src/request.rs b/src/request.rs index 722f57b..a9be493 100644 --- a/src/request.rs +++ b/src/request.rs @@ -941,7 +941,7 @@ impl Eq for Seat {} impl std::hash::Hash for Seat { fn hash(&self, state: &mut H) { - self.0.seat.0.id().hash(state); + Arc::as_ptr(&self.0).hash(state); } } @@ -1163,7 +1163,7 @@ impl Eq for Device {} impl std::hash::Hash for Device { fn hash(&self, state: &mut H) { - self.0.device.0.id().hash(state); + Arc::as_ptr(&self.0).hash(state); } }