cosmic/app/
action.rs

1// Copyright 2023 System76 <info@system76.com>
2// SPDX-License-Identifier: MPL-2.0
3
4use crate::surface;
5use crate::theme::Theme;
6use crate::widget::nav_bar;
7use crate::{config::CosmicTk, keyboard_nav};
8#[cfg(feature = "wayland")]
9use cctk::sctk::reexports::csd_frame::{WindowManagerCapabilities, WindowState};
10use cosmic_theme::ThemeMode;
11#[cfg(not(any(feature = "multi-window", feature = "wayland")))]
12use iced::Application as IcedApplication;
13
14/// A message managed internally by COSMIC.
15#[derive(Clone, Debug)]
16pub enum Action {
17    /// Activate the application
18    Activate(String),
19    /// Application requests theme change.
20    AppThemeChange(Theme),
21    /// Requests to close the window.
22    Close,
23    /// Closes or shows the context drawer.
24    ContextDrawer(bool),
25    #[cfg(feature = "single-instance")]
26    DbusConnection(zbus::Connection),
27    /// Requests to drag the window.
28    Drag,
29    /// Window focus changed
30    Focus(iced::window::Id),
31    /// Keyboard shortcuts managed by libcosmic.
32    KeyboardNav(keyboard_nav::Action),
33    /// Requests to maximize the window.
34    Maximize,
35    /// Requests to minimize the window.
36    Minimize,
37    /// Activates a navigation element from the nav bar.
38    NavBar(nav_bar::Id),
39    /// Activates a context menu for an item from the nav bar.
40    NavBarContext(nav_bar::Id),
41    /// A new window was opened.
42    Opened(iced::window::Id),
43    /// Set scaling factor
44    ScaleFactor(f32),
45    /// Show the window menu
46    ShowWindowMenu,
47    /// Tracks updates to window suggested size.
48    #[cfg(feature = "applet")]
49    SuggestedBounds(Option<iced::Size>),
50    /// Internal surface message
51    Surface(surface::Action),
52    /// Notifies that a surface was closed.
53    /// Any data relating to the surface should be cleaned up.
54    SurfaceClosed(iced::window::Id),
55    /// Notification of system theme changes.
56    SystemThemeChange(Vec<&'static str>, Theme),
57    /// Notification of system theme mode changes.
58    SystemThemeModeChange(Vec<&'static str>, ThemeMode),
59    /// Toggles visibility of the nav bar.
60    ToggleNavBar,
61    /// Toggles the condensed status of the nav bar.
62    ToggleNavBarCondensed,
63    /// Toolkit configuration update
64    ToolkitConfig(CosmicTk),
65    /// Window focus lost
66    Unfocus(iced::window::Id),
67    /// Windowing system initialized
68    WindowingSystemInitialized,
69    /// Updates the window maximized state
70    WindowMaximized(iced::window::Id, bool),
71    /// Updates the tracked window geometry.
72    WindowResize(iced::window::Id, f32, f32),
73    /// Tracks updates to window state.
74    #[cfg(feature = "wayland")]
75    WindowState(iced::window::Id, WindowState),
76    /// Capabilities the window manager supports
77    #[cfg(feature = "wayland")]
78    WmCapabilities(iced::window::Id, WindowManagerCapabilities),
79    #[cfg(feature = "xdg-portal")]
80    DesktopSettings(crate::theme::portal::Desktop),
81}