From 155e8118d219ede2be841e6562b99f9105d198d1 Mon Sep 17 00:00:00 2001 From: Ian Douglas Scott Date: Wed, 15 May 2024 15:38:13 -0700 Subject: [PATCH 1/2] wayland: Use `wl_fixes` to free registry --- Cargo.toml | 2 +- src/backends/wayland/mod.rs | 25 ++++++++++++++++++++++++- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index c6422a4..cb6c9f9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -64,7 +64,7 @@ tiny-xlib = { version = "0.2.1", optional = true } wayland-backend = { version = "0.3.0", features = [ "client_system", ], optional = true } -wayland-client = { version = "0.31.0", optional = true } +wayland-client = { version = "0.31.12", optional = true } wayland-sys = { version = "0.31.0", optional = true } x11rb = { version = "0.13.0", features = [ "allow-unsafe-code", diff --git a/src/backends/wayland/mod.rs b/src/backends/wayland/mod.rs index 2d37494..6165b9e 100644 --- a/src/backends/wayland/mod.rs +++ b/src/backends/wayland/mod.rs @@ -11,7 +11,7 @@ use std::{ use wayland_client::{ backend::{Backend, ObjectId}, globals::{registry_queue_init, GlobalListContents}, - protocol::{wl_registry, wl_shm, wl_surface}, + protocol::{wl_fixes, wl_registry, wl_shm, wl_surface}, Connection, Dispatch, EventQueue, Proxy, QueueHandle, }; @@ -58,6 +58,17 @@ impl ContextInterface for Arc(&qh, 1..=1, ()) { + fixes.destroy_registry(globals.registry()); + conn.backend() + .destroy_object(&globals.registry().id()) + .unwrap(); + fixes.destroy(); + } + Ok(Arc::new(WaylandDisplayImpl { conn: Some(conn), event_queue: Mutex::new(event_queue), @@ -337,3 +348,15 @@ impl Dispatch for State { ) { } } + +impl Dispatch for State { + fn event( + _: &mut State, + _: &wl_fixes::WlFixes, + _: wl_fixes::Event, + _: &(), + _: &Connection, + _: &QueueHandle, + ) { + } +} From 3881df56128f3bcc6489d05bcf8b400588656c7b Mon Sep 17 00:00:00 2001 From: Ian Douglas Scott Date: Wed, 15 May 2024 15:43:31 -0700 Subject: [PATCH 2/2] wayland: Release `wl_shm` --- src/backends/wayland/mod.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/backends/wayland/mod.rs b/src/backends/wayland/mod.rs index 6165b9e..1e4dc18 100644 --- a/src/backends/wayland/mod.rs +++ b/src/backends/wayland/mod.rs @@ -81,6 +81,9 @@ impl ContextInterface for Arc Drop for WaylandDisplayImpl { fn drop(&mut self) { + if self.shm.version() >= 2 { + self.shm.release(); + } // Make sure the connection is dropped first. self.conn = None; }