//! Wayland specific shell //! use std::{borrow::Cow, collections::HashMap, sync::Arc}; #[cfg(all(feature = "cctk", target_os = "linux"))] use cctk::sctk::reexports::client::Connection; use iced_graphics::{Compositor, compositor}; use iced_runtime::{ core::{Vector, window}, platform_specific, user_interface, }; use winit::raw_window_handle::HasWindowHandle; #[cfg(all(feature = "cctk", target_os = "linux"))] pub mod wayland; #[cfg(all(feature = "cctk", target_os = "linux"))] pub use wayland::*; #[cfg(all(feature = "cctk", target_os = "linux"))] use wayland_backend::client::Backend; use crate::{CreateCompositor, Program, WindowManager}; pub type UserInterfaces<'a, P> = HashMap< window::Id, user_interface::UserInterface< 'a,
::Message,
::Theme,
::Renderer,
>,
rustc_hash::FxBuildHasher,
>;
#[derive(Debug)]
pub enum Event {
#[cfg(all(feature = "cctk", target_os = "linux"))]
Wayland(sctk_event::SctkEvent),
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum SurfaceIdWrapper {
LayerSurface(window::Id),
Window(window::Id),
Popup(window::Id),
SessionLock(window::Id),
Subsurface(window::Id),
}
impl SurfaceIdWrapper {
pub fn inner(&self) -> window::Id {
match self {
SurfaceIdWrapper::LayerSurface(id) => *id,
SurfaceIdWrapper::Window(id) => *id,
SurfaceIdWrapper::Popup(id) => *id,
SurfaceIdWrapper::SessionLock(id) => *id,
SurfaceIdWrapper::Subsurface(id) => *id,
}
}
}
#[derive(Debug, Default)]
pub struct PlatformSpecific {
#[cfg(all(feature = "cctk", target_os = "linux"))]
wayland: WaylandSpecific,
}
impl PlatformSpecific {
pub(crate) fn send_action(
&mut self,
action: iced_runtime::platform_specific::Action,
) {
match action {
#[cfg(all(feature = "cctk", target_os = "linux"))]
iced_runtime::platform_specific::Action::Wayland(a) => {
self.send_wayland(wayland::Action::Action(a));
}
}
}
pub(crate) fn retain_subsurfaces ,
compositor: &mut Option<
< ::Renderer as compositor::Default>::Compositor,
>,
window_manager: &mut WindowManager<
P,
< ::Renderer as compositor::Default>::Compositor,
>,
user_interfaces: &mut UserInterfaces<'a, P>,
clipboard: &mut crate::Clipboard,
create_compositor: CreateCompositor<'b, P>,
) where
P: Program,
{
match e {
#[cfg(all(feature = "cctk", target_os = "linux"))]
Event::Wayland(e) => {
platform_specific
.wayland
.handle_event(
e,
events,
program,
compositor,
window_manager,
user_interfaces,
clipboard,
create_compositor,
)
.await;
}
}
}