From 4dd4cfb6a389eb42fdf2c8b0fe8d46bd53eaef33 Mon Sep 17 00:00:00 2001 From: Ashley Wulber Date: Mon, 21 Oct 2024 10:44:40 -0400 Subject: [PATCH] refactor: disable wayland in winit shell by default --- winit/Cargo.toml | 4 +++- winit/src/platform_specific/mod.rs | 22 ++++++++++++++----- winit/src/platform_specific/wayland/mod.rs | 3 +-- .../platform_specific/wayland/sctk_event.rs | 12 +--------- 4 files changed, 22 insertions(+), 19 deletions(-) diff --git a/winit/Cargo.toml b/winit/Cargo.toml index 436e7f75f4..4e9e20023b 100644 --- a/winit/Cargo.toml +++ b/winit/Cargo.toml @@ -14,7 +14,7 @@ keywords.workspace = true workspace = true [features] -default = ["x11", "wayland", "wayland-dlopen", "wayland-csd-adwaita"] +default = ["x11"] debug = ["iced_runtime/debug"] system = ["sysinfo"] program = [] @@ -30,6 +30,8 @@ wayland = [ "xkbcommon-dl", "xkeysym", "iced_runtime/wayland", + "wayland-dlopen", + "wayland-csd-adwaita", ] wayland-dlopen = ["winit/wayland-dlopen"] wayland-csd-adwaita = ["winit/wayland-csd-adwaita"] diff --git a/winit/src/platform_specific/mod.rs b/winit/src/platform_specific/mod.rs index 4ef88dd7d9..608ca389ec 100644 --- a/winit/src/platform_specific/mod.rs +++ b/winit/src/platform_specific/mod.rs @@ -1,16 +1,17 @@ //! Wayland specific shell //! +use std::collections::HashMap; + use iced_graphics::Compositor; -use iced_runtime::{core::window, platform_specific, Debug}; -use sctk::reexports::client::Connection; -use wayland::sctk_event::UserInterfaces; +use iced_runtime::{core::window, user_interface, Debug}; #[cfg(all(feature = "wayland", target_os = "linux"))] pub mod wayland; #[cfg(all(feature = "wayland", target_os = "linux"))] pub use wayland::*; +#[cfg(all(feature = "wayland", target_os = "linux"))] use wayland_backend::client::Backend; use crate::{program::WindowManager, Program}; @@ -52,7 +53,7 @@ impl PlatformSpecific { ) { match action { #[cfg(all(feature = "wayland", target_os = "linux"))] - platform_specific::Action::Wayland(a) => { + iced_runtime::platform_specific::Action::Wayland(a) => { self.send_wayland(wayland::Action::Action(a)); } } @@ -92,7 +93,7 @@ impl PlatformSpecific { wayland_display_handle.display.as_ptr().cast(), ) }; - Connection::from_backend(backend) + sctk::reexports::client::Connection::from_backend(backend) } _ => { return; @@ -136,6 +137,17 @@ impl PlatformSpecific { } } +pub type UserInterfaces<'a, P> = HashMap< + window::Id, + user_interface::UserInterface< + 'a, +

::Message, +

::Theme, +

::Renderer, + >, + rustc_hash::FxBuildHasher, +>; + pub(crate) fn handle_event<'a, P, C>( e: Event, events: &mut Vec<(Option, iced_runtime::core::Event)>, diff --git a/winit/src/platform_specific/wayland/mod.rs b/winit/src/platform_specific/wayland/mod.rs index 7fbd07b4d8..445b1b67be 100644 --- a/winit/src/platform_specific/wayland/mod.rs +++ b/winit/src/platform_specific/wayland/mod.rs @@ -18,7 +18,6 @@ use sctk::reexports::calloop; use sctk::reexports::client::protocol::wl_surface::WlSurface; use sctk::seat::keyboard::Modifiers; use sctk_event::SctkEvent; -use sctk_event::UserInterfaces; use std::{collections::HashMap, sync::Arc}; use subsurface_widget::{SubsurfaceInstance, SubsurfaceState}; use wayland_backend::client::ObjectId; @@ -128,7 +127,7 @@ impl WaylandSpecific { compositor: &mut C, window_manager: &mut WindowManager, debug: &mut Debug, - user_interfaces: &mut UserInterfaces<'a, P>, + user_interfaces: &mut super::UserInterfaces<'a, P>, clipboard: &mut crate::Clipboard, #[cfg(feature = "a11y")] adapters: &mut HashMap< window::Id, diff --git a/winit/src/platform_specific/wayland/sctk_event.rs b/winit/src/platform_specific/wayland/sctk_event.rs index 6bfa328125..f4f51c3e8b 100755 --- a/winit/src/platform_specific/wayland/sctk_event.rs +++ b/winit/src/platform_specific/wayland/sctk_event.rs @@ -281,16 +281,6 @@ pub struct SurfaceCompositorUpdate { /// New scale factor. pub scale_factor: Option, } -pub type UserInterfaces<'a, P> = HashMap< - SurfaceId, - user_interface::UserInterface< - 'a, -

::Message, -

::Theme, -

::Renderer, - >, - rustc_hash::FxBuildHasher, ->; impl SctkEvent { pub(crate) fn process<'a, P, C>( @@ -305,7 +295,7 @@ impl SctkEvent { control_sender: &mpsc::UnboundedSender, proxy: &EventLoopProxy, debug: &mut Debug, - user_interfaces: &mut UserInterfaces<'a, P>, + user_interfaces: &mut crate::platform_specific::UserInterfaces<'a, P>, events: &mut Vec<(Option, iced_runtime::core::Event)>, clipboard: &mut Clipboard, subsurface_state: &mut Option,