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

@ -6,7 +6,7 @@ use cosmic::iced::{self, Length, Limits, Task};
use cosmic::iced_runtime::core::window;
use cosmic::iced_runtime::platform_specific::wayland::popup::SctkPopupSettings;
use cosmic::iced_runtime::platform_specific::wayland::subsurface;
use cosmic::surface_message::{MessageWrapper, SurfaceMessage};
use cosmic::surface::{MessageWrapper, SurfaceMessage};
use cosmic::widget::dropdown::DropdownView;
use cosmic::widget::{autosize, dropdown, layer_container, list_column, settings, toggler};
use cosmic::{iced_core, Element};

View file

@ -70,10 +70,10 @@ pub enum NavMenuAction {
}
impl menu::Action for NavMenuAction {
type Message = cosmic::app::Message<Message>;
type Message = cosmic::Action<Message>;
fn message(&self) -> Self::Message {
cosmic::app::Message::App(Message::NavMenuAction(*self))
cosmic::Action::App(Message::NavMenuAction(*self))
}
}
@ -131,7 +131,7 @@ impl cosmic::Application for App {
fn nav_context_menu(
&self,
id: nav_bar::Id,
) -> Option<Vec<menu::Tree<cosmic::app::Message<Self::Message>>>> {
) -> Option<Vec<menu::Tree<cosmic::Action<Self::Message>>>> {
Some(menu::items(
&HashMap::new(),
vec![

View file

@ -7,7 +7,6 @@ use apply::Apply;
use cosmic::app::{Core, Settings, Task};
use cosmic::dialog::file_chooser::{self, FileFilter};
use cosmic::iced_core::Length;
use cosmic::surface_message::{MessageWrapper, SurfaceMessage};
use cosmic::widget::button;
use cosmic::{executor, iced, ApplicationExt, Element};
use std::sync::Arc;
@ -35,22 +34,7 @@ pub enum Message {
OpenError(Arc<file_chooser::Error>),
OpenFile,
Selected(Url),
Surface(SurfaceMessage),
}
impl From<Message> for MessageWrapper<Message> {
fn from(value: Message) -> Self {
match value {
Message::Surface(s) => MessageWrapper::Surface(s),
m => MessageWrapper::Message(m),
}
}
}
impl From<SurfaceMessage> for Message {
fn from(value: SurfaceMessage) -> Self {
Message::Surface(value)
}
Surface(cosmic::surface::Action),
}
/// The [`App`] stores application-specific state.
@ -202,7 +186,7 @@ impl cosmic::Application for App {
Message::CloseError => {
self.error_status = None;
}
Message::Surface(surface_message) => {}
Message::Surface(surface) => {}
}
Task::none()

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")]