diff --git a/src/app/cosmic.rs b/src/app/cosmic.rs index 5a83f66e..b559ab4a 100644 --- a/src/app/cosmic.rs +++ b/src/app/cosmic.rs @@ -535,14 +535,14 @@ where // popup pipeline. Drained before the creation queue so a // destroy-then-recreate (a second right-click reusing the same id) // keeps its order. - #[cfg(all(feature = "wayland", target_os = "linux"))] + #[cfg(all(wayland_platform, target_os = "linux"))] for id in crate::widget::text_context_menu::take_popup_destroys() { task = task.chain(iced_winit::commands::popup::destroy_popup(id)); } // Drain any text context-menu popup requests queued by widgets during // `app.update()` and create them through the normal popup pipeline. - #[cfg(all(feature = "wayland", target_os = "linux"))] + #[cfg(all(wayland_platform, target_os = "linux"))] for req in crate::widget::text_context_menu::take_popup_requests() { let (settings, view) = crate::widget::text_context_menu::into_popup_view::(req); @@ -723,7 +723,7 @@ where // Drives the text context-menu popup queues: a right-click queues a // popup but publishes no message, so this re-emits `Action::None` to // make `update()` run and drain the queue. - #[cfg(all(feature = "wayland", target_os = "linux"))] + #[cfg(all(wayland_platform, target_os = "linux"))] subscriptions.push(crate::widget::text_context_menu::wake_subscription::< T::Message, >()); @@ -743,7 +743,7 @@ where #[cfg(feature = "multi-window")] pub fn view(&self, id: window::Id) -> Element<'_, crate::Action> { - #[cfg(all(feature = "wayland", target_os = "linux"))] + #[cfg(all(wayland_platform, target_os = "linux"))] if let Some((_, _, _, Some(v))) = self.surface_views.get(&id) { return v(&self.app); } diff --git a/src/widget/selectable_text.rs b/src/widget/selectable_text.rs index 5bd85ed4..4b47cfd4 100644 --- a/src/widget/selectable_text.rs +++ b/src/widget/selectable_text.rs @@ -69,7 +69,7 @@ impl<'a> SelectableText<'a> { } fn uses_popup_context_menu(&self) -> bool { - #[cfg(all(feature = "wayland", feature = "winit"))] + #[cfg(all(wayland_platform, feature = "winit"))] if matches!( crate::app::cosmic::WINDOWING_SYSTEM.get(), Some(crate::app::cosmic::WindowingSystem::Wayland) @@ -329,7 +329,7 @@ impl<'a, Message: Clone + 'static> Widget for S viewport, ); - #[cfg(feature = "wayland")] + #[cfg(wayland_platform)] if self.uses_popup_context_menu() { use iced_core::widget::text::HasSelectableText; diff --git a/src/widget/text_context_menu.rs b/src/widget/text_context_menu.rs index 7912e37c..6fdea222 100644 --- a/src/widget/text_context_menu.rs +++ b/src/widget/text_context_menu.rs @@ -51,13 +51,13 @@ thread_local! { static CURRENT_WINDOW_ID: Cell = const { Cell::new(iced_core::window::Id::NONE) }; } -#[cfg(feature = "wayland")] +#[cfg(wayland_platform)] use iced_runtime::platform_specific::wayland::popup::SctkPopupSettings; /// A request to create a text context-menu popup surface, queued by a widget /// during `update()` and drained by `Cosmic::update()` so the popup goes /// through the normal `get_popup()` Task + `surface_views` pipeline. -#[cfg(feature = "wayland")] +#[cfg(wayland_platform)] pub(crate) struct PopupRequest { settings: SctkPopupSettings, menu: Menu<'static, TextCtxAction>, @@ -65,7 +65,7 @@ pub(crate) struct PopupRequest { pending_action: PendingAction, } -#[cfg(feature = "wayland")] +#[cfg(wayland_platform)] thread_local! { static PENDING_POPUP_REQUESTS: std::cell::RefCell> = const { std::cell::RefCell::new(Vec::new()) }; @@ -80,7 +80,7 @@ pub(crate) fn current_window_id() -> iced_core::window::Id { } /// Drains all popup requests queued by widgets this frame. -#[cfg(feature = "wayland")] +#[cfg(wayland_platform)] pub(crate) fn take_popup_requests() -> Vec { PENDING_POPUP_REQUESTS.with(|q| std::mem::take(&mut *q.borrow_mut())) } @@ -88,7 +88,7 @@ pub(crate) fn take_popup_requests() -> Vec { /// Consumes a [`PopupRequest`], returning the popup settings plus a view /// builder. The builder rebuilds the menu element each frame from the /// captured content, independent of app state. -#[cfg(feature = "wayland")] +#[cfg(wayland_platform)] #[allow(clippy::type_complexity)] pub(crate) fn into_popup_view( req: PopupRequest, @@ -117,7 +117,7 @@ pub(crate) fn into_popup_view( (settings, view) } -#[cfg(feature = "wayland")] +#[cfg(wayland_platform)] thread_local! { static PENDING_POPUP_DESTROYS: std::cell::RefCell> = const { std::cell::RefCell::new(Vec::new()) }; @@ -129,22 +129,22 @@ thread_local! { /// inside `update()` can't reach `Cosmic` to issue a Task, so they push the /// id here and `Cosmic::update()` drains it into a `destroy_popup` Task that /// flows through the normal surface pipeline. -#[cfg(feature = "wayland")] +#[cfg(wayland_platform)] fn queue_destroy_popup(id: iced_core::window::Id) { PENDING_POPUP_DESTROYS.with(|q| q.borrow_mut().push(id)); wake_runtime(); } -#[cfg(feature = "wayland")] +#[cfg(wayland_platform)] static WAKE_TX: std::sync::OnceLock> = std::sync::OnceLock::new(); /// Stable identity for [`wake_subscription`]. -#[cfg(feature = "wayland")] +#[cfg(wayland_platform)] struct PopupWake; /// Nudges the runtime so `Cosmic::update()` runs and drains the popup queues. -#[cfg(feature = "wayland")] +#[cfg(wayland_platform)] fn wake_runtime() { if let Some(tx) = WAKE_TX.get() { let _ = tx.clone().try_send(()); @@ -155,7 +155,7 @@ fn wake_runtime() { /// wake channel and re-emits each ping as [`crate::Action::None`]. Add it to /// the app's subscriptions (done by `Cosmic::subscription`) so popup creation /// and teardown queued from widget `update()` get drained promptly. -#[cfg(feature = "wayland")] +#[cfg(wayland_platform)] pub(crate) fn wake_subscription() -> iced_futures::Subscription> { use iced_futures::futures::{SinkExt, StreamExt}; @@ -466,7 +466,7 @@ where /// Pushes a [`PopupRequest`] onto the request queue; `Cosmic::update()` /// drains it and creates the popup through `get_popup()`, so it flows /// through the normal Task + `surface_views` pipeline. -#[cfg(feature = "wayland")] +#[cfg(wayland_platform)] pub(crate) fn create_text_context_popup( click_position: Point, selected_text: Option, @@ -602,7 +602,7 @@ pub(crate) fn create_text_context_popup( /// Dismisses this widget's open context-menu popup on an outside click, /// touch, or Escape. -#[cfg(feature = "wayland")] +#[cfg(wayland_platform)] pub(crate) fn dismiss_popup_on_event(menu_bar_state: &MenuBarState, event: &event::Event) { let is_dismiss = matches!( event, @@ -710,7 +710,7 @@ impl iced_core::widget::Widget, viewport: &Rectangle, ) { - #[cfg(feature = "wayland")] + #[cfg(wayland_platform)] { use iced_core::event::wayland::PopupEvent; let popup_event = match event { @@ -736,7 +736,7 @@ impl iced_core::widget::Widget iced_core::widget::Widget TextEditor<'a, Message> { } fn uses_popup_context_menu(&self) -> bool { - #[cfg(all(feature = "wayland", feature = "winit"))] + #[cfg(all(wayland_platform, feature = "winit"))] if matches!( crate::app::cosmic::WINDOWING_SYSTEM.get(), Some(crate::app::cosmic::WindowingSystem::Wayland) @@ -275,7 +275,7 @@ impl<'a, Message: Clone + 'static> Widget bool { - #[cfg(all(feature = "wayland", feature = "winit"))] + #[cfg(all(wayland_platform, feature = "winit"))] if matches!( crate::app::cosmic::WINDOWING_SYSTEM.get(), Some(crate::app::cosmic::WindowingSystem::Wayland) @@ -919,7 +919,7 @@ where shell: &mut Shell<'_, Message>, viewport: &Rectangle, ) { - #[cfg(all(feature = "wayland", feature = "winit"))] + #[cfg(all(wayland_platform, feature = "winit"))] if self.uses_popup_context_menu() { let menu_bar_state = tree.state.downcast_ref::().menu_bar_state.clone(); crate::widget::text_context_menu::dismiss_popup_on_event(&menu_bar_state, event); @@ -1036,7 +1036,7 @@ where ); // On Wayland: if right-click just set context_menu_position, create a popup instead. - #[cfg(all(feature = "wayland", feature = "winit"))] + #[cfg(all(wayland_platform, feature = "winit"))] if matches!( crate::app::cosmic::WINDOWING_SYSTEM.get(), Some(crate::app::cosmic::WindowingSystem::Wayland)