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(all(feature = "wayland", target_os = "linux"))]
9use cctk::sctk::reexports::csd_frame::{WindowManagerCapabilities, WindowState};
10use cosmic_theme::ThemeMode;
11
12/// A message managed internally by COSMIC.
13#[derive(Clone, Debug)]
14pub enum Action {
15 /// Activate the application
16 Activate(String),
17 /// Application requests theme change.
18 AppThemeChange(Theme),
19 /// Requests to close the window.
20 Close,
21 /// Closes or shows the context drawer.
22 ContextDrawer(bool),
23 #[cfg(feature = "single-instance")]
24 DbusConnection(zbus::Connection),
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 /// A new window was opened.
40 Opened(iced::window::Id),
41 /// Set scaling factor
42 ScaleFactor(f32),
43 /// Show the window menu
44 ShowWindowMenu,
45 /// Tracks updates to window suggested size.
46 #[cfg(feature = "applet")]
47 SuggestedBounds(Option<iced::Size>),
48 /// Internal surface message
49 Surface(surface::Action),
50 /// Notifies that a surface was closed.
51 /// Any data relating to the surface should be cleaned up.
52 SurfaceClosed(iced::window::Id),
53 /// Notification of system theme changes.
54 SystemThemeChange(Vec<&'static str>, Theme),
55 /// Notification of system theme mode changes.
56 SystemThemeModeChange(Vec<&'static str>, ThemeMode),
57 /// Toggles visibility of the nav bar.
58 ToggleNavBar,
59 /// Toggles the condensed status of the nav bar.
60 ToggleNavBarCondensed,
61 /// Toolkit configuration update
62 ToolkitConfig(CosmicTk),
63 /// Window focus lost
64 Unfocus(iced::window::Id),
65 /// Windowing system initialized
66 WindowingSystemInitialized,
67 /// Updates the window maximized state
68 WindowMaximized(iced::window::Id, bool),
69 /// Updates the tracked window geometry.
70 WindowResize(iced::window::Id, f32, f32),
71 /// Tracks updates to window state.
72 #[cfg(all(feature = "wayland", target_os = "linux"))]
73 WindowState(iced::window::Id, WindowState),
74 /// Capabilities the window manager supports
75 #[cfg(all(feature = "wayland", target_os = "linux"))]
76 WmCapabilities(iced::window::Id, WindowManagerCapabilities),
77 #[cfg(feature = "xdg-portal")]
78 DesktopSettings(crate::theme::portal::Desktop),
79}