fix: feature gates
This commit is contained in:
parent
511384f620
commit
8e6aea650a
23 changed files with 161 additions and 327 deletions
|
|
@ -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(
|
||||
|
|
|
|||
|
|
@ -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<Message: Clone + 'static> 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<Message: 'static + Clone> Widget<Message, crate::Theme, crate::Renderer>
|
|||
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<Message: 'static + Clone> Widget<Message, crate::Theme, crate::Renderer>
|
|||
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<Message: 'static + Clone> Widget<Message, crate::Theme, crate::Renderer>
|
|||
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<Message: 'static + Clone> Widget<Message, crate::Theme, crate::Renderer>
|
|||
_viewport: &iced::Rectangle,
|
||||
translation: Vector,
|
||||
) -> Option<iced_core::overlay::Element<'b, Message, crate::Theme, crate::Renderer>> {
|
||||
#[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()
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ where
|
|||
action_map: Option<Arc<dyn Fn(Message) -> AppMessage + 'static + Send + Sync>>,
|
||||
#[setters(strip_option)]
|
||||
window_id: Option<window::Id>,
|
||||
#[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<NewAppMessage>(
|
||||
|
|
@ -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<overlay::Element<'b, Message, crate::Theme, crate::Renderer>> {
|
||||
#[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<dyn Fn(usize) -> Message + Send + Sync + 'static>,
|
||||
selected: Option<usize>,
|
||||
|
|
@ -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<
|
||||
|
|
|
|||
|
|
@ -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<Message> {
|
|||
menu_roots: Vec<MenuTree<Message>>,
|
||||
style: <crate::Theme as StyleSheet>::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<Arc<dyn Fn(crate::surface::Action) -> Message + Send + Sync + 'static>>,
|
||||
|
|
@ -231,12 +220,7 @@ where
|
|||
menu_roots,
|
||||
style: <crate::Theme as StyleSheet>::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<overlay::Element<'b, Message, crate::Theme, Renderer>> {
|
||||
#[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
|
||||
|
|
|
|||
|
|
@ -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<Message: std::clone::Clone + 'static> Widget<Message, crate::Theme, crate::
|
|||
) {
|
||||
let new_root = self.update(event, layout, cursor, renderer, clipboard, shell);
|
||||
|
||||
#[cfg(all(
|
||||
feature = "multi-window",
|
||||
feature = "wayland",
|
||||
feature = "winit",
|
||||
feature = "surface-message",
|
||||
target_os = "linux"
|
||||
))]
|
||||
#[cfg(wayland_platform)]
|
||||
if matches!(WINDOWING_SYSTEM.get(), Some(WindowingSystem::Wayland))
|
||||
&& let Some((new_root, new_ms)) = new_root
|
||||
{
|
||||
|
|
@ -1271,13 +1253,7 @@ pub(crate) fn init_root_menu<Message: Clone>(
|
|||
});
|
||||
}
|
||||
|
||||
#[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<Message>(
|
||||
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);
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -195,12 +195,7 @@ where
|
|||
pub(super) on_reorder: Option<Box<dyn Fn(ReorderEvent) -> 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<Message: 'static>(
|
||||
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<iced_core::overlay::Element<'b, Message, crate::Theme, Renderer>> {
|
||||
#[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)
|
||||
|
|
|
|||
|
|
@ -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<String> {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue