cosmic/app/
action.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
// Copyright 2023 System76 <info@system76.com>
// SPDX-License-Identifier: MPL-2.0

use crate::surface;
use crate::theme::Theme;
use crate::widget::nav_bar;
use crate::{config::CosmicTk, keyboard_nav};
#[cfg(feature = "wayland")]
use cctk::sctk::reexports::csd_frame::{WindowManagerCapabilities, WindowState};
use cosmic_theme::ThemeMode;
#[cfg(not(any(feature = "multi-window", feature = "wayland")))]
use iced::Application as IcedApplication;

/// A message managed internally by COSMIC.
#[derive(Clone, Debug)]
pub enum Action {
    /// Activate the application
    Activate(String),
    /// Application requests theme change.
    AppThemeChange(Theme),
    /// Requests to close the window.
    Close,
    /// Closes or shows the context drawer.
    ContextDrawer(bool),
    /// Requests to drag the window.
    Drag,
    /// Window focus changed
    Focus(iced::window::Id),
    /// Keyboard shortcuts managed by libcosmic.
    KeyboardNav(keyboard_nav::Action),
    /// Requests to maximize the window.
    Maximize,
    /// Requests to minimize the window.
    Minimize,
    /// Activates a navigation element from the nav bar.
    NavBar(nav_bar::Id),
    /// Activates a context menu for an item from the nav bar.
    NavBarContext(nav_bar::Id),
    /// Set scaling factor
    ScaleFactor(f32),
    /// Show the window menu
    ShowWindowMenu,
    /// Tracks updates to window suggested size.
    #[cfg(feature = "applet")]
    SuggestedBounds(Option<iced::Size>),
    /// Internal surface message
    Surface(surface::Action),
    /// Notifies that a surface was closed.
    /// Any data relating to the surface should be cleaned up.
    SurfaceClosed(iced::window::Id),
    /// Notification of system theme changes.
    SystemThemeChange(Vec<&'static str>, Theme),
    /// Notification of system theme mode changes.
    SystemThemeModeChange(Vec<&'static str>, ThemeMode),
    /// Toggles visibility of the nav bar.
    ToggleNavBar,
    /// Toggles the condensed status of the nav bar.
    ToggleNavBarCondensed,
    /// Toolkit configuration update
    ToolkitConfig(CosmicTk),
    /// Window focus lost
    Unfocus(iced::window::Id),
    /// Updates the window maximized state
    WindowMaximized(iced::window::Id, bool),
    /// Updates the tracked window geometry.
    WindowResize(iced::window::Id, f32, f32),
    /// Tracks updates to window state.
    #[cfg(feature = "wayland")]
    WindowState(iced::window::Id, WindowState),
    /// Capabilities the window manager supports
    #[cfg(feature = "wayland")]
    WmCapabilities(iced::window::Id, WindowManagerCapabilities),
    #[cfg(feature = "xdg-portal")]
    DesktopSettings(crate::theme::portal::Desktop),
}