|
1 | | -use super::mime_type::decide_mime_type; |
2 | 1 | use super::ClipBackend; |
3 | 2 | use super::CopyConfig; |
4 | 3 | use super::PasteConfig; |
| 4 | +use super::mime_type::decide_mime_type; |
5 | 5 | use crate::protocol::SourceData; |
6 | | -use anyhow::{bail, Context, Error, Result}; |
| 6 | +use anyhow::{Context, Error, Result, bail}; |
7 | 7 | use nix::unistd::{pipe, read}; |
8 | 8 | use std::collections::HashMap; |
9 | 9 | use std::ffi::CString; |
10 | 10 | use std::fs::File; |
11 | 11 | use std::io::Write; |
12 | 12 | use std::os::fd::AsRawFd; |
13 | | -use wayrs_client::global::GlobalExt; |
14 | 13 | use wayrs_client::protocol::wl_seat::WlSeat; |
15 | 14 | use wayrs_client::{Connection, EventCtx, IoMode}; |
16 | 15 | use wayrs_protocols::wlr_data_control_unstable_v1::{ |
| 16 | + ZwlrDataControlManagerV1, |
17 | 17 | zwlr_data_control_device_v1::{self, ZwlrDataControlDeviceV1}, |
18 | 18 | zwlr_data_control_offer_v1::{self, ZwlrDataControlOfferV1}, |
19 | 19 | zwlr_data_control_source_v1::{self, ZwlrDataControlSourceV1}, |
20 | | - ZwlrDataControlManagerV1, |
21 | 20 | }; |
22 | 21 |
|
23 | 22 | pub struct WaylandBackend {} |
@@ -53,30 +52,12 @@ impl ClipBackend for WaylandBackend { |
53 | 52 | } |
54 | 53 |
|
55 | 54 | 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'")?; |
70 | 58 |
|
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("")?; |
80 | 61 |
|
81 | 62 | Ok(WaylandClient::<T> { |
82 | 63 | conn, |
|
0 commit comments