fix: conditional features and tests

This commit is contained in:
Michael Aaron Murphy 2025-03-05 17:56:19 +01:00 • committed by Ashley Wulber
parent adb08f9daf
commit ed59fe8fb3
No known key found for this signature in database
GPG key ID: 5216D4F46A90A820
8 changed files with 19 additions and 25 deletions

View file

@ -1,12 +1,13 @@
// Copyright 2023 System76 <info@system76.com>
// SPDX-License-Identifier: MPL-2.0
#[cfg(feature = "winit")]
use crate::app;
pub const fn app<M>(message: M) -> Action<M> {
Action::App(message)
}
#[cfg(feature = "winit")]
pub const fn cosmic<M>(message: app::Action) -> Action<M> {
Action::Cosmic(message)
}
@ -20,9 +21,10 @@ pub const fn none<M>() -> Action<M> {
pub enum Action<M> {
/// Messages from the application, for the application.
App(M),
#[cfg(feature = "winit")]
/// Internal messages to be handled by libcosmic.
Cosmic(app::Action),
#[cfg(feature = "single-instance")]
#[cfg(all(feature = "winit", feature = "single-instance"))]
/// Dbus activation messages
DbusActivation(app::DbusActivationMessage),
/// Do nothing

View file

@ -24,10 +24,12 @@ pub fn set_title<M>(id: window::Id, title: String) -> iced::Task<crate::Action<M
iced::Task::none()
}
#[cfg(feature = "winit")]
pub fn set_scaling_factor<M: Send + 'static>(factor: f32) -> iced::Task<crate::Action<M>> {
iced::Task::done(crate::app::Action::ScaleFactor(factor)).map(crate::Action::Cosmic)
}
#[cfg(feature = "winit")]
pub fn set_theme<M: Send + 'static>(theme: crate::Theme) -> iced::Task<crate::Action<M>> {
iced::Task::done(crate::app::Action::AppThemeChange(theme)).map(crate::Action::Cosmic)
}

View file

@ -382,6 +382,7 @@ impl Core {
id
}
#[cfg(feature = "winit")]
pub fn drag<M: Send + 'static>(&self, id: Option<window::Id>) -> crate::app::Task<M> {
let Some(id) = id.or(self.main_window) else {
return iced::Task::none();
@ -389,6 +390,7 @@ impl Core {
crate::command::drag(id)
}
#[cfg(feature = "winit")]
pub fn maximize<M: Send + 'static>(
&self,
id: Option<window::Id>,
@ -400,6 +402,7 @@ impl Core {
crate::command::maximize(id, maximized)
}
#[cfg(feature = "winit")]
pub fn minimize<M: Send + 'static>(&self, id: Option<window::Id>) -> crate::app::Task<M> {
let Some(id) = id.or(self.main_window) else {
return iced::Task::none();
@ -407,6 +410,7 @@ impl Core {
crate::command::minimize(id)
}
#[cfg(feature = "winit")]
pub fn set_title<M: Send + 'static>(
&self,
id: Option<window::Id>,
@ -418,6 +422,7 @@ impl Core {
crate::command::set_title(id, title)
}
#[cfg(feature = "winit")]
pub fn set_windowed<M: Send + 'static>(&self, id: Option<window::Id>) -> crate::app::Task<M> {
let Some(id) = id.or(self.main_window) else {
return iced::Task::none();
@ -425,6 +430,7 @@ impl Core {
crate::command::set_windowed(id)
}
#[cfg(feature = "winit")]
pub fn toggle_maximize<M: Send + 'static>(
&self,
id: Option<window::Id>,

View file

@ -1,6 +1,7 @@
// Copyright 2025 System76 <info@system76.com>
// SPDX-License-Identifier: MPL-2.0
#[cfg(feature = "winit")]
pub mod action;
use iced::Limits;

View file

@ -97,7 +97,6 @@ pub mod aspect_ratio;
#[cfg(feature = "autosize")]
pub mod autosize;
#[cfg(feature = "winit")]
pub(crate) mod responsive_container;
#[cfg(feature = "surface-message")]