From 1e30de075068d3834bf8b26a439a7496ac99e777 Mon Sep 17 00:00:00 2001 From: Ian Douglas Scott Date: Wed, 11 Oct 2023 12:58:00 -0700 Subject: [PATCH] client: Implement `Eq` for `Connection` This is useful in some cases, and there's no harm to providing it. --- wayland-backend/CHANGELOG.md | 3 +++ wayland-backend/src/client_api.rs | 2 +- wayland-backend/src/rs/client_impl/mod.rs | 8 ++++++++ wayland-backend/src/sys/client_impl/mod.rs | 8 ++++++++ wayland-client/CHANGELOG.md | 3 +++ wayland-client/src/conn.rs | 2 +- 6 files changed, 24 insertions(+), 2 deletions(-) diff --git a/wayland-backend/CHANGELOG.md b/wayland-backend/CHANGELOG.md index 8798c5e77cb..99b336db265 100644 --- a/wayland-backend/CHANGELOG.md +++ b/wayland-backend/CHANGELOG.md @@ -2,6 +2,9 @@ ## Unreleased +### Additions +- client: Implement `Eq` for `Backend` + ## 0.3.2 -- 2023-09-25 #### Bugfixes diff --git a/wayland-backend/src/client_api.rs b/wayland-backend/src/client_api.rs index 9908baa6548..a8633657e5c 100644 --- a/wayland-backend/src/client_api.rs +++ b/wayland-backend/src/client_api.rs @@ -129,7 +129,7 @@ impl ObjectId { /// /// This type hosts all the interface for interacting with the wayland protocol. It can be /// cloned, all clones refer to the same underlying connection. -#[derive(Clone, Debug)] +#[derive(Clone, Debug, PartialEq, Eq)] pub struct Backend { pub(crate) backend: client_impl::InnerBackend, } diff --git a/wayland-backend/src/rs/client_impl/mod.rs b/wayland-backend/src/rs/client_impl/mod.rs index ba10fbb27ae..8001fa3e623 100644 --- a/wayland-backend/src/rs/client_impl/mod.rs +++ b/wayland-backend/src/rs/client_impl/mod.rs @@ -139,6 +139,14 @@ impl WeakInnerBackend { } } +impl PartialEq for InnerBackend { + fn eq(&self, rhs: &Self) -> bool { + Arc::ptr_eq(&self.state, &rhs.state) + } +} + +impl Eq for InnerBackend {} + impl InnerBackend { pub fn downgrade(&self) -> WeakInnerBackend { WeakInnerBackend { state: Arc::downgrade(&self.state) } diff --git a/wayland-backend/src/sys/client_impl/mod.rs b/wayland-backend/src/sys/client_impl/mod.rs index 88c64277b91..946b5918201 100644 --- a/wayland-backend/src/sys/client_impl/mod.rs +++ b/wayland-backend/src/sys/client_impl/mod.rs @@ -219,6 +219,14 @@ impl WeakInnerBackend { } } +impl PartialEq for InnerBackend { + fn eq(&self, rhs: &Self) -> bool { + Arc::ptr_eq(&self.inner, &rhs.inner) + } +} + +impl Eq for InnerBackend {} + unsafe impl Send for InnerBackend {} unsafe impl Sync for InnerBackend {} diff --git a/wayland-client/CHANGELOG.md b/wayland-client/CHANGELOG.md index 85fa344c1b6..75383746121 100644 --- a/wayland-client/CHANGELOG.md +++ b/wayland-client/CHANGELOG.md @@ -2,6 +2,9 @@ ## Unreleased +#### Additions +- Implement `Eq` for `Connection` + ## 0.31.1 -- 2023-09-19 #### Additions diff --git a/wayland-client/src/conn.rs b/wayland-client/src/conn.rs index d33826324f8..5900ac54c29 100644 --- a/wayland-client/src/conn.rs +++ b/wayland-client/src/conn.rs @@ -34,7 +34,7 @@ use crate::{protocol::wl_display::WlDisplay, EventQueue, Proxy}; /// In case you need to plug yourself into an external Wayland connection that you don't control, you'll /// likely get access to it as a [`Backend`], in which case you can create a [`Connection`] from it using /// the [`from_backend`](Connection::from_backend) method. -#[derive(Debug, Clone)] +#[derive(Debug, Clone, PartialEq, Eq)] pub struct Connection { pub(crate) backend: Backend, }