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 /// Requests to drag the window.
26 Drag,
27 /// Window focus changed
28 Focus(iced::window::Id),
29 /// Keyboard shortcuts managed by libcosmic.
30 KeyboardNav(keyboard_nav::Action),
31 /// Requests to maximize the window.
32 Maximize,
33 /// Requests to minimize the window.
34 Minimize,
35 /// Activates a navigation element from the nav bar.
36 NavBar(nav_bar::Id),
37 /// Activates a context menu for an item from the nav bar.
38 NavBarContext(nav_bar::Id),
39 /// Set scaling factor
40 ScaleFactor(f32),
41 /// Show the window menu
42 ShowWindowMenu,
43 /// Tracks updates to window suggested size.
44 #[cfg(feature = "applet")]
45 SuggestedBounds(Option<iced::Size>),
46 /// Internal surface message
47 Surface(surface::Action),
48 /// Notifies that a surface was closed.
49 /// Any data relating to the surface should be cleaned up.
50 SurfaceClosed(iced::window::Id),
51 /// Notification of system theme changes.
52 SystemThemeChange(Vec<&'static str>, Theme),
53 /// Notification of system theme mode changes.
54 SystemThemeModeChange(Vec<&'static str>, ThemeMode),
55 /// Toggles visibility of the nav bar.
56 ToggleNavBar,
57 /// Toggles the condensed status of the nav bar.
58 ToggleNavBarCondensed,
59 /// Toolkit configuration update
60 ToolkitConfig(CosmicTk),
61 /// Window focus lost
62 Unfocus(iced::window::Id),
63 /// Updates the window maximized state
64 WindowMaximized(iced::window::Id, bool),
65 /// Updates the tracked window geometry.
66 WindowResize(iced::window::Id, f32, f32),
67 /// Tracks updates to window state.
68 #[cfg(feature = "wayland")]
69 WindowState(iced::window::Id, WindowState),
70 /// Capabilities the window manager supports
71 #[cfg(feature = "wayland")]
72 WmCapabilities(iced::window::Id, WindowManagerCapabilities),
73 #[cfg(feature = "xdg-portal")]
74 DesktopSettings(crate::theme::portal::Desktop),
75}