Skip to content

Commit 225bdd4

Browse files
committed
Fix deprecated wayrs connect_and_collect_globals
1 parent 744ffb2 commit 225bdd4

File tree

1 file changed

+8
-27
lines changed

1 file changed

+8
-27
lines changed

src/clipboard/wayland.rs

Lines changed: 8 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,22 @@
1-
use super::mime_type::decide_mime_type;
21
use super::ClipBackend;
32
use super::CopyConfig;
43
use super::PasteConfig;
4+
use super::mime_type::decide_mime_type;
55
use crate::protocol::SourceData;
6-
use anyhow::{bail, Context, Error, Result};
6+
use anyhow::{Context, Error, Result, bail};
77
use nix::unistd::{pipe, read};
88
use std::collections::HashMap;
99
use std::ffi::CString;
1010
use std::fs::File;
1111
use std::io::Write;
1212
use std::os::fd::AsRawFd;
13-
use wayrs_client::global::GlobalExt;
1413
use wayrs_client::protocol::wl_seat::WlSeat;
1514
use wayrs_client::{Connection, EventCtx, IoMode};
1615
use wayrs_protocols::wlr_data_control_unstable_v1::{
16+
ZwlrDataControlManagerV1,
1717
zwlr_data_control_device_v1::{self, ZwlrDataControlDeviceV1},
1818
zwlr_data_control_offer_v1::{self, ZwlrDataControlOfferV1},
1919
zwlr_data_control_source_v1::{self, ZwlrDataControlSourceV1},
20-
ZwlrDataControlManagerV1,
2120
};
2221

2322
pub struct WaylandBackend {}
@@ -53,30 +52,12 @@ impl ClipBackend for WaylandBackend {
5352
}
5453

5554
fn create_wayland_client<T>() -> Result<WaylandClient<T>> {
56-
let (mut conn, globals) = Connection::<T>::connect_and_collect_globals()
57-
.context("Failed to create wayland connection")?;
58-
59-
let mut seat_opt: Option<WlSeat> = None;
60-
for g in &globals {
61-
if g.is::<WlSeat>() {
62-
if seat_opt.is_none() {
63-
seat_opt = Some(g.bind(&mut conn, 2..=4).unwrap());
64-
} else {
65-
log::debug!("More than one WlSeat found, this is not expected")
66-
}
67-
}
68-
}
69-
let seat = seat_opt.context("Failed to find 'WlSeat'")?;
55+
let mut conn = Connection::<T>::connect().context("Failed to create wayland connection")?;
56+
conn.blocking_roundtrip()
57+
.context("Failed to call 'blocking_roundtrip'")?;
7058

71-
let data_ctl_mgr: ZwlrDataControlManagerV1 = globals
72-
.iter()
73-
.find(|g| g.is::<ZwlrDataControlManagerV1>())
74-
.context(
75-
"No zwlr_data_control_manager_v1 global found, \
76-
ensure compositor supports wlr-data-control-unstable-v1 protocol",
77-
)?
78-
.bind(&mut conn, ..=2)
79-
.context("Failed to bind to the 'ZwlrDataControlManagerV1'")?;
59+
let seat: WlSeat = conn.bind_singleton(2..=4).context("")?;
60+
let data_ctl_mgr: ZwlrDataControlManagerV1 = conn.bind_singleton(..=2).context("")?;
8061

8162
Ok(WaylandClient::<T> {
8263
conn,

0 commit comments

Comments
 (0)