From b0d470ed3ff49cbe07339534173ae88f58d38a77 Mon Sep 17 00:00:00 2001 From: Ian Douglas Scott Date: Wed, 15 May 2024 15:38:13 -0700 Subject: [PATCH 1/2] WIP wayland: Use `wl_fixes` to free registry --- Cargo.toml | 8 ++++++++ src/backends/wayland/mod.rs | 25 ++++++++++++++++++++++++- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 24db5ed..3d3a8ba 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -115,3 +115,11 @@ targets = [ "x86_64-unknown-linux-gnu", "wasm32-unknown-unknown", ] + +[patch.crates-io] +wayland-protocols = { git = "https://github.com/ids1024/wayland-rs", branch = "wl-fixes" } +wayland-protocols-wlr = { git = "https://github.com/ids1024/wayland-rs", branch = "wl-fixes" } +wayland-client = { git = "https://github.com/ids1024/wayland-rs", branch = "wl-fixes" } +wayland-sys = { git = "https://github.com/ids1024/wayland-rs", branch = "wl-fixes" } +wayland-backend = { git = "https://github.com/ids1024/wayland-rs", branch = "wl-fixes" } +wayland-scanner = { git = "https://github.com/ids1024/wayland-rs", branch = "wl-fixes" } diff --git a/src/backends/wayland/mod.rs b/src/backends/wayland/mod.rs index 32be3d4..277a666 100644 --- a/src/backends/wayland/mod.rs +++ b/src/backends/wayland/mod.rs @@ -12,7 +12,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, }; @@ -59,6 +59,17 @@ impl ContextInterface for Rc(&qh, 1..=1, ()) { + fixes.destroy_registry(globals.registry()); + conn.backend() + .destroy_object(&globals.registry().id()) + .unwrap(); + fixes.destroy(); + } + Ok(Rc::new(WaylandDisplayImpl { conn: Some(conn), event_queue: RefCell::new(event_queue), @@ -312,3 +323,15 @@ impl Dispatch for State { ) { } } + +impl Dispatch for State { + fn event( + _: &mut State, + _: &wl_fixes::WlFixes, + _: wl_fixes::Event, + _: &(), + _: &Connection, + _: &QueueHandle, + ) { + } +} From 9cdb7527363ff0fed31c37ad489d9f708339ccc9 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 277a666..8c38a12 100644 --- a/src/backends/wayland/mod.rs +++ b/src/backends/wayland/mod.rs @@ -82,6 +82,9 @@ impl ContextInterface for Rc 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; }