mirror of
https://github.com/Zedfrigg/ironbar.git
synced 2025-08-17 14:51:04 +02:00
feat: new clipboard manager module
This commit is contained in:
parent
5bbe64bb86
commit
575d6cc30f
26 changed files with 1809 additions and 149 deletions
|
@ -1,21 +1,32 @@
|
|||
mod client;
|
||||
mod toplevel;
|
||||
mod toplevel_manager;
|
||||
|
||||
extern crate smithay_client_toolkit as sctk;
|
||||
mod wlr_foreign_toplevel;
|
||||
|
||||
use std::collections::HashMap;
|
||||
use async_once::AsyncOnce;
|
||||
use lazy_static::lazy_static;
|
||||
pub use toplevel::{ToplevelChange, ToplevelEvent, ToplevelInfo};
|
||||
use toplevel_manager::{ToplevelHandler, ToplevelHandling, ToplevelStatusListener};
|
||||
use wayland_client::{Attached, DispatchData, Interface};
|
||||
use wayland_protocols::wlr::unstable::foreign_toplevel::v1::client::{
|
||||
zwlr_foreign_toplevel_handle_v1::ZwlrForeignToplevelHandleV1,
|
||||
zwlr_foreign_toplevel_manager_v1::ZwlrForeignToplevelManagerV1,
|
||||
};
|
||||
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};
|
||||
|
||||
pub use client::WaylandClient;
|
||||
|
||||
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};
|
||||
}
|
||||
}
|
||||
|
||||
/// A utility for lazy-loading globals.
|
||||
/// Taken from `smithay_client_toolkit` where it's not exposed
|
||||
#[derive(Debug)]
|
||||
|
@ -25,21 +36,32 @@ enum LazyGlobal<I: Interface> {
|
|||
Bound(Attached<I>),
|
||||
}
|
||||
|
||||
sctk::default_environment!(Env,
|
||||
fields = [
|
||||
toplevel: ToplevelHandler
|
||||
],
|
||||
singles = [
|
||||
ZwlrForeignToplevelManagerV1 => toplevel
|
||||
],
|
||||
);
|
||||
pub struct DData {
|
||||
env: Environment<Env>,
|
||||
offer_tokens: HashMap<u128, RegistrationToken>,
|
||||
}
|
||||
|
||||
impl ToplevelHandling for Env {
|
||||
fn listen<F>(&mut self, f: F) -> ToplevelStatusListener
|
||||
where
|
||||
F: FnMut(ZwlrForeignToplevelHandleV1, ToplevelEvent, DispatchData) + 'static,
|
||||
{
|
||||
self.toplevel.listen(f)
|
||||
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,
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue