Skip to content

Commit 1e8ee18

Browse files
committed
wayland: Use wl_fixes to free registry
1 parent 468cf78 commit 1e8ee18

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ memmap2 = { version = "0.9.0", optional = true }
7070
wayland-backend = { version = "0.3.0", optional = true, features = [
7171
"client_system",
7272
] }
73-
wayland-client = { version = "0.31.0", optional = true }
73+
wayland-client = { version = "0.31.12", optional = true }
7474
wayland-sys = { version = "0.31.0", optional = true }
7575
# X11
7676
as-raw-xcb-connection = { version = "1.0.0", optional = true }

src/backends/wayland/mod.rs

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use std::{
1111
use wayland_client::{
1212
backend::{Backend, ObjectId},
1313
globals::{registry_queue_init, GlobalListContents},
14-
protocol::{wl_registry, wl_shm, wl_surface},
14+
protocol::{wl_fixes, wl_registry, wl_shm, wl_surface},
1515
Connection, Dispatch, EventQueue, Proxy, QueueHandle,
1616
};
1717

@@ -58,6 +58,17 @@ impl<D: HasDisplayHandle + ?Sized> ContextInterface<D> for Arc<WaylandDisplayImp
5858
let shm: wl_shm::WlShm = globals
5959
.bind(&qh, 1..=1, ())
6060
.swbuf_err("Failed to instantiate Wayland Shm")?;
61+
62+
// If `wl_fixes` is supported, destroy registry using it.
63+
// We don't need the registry anymore.
64+
if let Ok(fixes) = globals.bind::<wl_fixes::WlFixes, _, ()>(&qh, 1..=1, ()) {
65+
fixes.destroy_registry(globals.registry());
66+
conn.backend()
67+
.destroy_object(&globals.registry().id())
68+
.unwrap();
69+
fixes.destroy();
70+
}
71+
6172
Ok(Arc::new(WaylandDisplayImpl {
6273
conn: Some(conn),
6374
event_queue: Mutex::new(event_queue),
@@ -313,3 +324,15 @@ impl Dispatch<wl_shm::WlShm, ()> for State {
313324
) {
314325
}
315326
}
327+
328+
impl Dispatch<wl_fixes::WlFixes, ()> for State {
329+
fn event(
330+
_: &mut State,
331+
_: &wl_fixes::WlFixes,
332+
_: wl_fixes::Event,
333+
_: &(),
334+
_: &Connection,
335+
_: &QueueHandle<State>,
336+
) {
337+
}
338+
}

0 commit comments

Comments
 (0)