diff --git a/Cargo.toml b/Cargo.toml index b02b6ca7..3b3871c7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,7 +14,7 @@ default = [ "a11y", "dbus-config", "x11", - "iced-wayland", + "wayland", "multi-window", ] advanced-shaping = ["iced/advanced-shaping"] @@ -72,6 +72,7 @@ serde-keycode = ["iced_core/serde"] single-instance = ["iced_winit/single-instance", "zbus/blocking-api", "ron"] # smol async runtime smol = ["dep:smol", "iced/smol", "zbus?/async-io", "rfd?/async-std"] +# Tokio async runtime tokio = [ "dep:tokio", "ashpd?/tokio", @@ -80,22 +81,18 @@ tokio = [ "zbus?/tokio", "cosmic-config/tokio", ] -# Tokio async runtime # Wayland window support -iced-wayland = [ - "ashpd?/wayland", +wayland = [ "autosize", + "surface-message", + "cctk", + "multi-window", + "winit", + "ashpd?/wayland", "iced/wayland", "iced_winit/wayland", - "surface-message", -] -wayland = [ - "iced-wayland", - "iced_runtime/cctk", - "iced_winit/cctk", - "iced_wgpu/cctk", - "iced/cctk", - "dep:cctk", + "iced_runtime/wayland", + "iced_wgpu/wayland", ] surface-message = [] # multi-window support @@ -127,7 +124,6 @@ ashpd = { version = "0.12.3", default-features = false, optional = true } async-fs = { version = "2.2", optional = true } async-std = { workspace = true, optional = true } auto_enums = "0.8.8" -cctk = { git = "https://github.com/pop-os/cosmic-protocols", package = "cosmic-client-toolkit", rev = "32283d7", optional = true } jiff = "0.2" cosmic-config = { path = "cosmic-config" } cosmic-settings-config = { git = "https://github.com/pop-os/cosmic-settings-daemon", optional = true } @@ -173,7 +169,8 @@ ron = { workspace = true, optional = true } enumflags2 = "0.7.12" # Enable DBus feature on Linux targets -[target.'cfg(target_os = "linux")'.dependencies] +[target.'cfg(all(unix, not(any(target_os = "redox", target_family = "wasm", target_os = "android", target_vendor = "apple"))))'.dependencies] +cctk = { git = "https://github.com/pop-os/cosmic-protocols", package = "cosmic-client-toolkit", rev = "32283d7", optional = true } cosmic-config = { path = "cosmic-config", features = ["dbus"] } cosmic-settings-daemon = { git = "https://github.com/pop-os/dbus-settings-bindings" } zbus.workspace = true @@ -261,3 +258,9 @@ zbus = { version = "5.15", default-features = false } [dev-dependencies] tempfile = "3.27.0" + +[workspace.package] +edition = "2024" + +[build-dependencies] +build_helpers = { path = "./iced/build_helpers" } diff --git a/build.rs b/build.rs index 4ce0aa9e..722d2c57 100644 --- a/build.rs +++ b/build.rs @@ -8,6 +8,7 @@ fn main() { { generate_bundled_icons(); } + build_helpers::cfg_aliases_setup(); } fn generate_bundled_icons() { diff --git a/iced b/iced index f6daee14..7177c92b 160000 --- a/iced +++ b/iced @@ -1 +1 @@ -Subproject commit f6daee14ac8f7cf090a5413ee1576aa59649a956 +Subproject commit 7177c92bb0b10382acafdec1af7441312138c69e diff --git a/src/app/action.rs b/src/app/action.rs index a3b9dd6a..1308335e 100644 --- a/src/app/action.rs +++ b/src/app/action.rs @@ -5,7 +5,7 @@ use crate::config::CosmicTk; use crate::theme::Theme; use crate::widget::nav_bar; use crate::{keyboard_nav, surface}; -#[cfg(all(feature = "wayland", target_os = "linux"))] +#[cfg(wayland_platform)] use cctk::sctk::reexports::csd_frame::{WindowManagerCapabilities, WindowState}; use cosmic_theme::ThemeMode; @@ -71,10 +71,10 @@ pub enum Action { /// Updates the tracked window geometry. WindowResize(iced::window::Id, f32, f32), /// Tracks updates to window state. - #[cfg(all(feature = "wayland", target_os = "linux"))] + #[cfg(wayland_platform)] WindowState(iced::window::Id, WindowState), /// Capabilities the window manager supports - #[cfg(all(feature = "wayland", target_os = "linux"))] + #[cfg(wayland_platform)] WmCapabilities(iced::window::Id, WindowManagerCapabilities), #[cfg(feature = "xdg-portal")] DesktopSettings(crate::theme::portal::Desktop), diff --git a/src/app/cosmic.rs b/src/app/cosmic.rs index ed81d416..f3f51e05 100644 --- a/src/app/cosmic.rs +++ b/src/app/cosmic.rs @@ -6,20 +6,20 @@ use std::collections::HashMap; use std::sync::Arc; use super::{Action, Application, ApplicationExt, Subscription}; -#[cfg(all(feature = "wayland", target_os = "linux"))] +#[cfg(wayland_platform)] use crate::core::Auto; -#[cfg(all(feature = "wayland", target_os = "linux"))] +#[cfg(wayland_platform)] use crate::surface::action::LiveSettings; use crate::theme::{THEME, Theme, ThemeType}; use crate::{Core, Element, keyboard_nav}; -#[cfg(all(feature = "wayland", target_os = "linux"))] +#[cfg(wayland_platform)] use cctk::sctk::reexports::csd_frame::{WindowManagerCapabilities, WindowState}; use cosmic_theme::ThemeMode; -#[cfg(all(feature = "wayland", target_os = "linux"))] +#[cfg(wayland_platform)] use enumflags2::BitFlags; -#[cfg(not(any(feature = "multi-window", feature = "wayland", target_os = "linux")))] +#[cfg(not(any(feature = "multi-window", wayland_platform)))] use iced::Application as IcedApplication; -#[cfg(all(feature = "wayland", target_os = "linux"))] +#[cfg(wayland_platform)] use iced::event::wayland; use iced::{Task, theme, window}; use iced_futures::event::listen_with; @@ -158,7 +158,7 @@ where ) -> iced::Task> { #[cfg(feature = "surface-message")] match _surface_message { - #[cfg(all(feature = "wayland", target_os = "linux"))] + #[cfg(wayland_platform)] crate::surface::Action::AppSubsurface(settings, live_settings, view) => { let Some(settings) = std::sync::Arc::try_unwrap(settings) .ok() @@ -185,7 +185,7 @@ where }); self.get_subsurface(settings, view.map(|v| *v)) } - #[cfg(all(feature = "wayland", target_os = "linux"))] + #[cfg(wayland_platform)] crate::surface::Action::Subsurface(settings, live_settings, view) => { let Some(settings) = std::sync::Arc::try_unwrap(settings) .ok() @@ -212,7 +212,7 @@ where self.get_subsurface(settings, None) } } - #[cfg(all(feature = "wayland", target_os = "linux"))] + #[cfg(wayland_platform)] crate::surface::Action::AppPopup(settings, live_settings, view) => { let Some(settings) = std::sync::Arc::try_unwrap(settings) .ok() @@ -249,11 +249,11 @@ where self.get_popup(settings, *live_settings, view.map(|v| *v)) } - #[cfg(all(feature = "wayland", target_os = "linux"))] + #[cfg(wayland_platform)] crate::surface::Action::DestroyPopup(id) => { iced_winit::commands::popup::destroy_popup(id) } - #[cfg(all(feature = "wayland", target_os = "linux"))] + #[cfg(wayland_platform)] crate::surface::Action::DestroyTooltipPopup => { #[cfg(feature = "applet")] { @@ -264,11 +264,11 @@ where Task::none() } } - #[cfg(all(feature = "wayland", target_os = "linux"))] + #[cfg(wayland_platform)] crate::surface::Action::DestroySubsurface(id) => { iced_winit::commands::subsurface::destroy_subsurface(id) } - #[cfg(all(feature = "wayland", target_os = "linux"))] + #[cfg(wayland_platform)] crate::surface::Action::DestroyWindow(id) => iced::window::close(id), crate::surface::Action::ResponsiveMenuBar { menu_bar, @@ -279,7 +279,7 @@ where core.menu_bars.insert(menu_bar, (limits, size)); iced::Task::none() } - #[cfg(all(feature = "wayland", target_os = "linux"))] + #[cfg(wayland_platform)] crate::surface::Action::Popup(settings, live_settings, view) => { let Some(settings) = std::sync::Arc::try_unwrap(settings) .ok() @@ -318,7 +318,7 @@ where self.get_popup(settings, live_settings, None) } } - #[cfg(all(feature = "wayland", target_os = "linux"))] + #[cfg(wayland_platform)] crate::surface::Action::AppWindow(id, settings, live_settings, view) => { let Some(settings) = std::sync::Arc::try_unwrap(settings).ok().and_then(|s| { s.downcast:: iced::window::Settings + Send + Sync>>() @@ -356,7 +356,7 @@ where self.get_window(id, settings, *live_settings, view.map(|v| *v)) } - #[cfg(all(feature = "wayland", target_os = "linux"))] + #[cfg(wayland_platform)] crate::surface::Action::Window(id, settings, live_settings, view) => { let Some(settings) = std::sync::Arc::try_unwrap(settings).ok().and_then(|s| { s.downcast:: iced::window::Settings + Send + Sync>>() @@ -413,7 +413,7 @@ where crate::surface::Action::Task(f) => { f().map(|sm| crate::Action::Cosmic(Action::Surface(sm))) } - #[cfg(all(feature = "wayland", target_os = "linux"))] + #[cfg(wayland_platform)] crate::surface::Action::AppLayerShell(settings, live_settings, view) => { let Some(settings) = std::sync::Arc::try_unwrap(settings) .ok() @@ -451,7 +451,7 @@ where self.get_layer_shell(settings, *live_settings, view.map(|v| *v)) } - #[cfg(all(feature = "wayland", target_os = "linux"))] + #[cfg(wayland_platform)] crate::surface::Action::LayerShell(settings, live_settings, view) => { let Some(settings) = std::sync::Arc::try_unwrap(settings) .ok() @@ -491,7 +491,7 @@ where self.get_layer_shell(settings, live_settings, None) } } - #[cfg(all(feature = "wayland", target_os = "linux"))] + #[cfg(wayland_platform)] crate::surface::Action::DestroyLayerShell(id) => { iced_winit::commands::layer_surface::destroy_layer_surface(id) } @@ -579,7 +579,7 @@ where } iced::Event::Window(window::Event::Focused) => return Some(Action::Focus(id)), iced::Event::Window(window::Event::Unfocused) => return Some(Action::Unfocus(id)), - #[cfg(all(feature = "wayland", target_os = "linux"))] + #[cfg(wayland_platform)] iced::Event::PlatformSpecific(iced::event::PlatformSpecific::Wayland(event)) => { match event { wayland::Event::Popup(wayland::PopupEvent::Done, _, id) @@ -592,7 +592,7 @@ where ) => { return Some(Action::SuggestedBounds(b)); } - #[cfg(all(feature = "wayland", target_os = "linux"))] + #[cfg(wayland_platform)] wayland::Event::Window(iced::event::wayland::WindowEvent::WindowState( s, )) => { @@ -762,7 +762,7 @@ impl Cosmic { fn cosmic_update(&mut self, message: Action) -> iced::Task> { match message { Action::WindowMaximized(id, maximized) => { - #[cfg(not(all(feature = "wayland", target_os = "linux")))] + #[cfg(not(wayland_platform))] if self .app .core() @@ -792,7 +792,7 @@ impl Cosmic { }); } - #[cfg(all(feature = "wayland", target_os = "linux"))] + #[cfg(wayland_platform)] Action::WindowState(id, state) => { if self .app @@ -824,7 +824,7 @@ impl Cosmic { } } - #[cfg(all(feature = "wayland", target_os = "linux"))] + #[cfg(wayland_platform)] Action::WmCapabilities(id, capabilities) => { if self .app @@ -911,7 +911,7 @@ impl Cosmic { guard.transparent = new_blur; drop(guard); - #[cfg(all(feature = "wayland", target_os = "linux"))] + #[cfg(wayland_platform)] { let core = self.app.core(); let mut cmds = Vec::with_capacity(1 + self.surface_views.len()); @@ -986,7 +986,7 @@ impl Cosmic { cosmic_theme.set_theme(new_theme.theme_type); cosmic_theme.transparent = new_blur; - #[cfg(all(feature = "wayland", target_os = "linux"))] + #[cfg(wayland_platform)] { use iced_winit::platform_specific::commands::corner_radius::corner_radius; @@ -1119,7 +1119,7 @@ impl Cosmic { if let ThemeType::System { .. } = cosmic_theme.theme_type { cosmic_theme.set_theme(new_theme.theme_type); cosmic_theme.transparent = new_blur; - #[cfg(all(feature = "wayland", target_os = "linux"))] + #[cfg(wayland_platform)] { use iced_winit::platform_specific::commands::corner_radius::corner_radius; @@ -1193,7 +1193,7 @@ impl Cosmic { // Unminimize window before requesting to activate it. let mut task = iced_runtime::window::minimize(id, false); - #[cfg(all(feature = "wayland", target_os = "linux"))] + #[cfg(wayland_platform)] { task = task.chain( iced_winit::platform_specific::commands::activation::activate( @@ -1204,7 +1204,7 @@ impl Cosmic { ); } - #[cfg(not(all(feature = "wayland", target_os = "linux")))] + #[cfg(not(wayland_platform))] { task = task.chain(iced_runtime::window::gain_focus(id)); } @@ -1301,7 +1301,7 @@ impl Cosmic { // Only apply update if the theme is set to load a system theme if let ThemeType::System { theme: _, .. } = cosmic_theme.theme_type { let mut cmds = Vec::with_capacity(1); - #[cfg(all(feature = "wayland", target_os = "linux"))] + #[cfg(wayland_platform)] { let blur = if cosmic_theme.transparent { iced::window::enable_blur @@ -1378,12 +1378,7 @@ impl Cosmic { } Action::Focus(f) => { - #[cfg(all( - feature = "wayland", - feature = "multi-window", - feature = "surface-message", - target_os = "linux" - ))] + #[cfg(wayland_platform)] if let Some(( parent, SurfaceIdWrapper::Subsurface(_) | SurfaceIdWrapper::Popup(_), @@ -1428,7 +1423,7 @@ impl Cosmic { core.applet.suggested_bounds = b; } Action::Opened(id) => { - #[cfg(all(feature = "wayland", target_os = "linux"))] + #[cfg(wayland_platform)] { use iced_winit::platform_specific::commands::corner_radius::corner_radius; @@ -1511,7 +1506,7 @@ impl Cosmic { } return iced_runtime::window::run_with_handle(id, init_windowing_system); } - #[cfg(all(feature = "wayland", target_os = "linux"))] + #[cfg(wayland_platform)] Action::BlurEnabled => { // TODO do this after blur event confirms support instead of for all wayland windows self.blur_enabled = true; @@ -1591,7 +1586,7 @@ impl Cosmic { if matches!(id_wrapper, SurfaceIdWrapper::Window(_)) { window::enable_blur(id) } else { - #[cfg(all(feature = "wayland", feature = "winit", target_os = "linux"))] + #[cfg(wayland_platform)] { iced_winit::commands::blur::blur( id, @@ -1602,7 +1597,7 @@ impl Cosmic { ) .discard() } - #[cfg(not(all(feature = "wayland", feature = "winit", target_os = "linux")))] + #[cfg(not(wayland_platform))] { iced::window::enable_blur(id) } @@ -1610,11 +1605,11 @@ impl Cosmic { } else if matches!(id_wrapper, SurfaceIdWrapper::Window(_)) { window::disable_blur(id) } else { - #[cfg(all(feature = "wayland", feature = "winit", target_os = "linux"))] + #[cfg(wayland_platform)] { iced_winit::commands::blur::blur(id, None).discard() } - #[cfg(not(all(feature = "wayland", feature = "winit", target_os = "linux")))] + #[cfg(not(wayland_platform))] { iced::window::disable_blur(id) } @@ -1624,7 +1619,7 @@ impl Cosmic { cmds.push(if matches!(id_wrapper, SurfaceIdWrapper::Window(_)) { window::enable_blur(id) } else { - #[cfg(all(feature = "wayland", feature = "winit", target_os = "linux"))] + #[cfg(wayland_platform)] { iced_winit::commands::blur::blur( id, @@ -1635,13 +1630,13 @@ impl Cosmic { ) .discard() } - #[cfg(not(all(feature = "wayland", feature = "winit", target_os = "linux")))] + #[cfg(not(wayland_platform))] { iced::window::enable_blur(id) } }); } - #[cfg(all(feature = "wayland", feature = "winit", target_os = "linux"))] + #[cfg(wayland_platform)] if let Some(corners) = live_settings.corners { cmds.push( iced_winit::commands::corner_radius::corner_radius(id, Some(corners)).discard(), @@ -1657,7 +1652,7 @@ impl Cosmic { ); } } - #[cfg(all(feature = "wayland", feature = "winit", target_os = "linux"))] + #[cfg(wayland_platform)] if let (SurfaceIdWrapper::LayerSurface(id), Some(padding)) = (id_wrapper, live_settings.padding) { @@ -1668,7 +1663,7 @@ impl Cosmic { Task::batch(cmds) } - #[cfg(all(feature = "wayland", target_os = "linux"))] + #[cfg(wayland_platform)] /// Create a subsurface pub fn get_subsurface( &mut self, @@ -1700,7 +1695,7 @@ impl Cosmic { Task::batch([live_settings_task, get_subsurface(settings)]) } - #[cfg(all(feature = "wayland", target_os = "linux"))] + #[cfg(wayland_platform)] /// Create a subsurface pub fn get_popup( &mut self, @@ -1728,7 +1723,7 @@ impl Cosmic { live_settings_task.chain(get_popup(settings)).discard() } - #[cfg(all(feature = "wayland", target_os = "linux"))] + #[cfg(wayland_platform)] /// Create a window surface pub fn get_window( &mut self, @@ -1765,7 +1760,7 @@ impl Cosmic { ]) } - #[cfg(all(feature = "wayland", target_os = "linux"))] + #[cfg(wayland_platform)] pub fn get_layer_shell( &mut self, settings: iced_runtime::platform_specific::wayland::layer_surface::SctkLayerSurfaceSettings, @@ -1794,7 +1789,7 @@ impl Cosmic { } } -#[cfg(all(feature = "wayland", target_os = "linux"))] +#[cfg(wayland_platform)] fn corners( surface_type: SurfaceIdWrapper, rounded: bool, diff --git a/src/app/mod.rs b/src/app/mod.rs index 5ead69fe..d963b7dd 100644 --- a/src/app/mod.rs +++ b/src/app/mod.rs @@ -390,13 +390,7 @@ where crate::widget::nav_bar(nav_model, |id| crate::Action::Cosmic(Action::NavBar(id))) .on_context(|id| crate::Action::Cosmic(Action::NavBarContext(id))) .context_menu(self.nav_context_menu()); - #[cfg(all( - feature = "multi-window", - feature = "wayland", - target_os = "linux", - feature = "winit", - feature = "surface-message" - ))] + #[cfg(wayland_platform)] { nav = nav .window_id_maybe(self.core().main_window_id()) diff --git a/src/app/settings.rs b/src/app/settings.rs index 5c903f09..0c101741 100644 --- a/src/app/settings.rs +++ b/src/app/settings.rs @@ -16,7 +16,7 @@ pub struct Settings { pub(crate) antialiasing: bool, /// Autosize the window to fit its contents - #[cfg(all(feature = "wayland", target_os = "linux"))] + #[cfg(wayland_platform)] pub(crate) autosize: bool, /// Set the application to not create a main window @@ -80,7 +80,7 @@ impl Default for Settings { fn default() -> Self { Self { antialiasing: true, - #[cfg(all(feature = "wayland", target_os = "linux"))] + #[cfg(wayland_platform)] autosize: false, no_main_window: false, client_decorations: true, diff --git a/src/core.rs b/src/core.rs index b2bf8693..9b301fb5 100644 --- a/src/core.rs +++ b/src/core.rs @@ -521,7 +521,7 @@ impl Core { crate::command::toggle_maximize(id) } - #[cfg(all(feature = "wayland", target_os = "linux"))] + #[cfg(wayland_platform)] pub fn sync_window_border_radii_to_theme(&self) -> bool { match self.app_type { AppType::Window => self.auto_corner_radius.contains(Auto::Window), @@ -591,7 +591,7 @@ impl Core { /// Calculate suggested corners for each app type main window #[must_use] - #[cfg(all(feature = "wayland", target_os = "linux"))] + #[cfg(wayland_platform)] pub fn corners( &self, theme: &Theme, diff --git a/src/lib.rs b/src/lib.rs index c1646e23..38230db5 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -162,7 +162,7 @@ pub(crate) mod malloc; pub mod process; #[doc(inline)] -#[cfg(all(feature = "wayland", target_os = "linux"))] +#[cfg(wayland_platform)] pub use cctk; pub mod surface; diff --git a/src/surface/action.rs b/src/surface/action.rs index 493c9ad0..6620c34f 100644 --- a/src/surface/action.rs +++ b/src/surface/action.rs @@ -6,33 +6,33 @@ use super::Action; use crate::Application; use iced::{Rectangle, window}; -#[cfg(all(feature = "wayland", target_os = "linux", feature = "winit"))] +#[cfg(all(wayland_platform, feature = "winit"))] use iced_runtime::platform_specific::wayland::CornerRadius; -#[cfg(all(feature = "wayland", target_os = "linux", feature = "winit"))] +#[cfg(wayland_platform)] use iced_runtime::platform_specific::wayland::layer_surface::IcedMargin; use std::any::Any; use std::sync::Arc; /// Used to produce a destroy popup message from within a widget. -#[cfg(all(feature = "wayland", target_os = "linux"))] +#[cfg(wayland_platform)] #[must_use] pub fn destroy_popup(id: iced_core::window::Id) -> Action { Action::DestroyPopup(id) } -#[cfg(all(feature = "wayland", target_os = "linux"))] +#[cfg(wayland_platform)] #[must_use] pub fn destroy_subsurface(id: iced_core::window::Id) -> Action { Action::DestroySubsurface(id) } -#[cfg(all(feature = "wayland", target_os = "linux"))] +#[cfg(wayland_platform)] #[must_use] pub fn destroy_window(id: iced_core::window::Id) -> Action { Action::DestroyWindow(id) } -#[cfg(all(feature = "wayland", target_os = "linux"))] +#[cfg(wayland_platform)] #[must_use] pub fn destroy_layer_shell(id: iced_core::window::Id) -> Action { Action::DestroyLayerShell(id) @@ -40,17 +40,17 @@ pub fn destroy_layer_shell(id: iced_core::window::Id) -> Action { #[derive(Debug, Default, Copy, Clone)] pub struct LiveSettings { - #[cfg(all(feature = "wayland", target_os = "linux", feature = "winit"))] + #[cfg(wayland_platform)] /// Override the surface padding value for the surface type. pub padding: Option, - #[cfg(all(feature = "wayland", target_os = "linux", feature = "winit"))] + #[cfg(wayland_platform)] /// Override the default corner radius value for the surface type. pub corners: Option, /// Override the default blur setting for the surface type. pub blur: Option, } -#[cfg(all(feature = "wayland", target_os = "linux", feature = "winit"))] +#[cfg(wayland_platform)] type BoxedView = Option< Box< dyn Fn(&App) -> crate::Element<'_, crate::Action<::Message>> @@ -60,7 +60,7 @@ type BoxedView = Option< >, >; -#[cfg(all(feature = "wayland", target_os = "linux", feature = "winit"))] +#[cfg(wayland_platform)] #[must_use] pub fn app_window( live_settings: impl Fn(&App) -> LiveSettings + Send + Sync + 'static, @@ -92,7 +92,7 @@ pub fn app_window( } /// Used to create a window message from within a widget. -#[cfg(all(feature = "wayland", target_os = "linux", feature = "winit"))] +#[cfg(wayland_platform)] #[must_use] pub fn simple_window( live_settings: impl Fn() -> LiveSettings + Send + Sync + 'static, @@ -129,7 +129,7 @@ pub fn simple_window( ) } -#[cfg(all(feature = "wayland", target_os = "linux", feature = "winit"))] +#[cfg(wayland_platform)] #[must_use] pub fn app_popup( live_settings: impl Fn(&App) -> LiveSettings + Send + Sync + 'static, @@ -162,7 +162,7 @@ pub fn app_popup( } /// Used to create a subsurface message from within a widget. -#[cfg(all(feature = "wayland", target_os = "linux", feature = "winit"))] +#[cfg(wayland_platform)] #[must_use] pub fn simple_subsurface( settings: impl Fn() -> iced_runtime::platform_specific::wayland::subsurface::SctkSubsurfaceSettings @@ -192,7 +192,7 @@ pub fn simple_subsurface( } /// Used to create a popup message from within a widget. -#[cfg(all(feature = "wayland", target_os = "linux", feature = "winit"))] +#[cfg(wayland_platform)] #[must_use] pub fn simple_popup( live_settings: impl Fn() -> LiveSettings + Send + Sync + 'static, @@ -228,7 +228,7 @@ pub fn simple_popup( ) } -#[cfg(all(feature = "wayland", target_os = "linux", feature = "winit"))] +#[cfg(wayland_platform)] #[must_use] pub fn subsurface( settings: impl Fn( @@ -262,7 +262,7 @@ pub fn subsurface( ) } -#[cfg(all(feature = "wayland", target_os = "linux", feature = "winit"))] +#[cfg(wayland_platform)] #[must_use] pub fn simple_layer_shell( live_settings: impl Fn() -> LiveSettings + Send + Sync + 'static, @@ -298,7 +298,7 @@ pub fn simple_layer_shell( ) } -#[cfg(all(feature = "wayland", target_os = "linux", feature = "winit"))] +#[cfg(wayland_platform)] #[must_use] pub fn app_layer_shell( live_settings: impl Fn(&App) -> LiveSettings + Send + Sync + 'static, diff --git a/src/surface/mod.rs b/src/surface/mod.rs index b3858b97..b0a4a819 100644 --- a/src/surface/mod.rs +++ b/src/surface/mod.rs @@ -2,7 +2,7 @@ // SPDX-License-Identifier: MPL-2.0 pub mod action; -#[cfg(all(feature = "wayland", target_os = "linux"))] +#[cfg(wayland_platform)] pub mod corner_radius; use iced::{Limits, Size, Task}; diff --git a/src/theme/style/mod.rs b/src/theme/style/mod.rs index bc648a73..b2a4d62e 100644 --- a/src/theme/style/mod.rs +++ b/src/theme/style/mod.rs @@ -32,7 +32,7 @@ mod text_input; #[doc(inline)] pub use self::text_input::TextInput; -#[cfg(all(feature = "wayland", target_os = "linux", feature = "winit"))] +#[cfg(wayland_platform)] pub mod tooltip; -#[cfg(all(feature = "wayland", target_os = "linux", feature = "winit"))] +#[cfg(wayland_platform)] pub use tooltip::Tooltip; diff --git a/src/widget/autosize.rs b/src/widget/autosize.rs index c52367db..83c4d97e 100644 --- a/src/widget/autosize.rs +++ b/src/widget/autosize.rs @@ -169,7 +169,7 @@ where shell: &mut Shell<'_, Message>, viewport: &Rectangle, ) { - #[cfg(all(feature = "wayland", target_os = "linux"))] + #[cfg(wayland_platform)] if matches!( event, Event::PlatformSpecific(event::PlatformSpecific::Wayland( diff --git a/src/widget/context_menu.rs b/src/widget/context_menu.rs index 4b31fc01..f121bbe2 100644 --- a/src/widget/context_menu.rs +++ b/src/widget/context_menu.rs @@ -3,12 +3,7 @@ //! A context menu is a menu in a graphical user interface that appears upon user interaction, such as a right-click mouse operation. -#[cfg(all( - feature = "wayland", - target_os = "linux", - feature = "winit", - feature = "surface-message" -))] +#[cfg(wayland_platform)] use crate::app::cosmic::{WINDOWING_SYSTEM, WindowingSystem}; use crate::widget::menu::{ self, CloseCondition, Direction, ItemHeight, ItemWidth, MenuBarState, PathHighlight, @@ -64,12 +59,7 @@ pub struct ContextMenu<'a, Message> { } impl ContextMenu<'_, Message> { - #[cfg(all( - feature = "wayland", - target_os = "linux", - feature = "winit", - feature = "surface-message" - ))] + #[cfg(wayland_platform)] #[allow(clippy::too_many_lines)] fn create_popup( &mut self, @@ -391,12 +381,7 @@ impl Widget state.active_root.clear(); state.open = false; - #[cfg(all( - feature = "wayland", - target_os = "linux", - feature = "winit", - feature = "surface-message" - ))] + #[cfg(wayland_platform)] if matches!(WINDOWING_SYSTEM.get(), Some(WindowingSystem::Wayland)) && let Some(id) = state.popup_id.remove(&self.window_id) { @@ -435,12 +420,7 @@ impl Widget state.open = true; state.view_cursor = cursor; }); - #[cfg(all( - feature = "wayland", - target_os = "linux", - feature = "winit", - feature = "surface-message" - ))] + #[cfg(wayland_platform)] if matches!(WINDOWING_SYSTEM.get(), Some(WindowingSystem::Wayland)) { self.create_popup(layout, cursor, renderer, shell, viewport, state); } @@ -457,12 +437,7 @@ impl Widget state.active_root.clear(); state.open = false; - #[cfg(all( - feature = "wayland", - target_os = "linux", - feature = "winit", - feature = "surface-message" - ))] + #[cfg(wayland_platform)] if matches!(WINDOWING_SYSTEM.get(), Some(WindowingSystem::Wayland)) && let Some(id) = state.popup_id.remove(&self.window_id) { @@ -496,12 +471,7 @@ impl Widget _viewport: &iced::Rectangle, translation: Vector, ) -> Option> { - #[cfg(all( - feature = "wayland", - target_os = "linux", - feature = "winit", - feature = "surface-message" - ))] + #[cfg(wayland_platform)] if matches!(WINDOWING_SYSTEM.get(), Some(WindowingSystem::Wayland)) && self.window_id != window::Id::NONE && self.on_surface_action.is_some() diff --git a/src/widget/dropdown/mod.rs b/src/widget/dropdown/mod.rs index b5fd4c06..d0ec175a 100644 --- a/src/widget/dropdown/mod.rs +++ b/src/widget/dropdown/mod.rs @@ -50,7 +50,7 @@ pub fn popup_dropdown< let dropdown: Dropdown<'_, S, Message, AppMessage> = Dropdown::new(selections.into(), selected, on_selected); - #[cfg(all(feature = "winit", feature = "wayland", target_os = "linux"))] + #[cfg(wayland_platform)] let dropdown = dropdown.with_popup(_parent_id, _on_surface_action, _map_action); dropdown diff --git a/src/widget/dropdown/widget.rs b/src/widget/dropdown/widget.rs index 79f854fb..696e6c0d 100644 --- a/src/widget/dropdown/widget.rs +++ b/src/widget/dropdown/widget.rs @@ -60,7 +60,7 @@ where action_map: Option AppMessage + 'static + Send + Sync>>, #[setters(strip_option)] window_id: Option, - #[cfg(all(feature = "winit", feature = "wayland", target_os = "linux"))] + #[cfg(wayland_platform)] positioner: iced_runtime::platform_specific::wayland::popup::SctkPositioner, } @@ -96,14 +96,14 @@ where text_line_height: text::LineHeight::Relative(1.2), font: None, window_id: None, - #[cfg(all(feature = "winit", feature = "wayland", target_os = "linux"))] + #[cfg(wayland_platform)] positioner: iced_runtime::platform_specific::wayland::popup::SctkPositioner::default(), on_surface_action: None, action_map: None, } } - #[cfg(all(feature = "winit", feature = "wayland", target_os = "linux"))] + #[cfg(wayland_platform)] /// Handle dropdown requests for popup creation. /// Intended to be used with [`crate::app::message::get_popup`] pub fn with_popup( @@ -154,7 +154,7 @@ where self } - #[cfg(all(feature = "winit", feature = "wayland", target_os = "linux"))] + #[cfg(wayland_platform)] pub fn with_positioner( mut self, positioner: iced_runtime::platform_specific::wayland::popup::SctkPositioner, @@ -268,7 +268,7 @@ where layout, cursor, shell, - #[cfg(all(feature = "winit", feature = "wayland", target_os = "linux"))] + #[cfg(wayland_platform)] self.positioner.clone(), self.on_selected.clone(), self.selected, @@ -346,7 +346,7 @@ where viewport: &Rectangle, translation: Vector, ) -> Option> { - #[cfg(all(feature = "winit", feature = "wayland", target_os = "linux"))] + #[cfg(wayland_platform)] if self.window_id.is_some() || self.on_surface_action.is_some() { return None; } @@ -545,7 +545,7 @@ pub fn update< layout: Layout<'_>, cursor: mouse::Cursor, shell: &mut Shell<'_, Message>, - #[cfg(all(feature = "winit", feature = "wayland", target_os = "linux"))] + #[cfg(wayland_platform)] positioner: iced_runtime::platform_specific::wayland::popup::SctkPositioner, on_selected: Arc Message + Send + Sync + 'static>, selected: Option, @@ -571,7 +571,7 @@ pub fn update< *hovered_guard = selected; let id = window::Id::unique(); state.popup_id = id; - #[cfg(all(feature = "winit", feature = "wayland", target_os = "linux"))] + #[cfg(wayland_platform)] if let Some(((on_surface_action, parent), action_map)) = on_surface_action .as_ref() .zip(_window_id) @@ -661,7 +661,7 @@ pub fn update< state.close_operation = false; state.is_open.store(false, Ordering::SeqCst); if is_open { - #[cfg(all(feature = "winit", feature = "wayland", target_os = "linux"))] + #[cfg(wayland_platform)] if let Some(ref on_close) = on_surface_action { shell.publish(on_close(surface::action::destroy_popup(state.popup_id))); } @@ -684,7 +684,7 @@ pub fn update< // Event wasn't processed by overlay, so cursor was clicked either outside it's // bounds or on the drop-down, either way we close the overlay. state.is_open.store(false, Ordering::Relaxed); - #[cfg(all(feature = "winit", feature = "wayland", target_os = "linux"))] + #[cfg(wayland_platform)] if let Some(on_close) = on_surface_action { shell.publish(on_close(surface::action::destroy_popup(state.popup_id))); } @@ -729,7 +729,7 @@ pub fn mouse_interaction(layout: Layout<'_>, cursor: mouse::Cursor) -> mouse::In } } -#[cfg(all(feature = "winit", feature = "wayland", target_os = "linux"))] +#[cfg(wayland_platform)] /// Returns the current menu widget of a [`Dropdown`]. #[allow(clippy::too_many_arguments)] pub fn menu_widget< diff --git a/src/widget/menu/menu_bar.rs b/src/widget/menu/menu_bar.rs index fce272e1..84927b67 100644 --- a/src/widget/menu/menu_bar.rs +++ b/src/widget/menu/menu_bar.rs @@ -9,13 +9,7 @@ use super::menu_inner::{ }; use super::menu_tree::MenuTree; use crate::Renderer; -#[cfg(all( - feature = "multi-window", - feature = "wayland", - target_os = "linux", - feature = "winit", - feature = "surface-message" -))] +#[cfg(wayland_platform)] use crate::app::cosmic::{WINDOWING_SYSTEM, WindowingSystem}; use crate::style::menu_bar::StyleSheet; use crate::widget::RcWrapper; @@ -191,12 +185,7 @@ pub struct MenuBar { menu_roots: Vec>, style: ::Style, window_id: window::Id, - #[cfg(all( - feature = "multi-window", - feature = "wayland", - feature = "winit", - target_os = "linux" - ))] + #[cfg(wayland_platform)] positioner: iced_runtime::platform_specific::wayland::popup::SctkPositioner, pub(crate) on_surface_action: Option Message + Send + Sync + 'static>>, @@ -231,12 +220,7 @@ where menu_roots, style: ::Style::default(), window_id: window::Id::RESERVED, - #[cfg(all( - feature = "multi-window", - feature = "wayland", - feature = "winit", - target_os = "linux" - ))] + #[cfg(wayland_platform)] positioner: iced_runtime::platform_specific::wayland::popup::SctkPositioner::default(), on_surface_action: None, } @@ -330,12 +314,7 @@ where self } - #[cfg(all( - feature = "multi-window", - feature = "wayland", - feature = "winit", - target_os = "linux" - ))] + #[cfg(wayland_platform)] pub fn with_positioner( mut self, positioner: iced_runtime::platform_specific::wayland::popup::SctkPositioner, @@ -367,13 +346,7 @@ where self } - #[cfg(all( - feature = "multi-window", - feature = "wayland", - target_os = "linux", - feature = "winit", - feature = "surface-message" - ))] + #[cfg(wayland_platform)] #[allow(clippy::too_many_lines)] fn create_popup( &mut self, @@ -657,12 +630,7 @@ where state.menu_states.clear(); state.active_root.clear(); state.open = false; - #[cfg(all( - feature = "wayland", - target_os = "linux", - feature = "winit", - feature = "surface-message" - ))] + #[cfg(wayland_platform)] { let surface_action = self.on_surface_action.as_ref().unwrap(); shell.capture_event(); @@ -680,13 +648,7 @@ where return; } shell.capture_event(); - #[cfg(all( - feature = "multi-window", - feature = "wayland", - target_os = "linux", - feature = "winit", - feature = "surface-message" - ))] + #[cfg(wayland_platform)] if matches!(WINDOWING_SYSTEM.get(), Some(WindowingSystem::Wayland)) { self.create_popup(layout, view_cursor, renderer, shell, viewport, my_state); } @@ -695,13 +657,7 @@ where if open && view_cursor.is_over(layout.bounds()) => { shell.capture_event(); - #[cfg(all( - feature = "multi-window", - feature = "wayland", - target_os = "linux", - feature = "winit", - feature = "surface-message" - ))] + #[cfg(wayland_platform)] if matches!(WINDOWING_SYSTEM.get(), Some(WindowingSystem::Wayland)) { self.create_popup(layout, view_cursor, renderer, shell, viewport, my_state); } @@ -732,13 +688,7 @@ where // draw path highlight if self.path_highlight.is_some() { let mut is_overlay = true; - #[cfg(all( - feature = "multi-window", - feature = "wayland", - target_os = "linux", - feature = "winit", - feature = "surface-message" - ))] + #[cfg(wayland_platform)] if matches!(WINDOWING_SYSTEM.get(), Some(WindowingSystem::Wayland)) && self.on_surface_action.is_some() && self.window_id != window::Id::NONE @@ -792,13 +742,7 @@ where viewport: &Rectangle, translation: Vector, ) -> Option> { - #[cfg(all( - feature = "multi-window", - feature = "wayland", - target_os = "linux", - feature = "winit", - feature = "surface-message" - ))] + #[cfg(wayland_platform)] if matches!(WINDOWING_SYSTEM.get(), Some(WindowingSystem::Wayland)) && self.on_surface_action.is_some() && self.window_id != window::Id::NONE diff --git a/src/widget/menu/menu_inner.rs b/src/widget/menu/menu_inner.rs index 53c87415..c0d7f10a 100644 --- a/src/widget/menu/menu_inner.rs +++ b/src/widget/menu/menu_inner.rs @@ -6,13 +6,7 @@ use std::sync::Arc; use super::menu_bar::MenuBarState; use super::menu_tree::MenuTree; -#[cfg(all( - feature = "multi-window", - feature = "wayland", - target_os = "linux", - feature = "winit", - feature = "surface-message" -))] +#[cfg(wayland_platform)] use crate::app::cosmic::{WINDOWING_SYSTEM, WindowingSystem}; use crate::style::menu_bar::StyleSheet; @@ -677,13 +671,7 @@ impl<'b, Message: Clone + 'static> Menu<'b, Message> { needs_reset |= self.close_condition.click_outside && !is_inside; if needs_reset { - #[cfg(all( - feature = "multi-window", - feature = "wayland", - target_os = "linux", - feature = "winit", - feature = "surface-message" - ))] + #[cfg(wayland_platform)] if matches!(WINDOWING_SYSTEM.get(), Some(WindowingSystem::Wayland)) && let Some(handler) = self.on_surface_action.as_ref() { @@ -990,13 +978,7 @@ impl Widget( }); } -#[cfg(all( - feature = "multi-window", - feature = "wayland", - target_os = "linux", - feature = "winit", - feature = "surface-message" -))] +#[cfg(wayland_platform)] pub(super) fn init_root_popup_menu( menu: &mut Menu<'_, Message>, renderer: &crate::Renderer, @@ -1572,7 +1548,7 @@ where .as_ref() .is_some_and(|i| *i != new_index && !active_menu[*i].children.is_empty()); - #[cfg(all(feature = "multi-window", feature = "wayland",target_os = "linux", feature = "winit", feature = "surface-message"))] + #[cfg(wayland_platform)] if matches!(WINDOWING_SYSTEM.get(), Some(WindowingSystem::Wayland)) && remove { if let Some(id) = state.popup_id.remove(&menu.window_id) { state.active_root.truncate(menu.depth + 1); diff --git a/src/widget/mod.rs b/src/widget/mod.rs index 5089b997..ab1eef31 100644 --- a/src/widget/mod.rs +++ b/src/widget/mod.rs @@ -312,7 +312,7 @@ pub use toggler::{Toggler, toggler}; #[doc(inline)] pub use tooltip::{Tooltip, tooltip}; -#[cfg(all(feature = "wayland", target_os = "linux", feature = "winit"))] +#[cfg(wayland_platform)] pub mod wayland; pub mod tooltip { diff --git a/src/widget/nav_bar.rs b/src/widget/nav_bar.rs index d6595359..14790866 100644 --- a/src/widget/nav_bar.rs +++ b/src/widget/nav_bar.rs @@ -134,12 +134,7 @@ impl<'a, Message: Clone + 'static> NavBar<'a, Message> { self } - #[cfg(all( - feature = "multi-window", - feature = "wayland", - feature = "winit", - target_os = "linux" - ))] + #[cfg(wayland_platform)] pub fn with_positioner( mut self, positioner: iced_runtime::platform_specific::wayland::popup::SctkPositioner, diff --git a/src/widget/responsive_menu_bar.rs b/src/widget/responsive_menu_bar.rs index 2cae68d8..b7b416ef 100644 --- a/src/widget/responsive_menu_bar.rs +++ b/src/widget/responsive_menu_bar.rs @@ -23,7 +23,7 @@ impl Default for ResponsiveMenuBar { fn default() -> ResponsiveMenuBar { ResponsiveMenuBar { collapsed_item_width: { - #[cfg(all(feature = "winit", feature = "wayland", target_os = "linux"))] + #[cfg(wayland_platform)] if matches!( crate::app::cosmic::WINDOWING_SYSTEM.get(), Some(crate::app::cosmic::WindowingSystem::Wayland) @@ -32,7 +32,7 @@ impl Default for ResponsiveMenuBar { } else { ItemWidth::Static(84) } - #[cfg(not(all(feature = "winit", feature = "wayland", target_os = "linux")))] + #[cfg(not(wayland_platform))] { ItemWidth::Static(84) } diff --git a/src/widget/segmented_button/widget.rs b/src/widget/segmented_button/widget.rs index fbefce34..ca877348 100644 --- a/src/widget/segmented_button/widget.rs +++ b/src/widget/segmented_button/widget.rs @@ -195,12 +195,7 @@ where pub(super) on_reorder: Option Message + 'static>>, #[setters(skip)] window_id: window::Id, - #[cfg(all( - feature = "multi-window", - feature = "wayland", - feature = "winit", - target_os = "linux" - ))] + #[cfg(wayland_platform)] positioner: iced_runtime::platform_specific::wayland::popup::SctkPositioner, #[setters(skip)] pub(crate) on_surface_action: @@ -259,12 +254,7 @@ where on_drop_hint: None, on_reorder: None, window_id: window::Id::RESERVED, - #[cfg(all( - feature = "multi-window", - feature = "wayland", - feature = "winit", - target_os = "linux" - ))] + #[cfg(wayland_platform)] positioner: iced_runtime::platform_specific::wayland::popup::SctkPositioner::default(), on_surface_action: None, } @@ -883,12 +873,7 @@ where ) } - #[cfg(all( - feature = "multi-window", - feature = "wayland", - feature = "winit", - target_os = "linux" - ))] + #[cfg(wayland_platform)] pub fn with_positioner( mut self, positioner: iced_runtime::platform_specific::wayland::popup::SctkPositioner, @@ -920,13 +905,7 @@ where self } - #[cfg(all( - feature = "multi-window", - feature = "wayland", - target_os = "linux", - feature = "winit", - feature = "surface-message" - ))] + #[cfg(wayland_platform)] #[allow(clippy::too_many_lines)] fn create_popup<'b>( &mut self, @@ -1084,7 +1063,7 @@ where let rad = styling.menu_border_radius; /// Used to create a popup message from within a widget. - #[cfg(all(feature = "wayland", target_os = "linux", feature = "winit"))] + #[cfg(wayland_platform)] #[must_use] pub fn simple_popup( live_settings: impl Fn() -> LiveSettings + Send + Sync + 'static, @@ -1660,13 +1639,7 @@ where state.unfocus(); } - #[cfg(all( - feature = "multi-window", - feature = "wayland", - target_os = "linux", - feature = "winit", - feature = "surface-message" - ))] + #[cfg(wayland_platform)] if is_pressed(event) && let Some(on_context) = self.on_context.as_ref() { @@ -1722,13 +1695,7 @@ where shell.publish(on_context(key)); shell.capture_event(); - #[cfg(all( - feature = "multi-window", - feature = "wayland", - target_os = "linux", - feature = "winit", - feature = "surface-message" - ))] + #[cfg(wayland_platform)] if matches!( crate::app::cosmic::WINDOWING_SYSTEM.get(), Some(crate::app::cosmic::WindowingSystem::Wayland) @@ -1867,12 +1834,7 @@ where .inner .with_data_mut(|ms| ms.popup_id.remove(&self.window_id)) { - #[cfg(all( - feature = "wayland", - target_os = "linux", - feature = "winit", - feature = "surface-message" - ))] + #[cfg(wayland_platform)] { let surface_action = self.on_surface_action.as_ref().unwrap(); shell.capture_event(); @@ -2507,13 +2469,7 @@ where _viewport: &iced_core::Rectangle, translation: Vector, ) -> Option> { - #[cfg(all( - feature = "multi-window", - feature = "wayland", - target_os = "linux", - feature = "winit", - feature = "surface-message" - ))] + #[cfg(wayland_platform)] if matches!( crate::app::cosmic::WINDOWING_SYSTEM.get(), Some(crate::app::cosmic::WindowingSystem::Wayland) diff --git a/src/widget/text_input/input.rs b/src/widget/text_input/input.rs index 65b84882..ece26192 100644 --- a/src/widget/text_input/input.rs +++ b/src/widget/text_input/input.rs @@ -525,7 +525,7 @@ where } /// Sets the start dnd handler of the [`TextInput`]. - #[cfg(all(feature = "wayland", target_os = "linux"))] + #[cfg(wayland_platform)] pub fn on_start_dnd(mut self, on_start_dnd: impl Fn(State) -> Message + 'a) -> Self { self.on_create_dnd_source = Some(Box::new(on_start_dnd)); self @@ -1553,7 +1553,7 @@ pub fn update<'a, Message: Clone + 'static>( click.kind(), state.cursor().state(value), ) { - #[cfg(all(feature = "wayland", target_os = "linux"))] + #[cfg(wayland_platform)] (None, click::Kind::Single, cursor::State::Selection { start, end }) => { let left = start.min(end); let right = end.max(start); @@ -1694,7 +1694,7 @@ pub fn update<'a, Message: Clone + 'static>( | Event::Touch(touch::Event::FingerLifted { .. } | touch::Event::FingerLost { .. }) => { cold(); let state = state(); - #[cfg(all(feature = "wayland", target_os = "linux"))] + #[cfg(wayland_platform)] if matches!(state.dragging_state, Some(DraggingState::PrepareDnd(_))) { // clear selection and place cursor at click position update_cache(state, value); @@ -1749,7 +1749,7 @@ pub fn update<'a, Message: Clone + 'static>( shell.capture_event(); return; } - #[cfg(all(feature = "wayland", target_os = "linux"))] + #[cfg(wayland_platform)] if let Some(DraggingState::PrepareDnd(start_position)) = state.dragging_state { let distance = ((position.x - start_position.x).powi(2) + (position.y - start_position.y).powi(2)) @@ -2206,7 +2206,7 @@ pub fn update<'a, Message: Clone + 'static>( shell.request_redraw(); } } - #[cfg(all(feature = "wayland", target_os = "linux"))] + #[cfg(wayland_platform)] Event::Dnd(DndEvent::Source(SourceEvent::Finished | SourceEvent::Cancelled)) => { cold(); let state = state(); @@ -2217,7 +2217,7 @@ pub fn update<'a, Message: Clone + 'static>( return; } } - #[cfg(all(feature = "wayland", target_os = "linux"))] + #[cfg(wayland_platform)] Event::Dnd(DndEvent::Offer( rectangle, OfferEvent::Enter { @@ -2267,7 +2267,7 @@ pub fn update<'a, Message: Clone + 'static>( return; } } - #[cfg(all(feature = "wayland", target_os = "linux"))] + #[cfg(wayland_platform)] Event::Dnd(DndEvent::Offer(rectangle, OfferEvent::Motion { x, y })) if *rectangle == Some(dnd_id) => { @@ -2295,7 +2295,7 @@ pub fn update<'a, Message: Clone + 'static>( shell.capture_event(); return; } - #[cfg(all(feature = "wayland", target_os = "linux"))] + #[cfg(wayland_platform)] Event::Dnd(DndEvent::Offer(rectangle, OfferEvent::Drop)) if *rectangle == Some(dnd_id) => { cold(); let state = state(); @@ -2313,9 +2313,9 @@ pub fn update<'a, Message: Clone + 'static>( return; } - #[cfg(all(feature = "wayland", target_os = "linux"))] + #[cfg(wayland_platform)] Event::Dnd(DndEvent::Offer(id, OfferEvent::LeaveDestination)) if Some(dnd_id) != *id => {} - #[cfg(all(feature = "wayland", target_os = "linux"))] + #[cfg(wayland_platform)] Event::Dnd(DndEvent::Offer( rectangle, OfferEvent::Leave | OfferEvent::LeaveDestination, @@ -2333,7 +2333,7 @@ pub fn update<'a, Message: Clone + 'static>( shell.capture_event(); return; } - #[cfg(all(feature = "wayland", target_os = "linux"))] + #[cfg(wayland_platform)] Event::Dnd(DndEvent::Offer(rectangle, OfferEvent::Data { data, mime_type })) if *rectangle == Some(dnd_id) => { @@ -2616,9 +2616,9 @@ pub fn draw<'a, Message>( let actual_width = text_width.max(text_bounds.width); let radius_0 = THEME.lock().unwrap().cosmic().corner_radii.radius_0.into(); - #[cfg(all(feature = "wayland", target_os = "linux"))] + #[cfg(wayland_platform)] let handling_dnd_offer = !matches!(state.dnd_offer, DndOfferState::None); - #[cfg(not(all(feature = "wayland", target_os = "linux")))] + #[cfg(not(wayland_platform))] let handling_dnd_offer = false; let (cursors, offset, is_selecting) = if let Some(focus) = state.is_focused.filter(|f| f.focused).or_else(|| { @@ -2868,7 +2868,7 @@ pub fn mouse_interaction( #[derive(Debug, Clone)] pub struct TextInputString(pub String); -#[cfg(all(feature = "wayland", target_os = "linux"))] +#[cfg(wayland_platform)] impl AsMimeTypes for TextInputString { fn available(&self) -> Cow<'static, [String]> { Cow::Owned( @@ -2892,13 +2892,13 @@ impl AsMimeTypes for TextInputString { #[derive(Debug, Clone, PartialEq)] pub(crate) enum DraggingState { Selection, - #[cfg(all(feature = "wayland", target_os = "linux"))] + #[cfg(wayland_platform)] PrepareDnd(Point), - #[cfg(all(feature = "wayland", target_os = "linux"))] + #[cfg(wayland_platform)] Dnd(DndAction, String), } -#[cfg(all(feature = "wayland", target_os = "linux"))] +#[cfg(wayland_platform)] #[derive(Debug, Default, Clone)] pub(crate) enum DndOfferState { #[default] @@ -2907,7 +2907,7 @@ pub(crate) enum DndOfferState { Dropped, } #[derive(Debug, Default, Clone)] -#[cfg(not(all(feature = "wayland", target_os = "linux")))] +#[cfg(not(wayland_platform))] pub(crate) struct DndOfferState; /// The state of a [`TextInput`]. @@ -2983,7 +2983,7 @@ impl State { } } - #[cfg(all(feature = "wayland", target_os = "linux"))] + #[cfg(wayland_platform)] /// Returns the current value of the dragged text in the [`TextInput`]. #[must_use] pub fn dragged_text(&self) -> Option {