Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
28 changes: 27 additions & 1 deletion src/backends/wayland/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};

Expand Down Expand Up @@ -58,6 +58,17 @@ impl<D: HasDisplayHandle + ?Sized> ContextInterface<D> for Arc<WaylandDisplayImp
let shm: wl_shm::WlShm = globals
.bind(&qh, 1..=1, ())
.swbuf_err("Failed to instantiate Wayland Shm")?;

// If `wl_fixes` is supported, destroy registry using it.
// We don't need the registry anymore.
if let Ok(fixes) = globals.bind::<wl_fixes::WlFixes, _, ()>(&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),
Expand All @@ -70,6 +81,9 @@ impl<D: HasDisplayHandle + ?Sized> ContextInterface<D> for Arc<WaylandDisplayImp

impl<D: ?Sized> Drop for WaylandDisplayImpl<D> {
fn drop(&mut self) {
if self.shm.version() >= 2 {
self.shm.release();
}
// Make sure the connection is dropped first.
self.conn = None;
}
Expand Down Expand Up @@ -337,3 +351,15 @@ impl Dispatch<wl_shm::WlShm, ()> for State {
) {
}
}

impl Dispatch<wl_fixes::WlFixes, ()> for State {
fn event(
_: &mut State,
_: &wl_fixes::WlFixes,
_: wl_fixes::Event,
_: &(),
_: &Connection,
_: &QueueHandle<State>,
) {
}
}