cosmic/
action.rs

1// Copyright 2023 System76 <info@system76.com>
2// SPDX-License-Identifier: MPL-2.0
3
4#[cfg(feature = "winit")]
5use crate::app;
6#[cfg(feature = "single-instance")]
7use crate::dbus_activation;
8
9pub const fn app<M>(message: M) -> Action<M> {
10    Action::App(message)
11}
12#[cfg(feature = "winit")]
13pub const fn cosmic<M>(message: app::Action) -> Action<M> {
14    Action::Cosmic(message)
15}
16
17pub const fn none<M>() -> Action<M> {
18    Action::None
19}
20
21#[derive(Clone, Debug)]
22#[must_use]
23pub enum Action<M> {
24    /// Messages from the application, for the application.
25    App(M),
26    #[cfg(feature = "winit")]
27    /// Internal messages to be handled by libcosmic.
28    Cosmic(app::Action),
29    #[cfg(feature = "single-instance")]
30    /// Dbus activation messages
31    DbusActivation(dbus_activation::Message),
32    /// Do nothing
33    None,
34}
35
36impl<M> From<M> for Action<M> {
37    fn from(value: M) -> Self {
38        Self::App(value)
39    }
40}