fix: proper feature gate

This commit is contained in:
Ashley Wulber 2025-06-18 14:12:00 -04:00 • committed by Ashley Wulber
parent 720caa5dba
commit 36a5ce2002
3 changed files with 18 additions and 17 deletions

View file

@ -97,6 +97,7 @@ default = [
] ]
dbus-config = ["libcosmic/dbus-config"] dbus-config = ["libcosmic/dbus-config"]
desktop = ["libcosmic/desktop", "dep:cosmic-mime-apps", "dep:xdg"] desktop = ["libcosmic/desktop", "dep:cosmic-mime-apps", "dep:xdg"]
desktop-applet = []
gvfs = ["dep:gio", "dep:glib"] gvfs = ["dep:gio", "dep:glib"]
io-uring = ["compio/io-uring", "dep:io-uring"] io-uring = ["compio/io-uring", "dep:io-uring"]
io-uring-bindgen = ["io-uring?/bindgen"] io-uring-bindgen = ["io-uring?/bindgen"]

View file

@ -1,7 +1,7 @@
// Copyright 2023 System76 <info@system76.com> // Copyright 2023 System76 <info@system76.com>
// SPDX-License-Identifier: GPL-3.0-only // SPDX-License-Identifier: GPL-3.0-only
#[cfg(feature = "wayland")] #[cfg(all(feature = "wayland", feature = "desktop-applet"))]
use cosmic::iced::{ use cosmic::iced::{
event::wayland::{Event as WaylandEvent, OutputEvent, OverlapNotifyEvent}, event::wayland::{Event as WaylandEvent, OutputEvent, OverlapNotifyEvent},
platform_specific::runtime::wayland::layer_surface::{ platform_specific::runtime::wayland::layer_surface::{
@ -12,7 +12,7 @@ use cosmic::iced::{
}, },
Limits, Limits,
}; };
#[cfg(feature = "wayland")] #[cfg(all(feature = "wayland", feature = "desktop-applet"))]
use cosmic::iced_winit::commands::overlap_notify::overlap_notify; use cosmic::iced_winit::commands::overlap_notify::overlap_notify;
use cosmic::{ use cosmic::{
app::{self, context_drawer, Core, Task}, app::{self, context_drawer, Core, Task},
@ -63,7 +63,7 @@ use std::{
}; };
use tokio::sync::mpsc; use tokio::sync::mpsc;
use trash::TrashItem; use trash::TrashItem;
#[cfg(feature = "wayland")] #[cfg(all(feature = "wayland", feature = "desktop-applet"))]
use wayland_client::{protocol::wl_output::WlOutput, Proxy}; use wayland_client::{protocol::wl_output::WlOutput, Proxy};
use crate::{ use crate::{
@ -312,7 +312,7 @@ pub enum Message {
ExtractHere(Option<Entity>), ExtractHere(Option<Entity>),
ExtractTo(Option<Entity>), ExtractTo(Option<Entity>),
ExtractToResult(DialogResult), ExtractToResult(DialogResult),
#[cfg(all(feature = "desktop", feature = "wayland"))] #[cfg(all(feature = "wayland", feature = "desktop-applet"))]
Focused(window::Id), Focused(window::Id),
Key(Modifiers, Key, Option<SmolStr>), Key(Modifiers, Key, Option<SmolStr>),
LaunchUrl(String), LaunchUrl(String),
@ -339,7 +339,7 @@ pub enum Message {
OpenWithBrowse, OpenWithBrowse,
OpenWithDialog(Option<Entity>), OpenWithDialog(Option<Entity>),
OpenWithSelection(usize), OpenWithSelection(usize),
#[cfg(all(feature = "desktop", feature = "wayland"))] #[cfg(all(feature = "wayland", feature = "desktop-applet"))]
Overlap(OverlapNotifyEvent, window::Id), Overlap(OverlapNotifyEvent, window::Id),
Paste(Option<Entity>), Paste(Option<Entity>),
PasteContents(PathBuf, ClipboardPaste), PasteContents(PathBuf, ClipboardPaste),
@ -401,7 +401,7 @@ pub enum Message {
DndDropTab(Entity, Option<ClipboardPaste>, DndAction), DndDropTab(Entity, Option<ClipboardPaste>, DndAction),
DndDropNav(Entity, Option<ClipboardPaste>, DndAction), DndDropNav(Entity, Option<ClipboardPaste>, DndAction),
Recents, Recents,
#[cfg(feature = "wayland")] #[cfg(all(feature = "wayland", feature = "desktop-applet"))]
OutputEvent(OutputEvent, WlOutput), OutputEvent(OutputEvent, WlOutput),
Cosmic(app::Action), Cosmic(app::Action),
None, None,
@ -583,9 +583,9 @@ pub struct App {
failed_operations: BTreeMap<u64, (Operation, Controller, String)>, failed_operations: BTreeMap<u64, (Operation, Controller, String)>,
search_id: widget::Id, search_id: widget::Id,
size: Option<Size>, size: Option<Size>,
#[cfg(feature = "wayland")] #[cfg(all(feature = "wayland", feature = "desktop-applet"))]
surface_ids: HashMap<WlOutput, WindowId>, surface_ids: HashMap<WlOutput, WindowId>,
#[cfg(feature = "wayland")] #[cfg(all(feature = "wayland", feature = "desktop-applet"))]
surface_names: HashMap<WindowId, String>, surface_names: HashMap<WindowId, String>,
toasts: widget::toaster::Toasts<Message>, toasts: widget::toaster::Toasts<Message>,
watcher_opt: Option<(Debouncer<RecommendedWatcher, FileIdMap>, HashSet<PathBuf>)>, watcher_opt: Option<(Debouncer<RecommendedWatcher, FileIdMap>, HashSet<PathBuf>)>,
@ -1939,9 +1939,9 @@ impl Application for App {
failed_operations: BTreeMap::new(), failed_operations: BTreeMap::new(),
search_id: widget::Id::unique(), search_id: widget::Id::unique(),
size: None, size: None,
#[cfg(feature = "wayland")] #[cfg(all(feature = "wayland", feature = "desktop-applet"))]
surface_ids: HashMap::new(), surface_ids: HashMap::new(),
#[cfg(feature = "wayland")] #[cfg(all(feature = "wayland", feature = "desktop-applet"))]
surface_names: HashMap::new(), surface_names: HashMap::new(),
toasts: widget::toaster::Toasts::new(Message::CloseToast), toasts: widget::toaster::Toasts::new(Message::CloseToast),
watcher_opt: None, watcher_opt: None,
@ -4018,7 +4018,7 @@ impl Application for App {
Message::Recents => { Message::Recents => {
return self.open_tab(Location::Recents, false, None); return self.open_tab(Location::Recents, false, None);
} }
#[cfg(feature = "wayland")] #[cfg(all(feature = "wayland", feature = "desktop-applet"))]
Message::OutputEvent(output_event, output) => { Message::OutputEvent(output_event, output) => {
match output_event { match output_event {
OutputEvent::Created(output_info_opt) => { OutputEvent::Created(output_info_opt) => {
@ -4079,7 +4079,7 @@ impl Application for App {
exclusive_zone: 0, exclusive_zone: 0,
size_limits: Limits::NONE.min_width(1.0).min_height(1.0), size_limits: Limits::NONE.min_width(1.0).min_height(1.0),
}), }),
#[cfg(feature = "wayland")] #[cfg(all(feature = "wayland", feature = "desktop-applet"))]
overlap_notify(surface_id, true), overlap_notify(surface_id, true),
]); ]);
} }
@ -4106,7 +4106,7 @@ impl Application for App {
return Task::perform(async move { cosmic }, cosmic::action::cosmic); return Task::perform(async move { cosmic }, cosmic::action::cosmic);
} }
Message::None => {} Message::None => {}
#[cfg(all(feature = "desktop", feature = "wayland"))] #[cfg(all(feature = "wayland", feature = "desktop-applet"))]
Message::Overlap(overlap_notify_event, w_id) => match overlap_notify_event { Message::Overlap(overlap_notify_event, w_id) => match overlap_notify_event {
OverlapNotifyEvent::OverlapLayerAdd { OverlapNotifyEvent::OverlapLayerAdd {
identifier, identifier,
@ -4130,7 +4130,7 @@ impl Application for App {
self.size = Some(size); self.size = Some(size);
self.handle_overlap(); self.handle_overlap();
} }
#[cfg(all(feature = "desktop", feature = "wayland"))] #[cfg(all(feature = "wayland", feature = "desktop-applet"))]
Message::Focused(id) => { Message::Focused(id) => {
if let Some(w) = self.windows.get(&id) { if let Some(w) = self.windows.get(&id) {
match w { match w {
@ -5231,14 +5231,14 @@ impl Application for App {
Some(Message::ModifiersChanged(modifiers)) Some(Message::ModifiersChanged(modifiers))
} }
Event::Window(WindowEvent::Unfocused) => Some(Message::WindowUnfocus), Event::Window(WindowEvent::Unfocused) => Some(Message::WindowUnfocus),
#[cfg(all(feature = "desktop", feature = "wayland"))] #[cfg(all(feature = "wayland", feature = "desktop-applet"))]
Event::Window(WindowEvent::Focused) => Some(Message::Focused(window_id)), Event::Window(WindowEvent::Focused) => Some(Message::Focused(window_id)),
Event::Window(WindowEvent::CloseRequested) => Some(Message::WindowClose), Event::Window(WindowEvent::CloseRequested) => Some(Message::WindowClose),
Event::Window(WindowEvent::Opened { position: _, size }) => { Event::Window(WindowEvent::Opened { position: _, size }) => {
Some(Message::Size(size)) Some(Message::Size(size))
} }
Event::Window(WindowEvent::Resized(s)) => Some(Message::Size(s)), Event::Window(WindowEvent::Resized(s)) => Some(Message::Size(s)),
#[cfg(feature = "wayland")] #[cfg(all(feature = "wayland", feature = "desktop-applet"))]
Event::PlatformSpecific(event::PlatformSpecific::Wayland(wayland_event)) => { Event::PlatformSpecific(event::PlatformSpecific::Wayland(wayland_event)) => {
match wayland_event { match wayland_event {
WaylandEvent::Output(output_event, output) => { WaylandEvent::Output(output_event, output) => {

View file

@ -63,7 +63,7 @@ pub fn desktop() -> Result<(), Box<dyn std::error::Error>> {
settings = settings.size_limits(Limits::NONE.min_width(360.0).min_height(180.0)); settings = settings.size_limits(Limits::NONE.min_width(360.0).min_height(180.0));
settings = settings.exit_on_close(false); settings = settings.exit_on_close(false);
settings = settings.transparent(true); settings = settings.transparent(true);
#[cfg(feature = "wayland")] #[cfg(all(feature = "wayland", feature = "desktop-applet"))]
{ {
settings = settings.no_main_window(true); settings = settings.no_main_window(true);
} }