fix: feature gates

This commit is contained in:
Ashley Wulber 2026-07-15 12:36:30 -04:00 • committed by Ashley Wulber
parent 511384f620
commit 8e6aea650a
23 changed files with 161 additions and 327 deletions

View file

@ -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> {