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

@ -5,7 +5,7 @@ use crate::config::CosmicTk;
use crate::theme::Theme;
use crate::widget::nav_bar;
use crate::{keyboard_nav, surface};
#[cfg(all(feature = "wayland", target_os = "linux"))]
#[cfg(wayland_platform)]
use cctk::sctk::reexports::csd_frame::{WindowManagerCapabilities, WindowState};
use cosmic_theme::ThemeMode;
@ -71,10 +71,10 @@ pub enum Action {
/// Updates the tracked window geometry.
WindowResize(iced::window::Id, f32, f32),
/// Tracks updates to window state.
#[cfg(all(feature = "wayland", target_os = "linux"))]
#[cfg(wayland_platform)]
WindowState(iced::window::Id, WindowState),
/// Capabilities the window manager supports
#[cfg(all(feature = "wayland", target_os = "linux"))]
#[cfg(wayland_platform)]
WmCapabilities(iced::window::Id, WindowManagerCapabilities),
#[cfg(feature = "xdg-portal")]
DesktopSettings(crate::theme::portal::Desktop),

View file

@ -6,20 +6,20 @@ use std::collections::HashMap;
use std::sync::Arc;
use super::{Action, Application, ApplicationExt, Subscription};
#[cfg(all(feature = "wayland", target_os = "linux"))]
#[cfg(wayland_platform)]
use crate::core::Auto;
#[cfg(all(feature = "wayland", target_os = "linux"))]
#[cfg(wayland_platform)]
use crate::surface::action::LiveSettings;
use crate::theme::{THEME, Theme, ThemeType};
use crate::{Core, Element, keyboard_nav};
#[cfg(all(feature = "wayland", target_os = "linux"))]
#[cfg(wayland_platform)]
use cctk::sctk::reexports::csd_frame::{WindowManagerCapabilities, WindowState};
use cosmic_theme::ThemeMode;
#[cfg(all(feature = "wayland", target_os = "linux"))]
#[cfg(wayland_platform)]
use enumflags2::BitFlags;
#[cfg(not(any(feature = "multi-window", feature = "wayland", target_os = "linux")))]
#[cfg(not(any(feature = "multi-window", wayland_platform)))]
use iced::Application as IcedApplication;
#[cfg(all(feature = "wayland", target_os = "linux"))]
#[cfg(wayland_platform)]
use iced::event::wayland;
use iced::{Task, theme, window};
use iced_futures::event::listen_with;
@ -158,7 +158,7 @@ where
) -> iced::Task<crate::Action<T::Message>> {
#[cfg(feature = "surface-message")]
match _surface_message {
#[cfg(all(feature = "wayland", target_os = "linux"))]
#[cfg(wayland_platform)]
crate::surface::Action::AppSubsurface(settings, live_settings, view) => {
let Some(settings) = std::sync::Arc::try_unwrap(settings)
.ok()
@ -185,7 +185,7 @@ where
});
self.get_subsurface(settings, view.map(|v| *v))
}
#[cfg(all(feature = "wayland", target_os = "linux"))]
#[cfg(wayland_platform)]
crate::surface::Action::Subsurface(settings, live_settings, view) => {
let Some(settings) = std::sync::Arc::try_unwrap(settings)
.ok()
@ -212,7 +212,7 @@ where
self.get_subsurface(settings, None)
}
}
#[cfg(all(feature = "wayland", target_os = "linux"))]
#[cfg(wayland_platform)]
crate::surface::Action::AppPopup(settings, live_settings, view) => {
let Some(settings) = std::sync::Arc::try_unwrap(settings)
.ok()
@ -249,11 +249,11 @@ where
self.get_popup(settings, *live_settings, view.map(|v| *v))
}
#[cfg(all(feature = "wayland", target_os = "linux"))]
#[cfg(wayland_platform)]
crate::surface::Action::DestroyPopup(id) => {
iced_winit::commands::popup::destroy_popup(id)
}
#[cfg(all(feature = "wayland", target_os = "linux"))]
#[cfg(wayland_platform)]
crate::surface::Action::DestroyTooltipPopup => {
#[cfg(feature = "applet")]
{
@ -264,11 +264,11 @@ where
Task::none()
}
}
#[cfg(all(feature = "wayland", target_os = "linux"))]
#[cfg(wayland_platform)]
crate::surface::Action::DestroySubsurface(id) => {
iced_winit::commands::subsurface::destroy_subsurface(id)
}
#[cfg(all(feature = "wayland", target_os = "linux"))]
#[cfg(wayland_platform)]
crate::surface::Action::DestroyWindow(id) => iced::window::close(id),
crate::surface::Action::ResponsiveMenuBar {
menu_bar,
@ -279,7 +279,7 @@ where
core.menu_bars.insert(menu_bar, (limits, size));
iced::Task::none()
}
#[cfg(all(feature = "wayland", target_os = "linux"))]
#[cfg(wayland_platform)]
crate::surface::Action::Popup(settings, live_settings, view) => {
let Some(settings) = std::sync::Arc::try_unwrap(settings)
.ok()
@ -318,7 +318,7 @@ where
self.get_popup(settings, live_settings, None)
}
}
#[cfg(all(feature = "wayland", target_os = "linux"))]
#[cfg(wayland_platform)]
crate::surface::Action::AppWindow(id, settings, live_settings, view) => {
let Some(settings) = std::sync::Arc::try_unwrap(settings).ok().and_then(|s| {
s.downcast::<Box<dyn Fn(&mut T) -> iced::window::Settings + Send + Sync>>()
@ -356,7 +356,7 @@ where
self.get_window(id, settings, *live_settings, view.map(|v| *v))
}
#[cfg(all(feature = "wayland", target_os = "linux"))]
#[cfg(wayland_platform)]
crate::surface::Action::Window(id, settings, live_settings, view) => {
let Some(settings) = std::sync::Arc::try_unwrap(settings).ok().and_then(|s| {
s.downcast::<Box<dyn Fn() -> iced::window::Settings + Send + Sync>>()
@ -413,7 +413,7 @@ where
crate::surface::Action::Task(f) => {
f().map(|sm| crate::Action::Cosmic(Action::Surface(sm)))
}
#[cfg(all(feature = "wayland", target_os = "linux"))]
#[cfg(wayland_platform)]
crate::surface::Action::AppLayerShell(settings, live_settings, view) => {
let Some(settings) = std::sync::Arc::try_unwrap(settings)
.ok()
@ -451,7 +451,7 @@ where
self.get_layer_shell(settings, *live_settings, view.map(|v| *v))
}
#[cfg(all(feature = "wayland", target_os = "linux"))]
#[cfg(wayland_platform)]
crate::surface::Action::LayerShell(settings, live_settings, view) => {
let Some(settings) = std::sync::Arc::try_unwrap(settings)
.ok()
@ -491,7 +491,7 @@ where
self.get_layer_shell(settings, live_settings, None)
}
}
#[cfg(all(feature = "wayland", target_os = "linux"))]
#[cfg(wayland_platform)]
crate::surface::Action::DestroyLayerShell(id) => {
iced_winit::commands::layer_surface::destroy_layer_surface(id)
}
@ -579,7 +579,7 @@ where
}
iced::Event::Window(window::Event::Focused) => return Some(Action::Focus(id)),
iced::Event::Window(window::Event::Unfocused) => return Some(Action::Unfocus(id)),
#[cfg(all(feature = "wayland", target_os = "linux"))]
#[cfg(wayland_platform)]
iced::Event::PlatformSpecific(iced::event::PlatformSpecific::Wayland(event)) => {
match event {
wayland::Event::Popup(wayland::PopupEvent::Done, _, id)
@ -592,7 +592,7 @@ where
) => {
return Some(Action::SuggestedBounds(b));
}
#[cfg(all(feature = "wayland", target_os = "linux"))]
#[cfg(wayland_platform)]
wayland::Event::Window(iced::event::wayland::WindowEvent::WindowState(
s,
)) => {
@ -762,7 +762,7 @@ impl<T: Application> Cosmic<T> {
fn cosmic_update(&mut self, message: Action) -> iced::Task<crate::Action<T::Message>> {
match message {
Action::WindowMaximized(id, maximized) => {
#[cfg(not(all(feature = "wayland", target_os = "linux")))]
#[cfg(not(wayland_platform))]
if self
.app
.core()
@ -792,7 +792,7 @@ impl<T: Application> Cosmic<T> {
});
}
#[cfg(all(feature = "wayland", target_os = "linux"))]
#[cfg(wayland_platform)]
Action::WindowState(id, state) => {
if self
.app
@ -824,7 +824,7 @@ impl<T: Application> Cosmic<T> {
}
}
#[cfg(all(feature = "wayland", target_os = "linux"))]
#[cfg(wayland_platform)]
Action::WmCapabilities(id, capabilities) => {
if self
.app
@ -911,7 +911,7 @@ impl<T: Application> Cosmic<T> {
guard.transparent = new_blur;
drop(guard);
#[cfg(all(feature = "wayland", target_os = "linux"))]
#[cfg(wayland_platform)]
{
let core = self.app.core();
let mut cmds = Vec::with_capacity(1 + self.surface_views.len());
@ -986,7 +986,7 @@ impl<T: Application> Cosmic<T> {
cosmic_theme.set_theme(new_theme.theme_type);
cosmic_theme.transparent = new_blur;
#[cfg(all(feature = "wayland", target_os = "linux"))]
#[cfg(wayland_platform)]
{
use iced_winit::platform_specific::commands::corner_radius::corner_radius;
@ -1119,7 +1119,7 @@ impl<T: Application> Cosmic<T> {
if let ThemeType::System { .. } = cosmic_theme.theme_type {
cosmic_theme.set_theme(new_theme.theme_type);
cosmic_theme.transparent = new_blur;
#[cfg(all(feature = "wayland", target_os = "linux"))]
#[cfg(wayland_platform)]
{
use iced_winit::platform_specific::commands::corner_radius::corner_radius;
@ -1193,7 +1193,7 @@ impl<T: Application> Cosmic<T> {
// Unminimize window before requesting to activate it.
let mut task = iced_runtime::window::minimize(id, false);
#[cfg(all(feature = "wayland", target_os = "linux"))]
#[cfg(wayland_platform)]
{
task = task.chain(
iced_winit::platform_specific::commands::activation::activate(
@ -1204,7 +1204,7 @@ impl<T: Application> Cosmic<T> {
);
}
#[cfg(not(all(feature = "wayland", target_os = "linux")))]
#[cfg(not(wayland_platform))]
{
task = task.chain(iced_runtime::window::gain_focus(id));
}
@ -1301,7 +1301,7 @@ impl<T: Application> Cosmic<T> {
// Only apply update if the theme is set to load a system theme
if let ThemeType::System { theme: _, .. } = cosmic_theme.theme_type {
let mut cmds = Vec::with_capacity(1);
#[cfg(all(feature = "wayland", target_os = "linux"))]
#[cfg(wayland_platform)]
{
let blur = if cosmic_theme.transparent {
iced::window::enable_blur
@ -1378,12 +1378,7 @@ impl<T: Application> Cosmic<T> {
}
Action::Focus(f) => {
#[cfg(all(
feature = "wayland",
feature = "multi-window",
feature = "surface-message",
target_os = "linux"
))]
#[cfg(wayland_platform)]
if let Some((
parent,
SurfaceIdWrapper::Subsurface(_) | SurfaceIdWrapper::Popup(_),
@ -1428,7 +1423,7 @@ impl<T: Application> Cosmic<T> {
core.applet.suggested_bounds = b;
}
Action::Opened(id) => {
#[cfg(all(feature = "wayland", target_os = "linux"))]
#[cfg(wayland_platform)]
{
use iced_winit::platform_specific::commands::corner_radius::corner_radius;
@ -1511,7 +1506,7 @@ impl<T: Application> Cosmic<T> {
}
return iced_runtime::window::run_with_handle(id, init_windowing_system);
}
#[cfg(all(feature = "wayland", target_os = "linux"))]
#[cfg(wayland_platform)]
Action::BlurEnabled => {
// TODO do this after blur event confirms support instead of for all wayland windows
self.blur_enabled = true;
@ -1591,7 +1586,7 @@ impl<App: Application> Cosmic<App> {
if matches!(id_wrapper, SurfaceIdWrapper::Window(_)) {
window::enable_blur(id)
} else {
#[cfg(all(feature = "wayland", feature = "winit", target_os = "linux"))]
#[cfg(wayland_platform)]
{
iced_winit::commands::blur::blur(
id,
@ -1602,7 +1597,7 @@ impl<App: Application> Cosmic<App> {
)
.discard()
}
#[cfg(not(all(feature = "wayland", feature = "winit", target_os = "linux")))]
#[cfg(not(wayland_platform))]
{
iced::window::enable_blur(id)
}
@ -1610,11 +1605,11 @@ impl<App: Application> Cosmic<App> {
} else if matches!(id_wrapper, SurfaceIdWrapper::Window(_)) {
window::disable_blur(id)
} else {
#[cfg(all(feature = "wayland", feature = "winit", target_os = "linux"))]
#[cfg(wayland_platform)]
{
iced_winit::commands::blur::blur(id, None).discard()
}
#[cfg(not(all(feature = "wayland", feature = "winit", target_os = "linux")))]
#[cfg(not(wayland_platform))]
{
iced::window::disable_blur(id)
}
@ -1624,7 +1619,7 @@ impl<App: Application> Cosmic<App> {
cmds.push(if matches!(id_wrapper, SurfaceIdWrapper::Window(_)) {
window::enable_blur(id)
} else {
#[cfg(all(feature = "wayland", feature = "winit", target_os = "linux"))]
#[cfg(wayland_platform)]
{
iced_winit::commands::blur::blur(
id,
@ -1635,13 +1630,13 @@ impl<App: Application> Cosmic<App> {
)
.discard()
}
#[cfg(not(all(feature = "wayland", feature = "winit", target_os = "linux")))]
#[cfg(not(wayland_platform))]
{
iced::window::enable_blur(id)
}
});
}
#[cfg(all(feature = "wayland", feature = "winit", target_os = "linux"))]
#[cfg(wayland_platform)]
if let Some(corners) = live_settings.corners {
cmds.push(
iced_winit::commands::corner_radius::corner_radius(id, Some(corners)).discard(),
@ -1657,7 +1652,7 @@ impl<App: Application> Cosmic<App> {
);
}
}
#[cfg(all(feature = "wayland", feature = "winit", target_os = "linux"))]
#[cfg(wayland_platform)]
if let (SurfaceIdWrapper::LayerSurface(id), Some(padding)) =
(id_wrapper, live_settings.padding)
{
@ -1668,7 +1663,7 @@ impl<App: Application> Cosmic<App> {
Task::batch(cmds)
}
#[cfg(all(feature = "wayland", target_os = "linux"))]
#[cfg(wayland_platform)]
/// Create a subsurface
pub fn get_subsurface(
&mut self,
@ -1700,7 +1695,7 @@ impl<App: Application> Cosmic<App> {
Task::batch([live_settings_task, get_subsurface(settings)])
}
#[cfg(all(feature = "wayland", target_os = "linux"))]
#[cfg(wayland_platform)]
/// Create a subsurface
pub fn get_popup(
&mut self,
@ -1728,7 +1723,7 @@ impl<App: Application> Cosmic<App> {
live_settings_task.chain(get_popup(settings)).discard()
}
#[cfg(all(feature = "wayland", target_os = "linux"))]
#[cfg(wayland_platform)]
/// Create a window surface
pub fn get_window(
&mut self,
@ -1765,7 +1760,7 @@ impl<App: Application> Cosmic<App> {
])
}
#[cfg(all(feature = "wayland", target_os = "linux"))]
#[cfg(wayland_platform)]
pub fn get_layer_shell(
&mut self,
settings: iced_runtime::platform_specific::wayland::layer_surface::SctkLayerSurfaceSettings,
@ -1794,7 +1789,7 @@ impl<App: Application> Cosmic<App> {
}
}
#[cfg(all(feature = "wayland", target_os = "linux"))]
#[cfg(wayland_platform)]
fn corners(
surface_type: SurfaceIdWrapper,
rounded: bool,

View file

@ -390,13 +390,7 @@ where
crate::widget::nav_bar(nav_model, |id| crate::Action::Cosmic(Action::NavBar(id)))
.on_context(|id| crate::Action::Cosmic(Action::NavBarContext(id)))
.context_menu(self.nav_context_menu());
#[cfg(all(
feature = "multi-window",
feature = "wayland",
target_os = "linux",
feature = "winit",
feature = "surface-message"
))]
#[cfg(wayland_platform)]
{
nav = nav
.window_id_maybe(self.core().main_window_id())

View file

@ -16,7 +16,7 @@ pub struct Settings {
pub(crate) antialiasing: bool,
/// Autosize the window to fit its contents
#[cfg(all(feature = "wayland", target_os = "linux"))]
#[cfg(wayland_platform)]
pub(crate) autosize: bool,
/// Set the application to not create a main window
@ -80,7 +80,7 @@ impl Default for Settings {
fn default() -> Self {
Self {
antialiasing: true,
#[cfg(all(feature = "wayland", target_os = "linux"))]
#[cfg(wayland_platform)]
autosize: false,
no_main_window: false,
client_decorations: true,