2022-10-04 23:26:07 +01:00
|
|
|
mod client;
|
|
|
|
|
2023-02-25 14:30:45 +00:00
|
|
|
mod wlr_foreign_toplevel;
|
2022-10-04 23:26:07 +01:00
|
|
|
|
2023-02-25 14:30:45 +00:00
|
|
|
use std::collections::HashMap;
|
2022-10-04 23:26:07 +01:00
|
|
|
use async_once::AsyncOnce;
|
|
|
|
use lazy_static::lazy_static;
|
2023-02-25 14:30:45 +00:00
|
|
|
use std::fmt::Debug;
|
|
|
|
use cfg_if::cfg_if;
|
|
|
|
use smithay_client_toolkit::default_environment;
|
|
|
|
use smithay_client_toolkit::environment::Environment;
|
|
|
|
use smithay_client_toolkit::reexports::calloop::RegistrationToken;
|
|
|
|
use wayland_client::{Attached, Interface};
|
|
|
|
use wayland_protocols::wlr::unstable::foreign_toplevel::v1::client::zwlr_foreign_toplevel_manager_v1::ZwlrForeignToplevelManagerV1;
|
|
|
|
pub use wlr_foreign_toplevel::handle::{ToplevelChange, ToplevelEvent, ToplevelInfo};
|
|
|
|
use wlr_foreign_toplevel::manager::{ToplevelHandler};
|
2022-10-04 23:26:07 +01:00
|
|
|
|
|
|
|
pub use client::WaylandClient;
|
|
|
|
|
2023-02-25 14:30:45 +00:00
|
|
|
cfg_if! {
|
|
|
|
if #[cfg(feature = "clipboard")] {
|
|
|
|
mod wlr_data_control;
|
|
|
|
|
|
|
|
use wayland_protocols::wlr::unstable::data_control::v1::client::zwlr_data_control_manager_v1::ZwlrDataControlManagerV1;
|
|
|
|
use wlr_data_control::manager::DataControlDeviceHandler;
|
|
|
|
pub use wlr_data_control::{ClipboardItem, ClipboardValue};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-10-04 23:26:07 +01:00
|
|
|
/// A utility for lazy-loading globals.
|
2022-10-10 21:59:44 +01:00
|
|
|
/// Taken from `smithay_client_toolkit` where it's not exposed
|
2022-10-04 23:26:07 +01:00
|
|
|
#[derive(Debug)]
|
|
|
|
enum LazyGlobal<I: Interface> {
|
|
|
|
Unknown,
|
|
|
|
Seen { id: u32, version: u32 },
|
|
|
|
Bound(Attached<I>),
|
|
|
|
}
|
|
|
|
|
2023-02-25 14:30:45 +00:00
|
|
|
pub struct DData {
|
|
|
|
env: Environment<Env>,
|
|
|
|
offer_tokens: HashMap<u128, RegistrationToken>,
|
|
|
|
}
|
|
|
|
|
|
|
|
cfg_if! {
|
|
|
|
if #[cfg(feature = "clipboard")] {
|
|
|
|
default_environment!(Env,
|
|
|
|
fields = [
|
|
|
|
toplevel: ToplevelHandler,
|
|
|
|
data_control_device: DataControlDeviceHandler
|
|
|
|
],
|
|
|
|
singles = [
|
|
|
|
ZwlrForeignToplevelManagerV1 => toplevel,
|
|
|
|
ZwlrDataControlManagerV1 => data_control_device
|
|
|
|
],
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
default_environment!(Env,
|
|
|
|
fields = [
|
|
|
|
toplevel: ToplevelHandler,
|
|
|
|
],
|
|
|
|
singles = [
|
|
|
|
ZwlrForeignToplevelManagerV1 => toplevel,
|
|
|
|
],
|
|
|
|
);
|
2022-10-04 23:26:07 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
lazy_static! {
|
|
|
|
static ref CLIENT: AsyncOnce<WaylandClient> =
|
|
|
|
AsyncOnce::new(async { WaylandClient::new().await });
|
|
|
|
}
|
|
|
|
|
|
|
|
pub async fn get_client() -> &'static WaylandClient {
|
|
|
|
CLIENT.get().await
|
|
|
|
}
|