hyprshell_core_lib/transfer/
structs.rs

1use crate::{ClientId, WorkspaceId};
2use serde::{Deserialize, Serialize};
3
4#[derive(Debug, Serialize, Deserialize)]
5pub enum TransferType {
6    /// send from the keybind to open the overview
7    OpenOverview,
8    /// send from the keybind to open the switch
9    OpenSwitch(OpenSwitch),
10    /// send from the keybinds like arrow keys or tab on overview
11    SwitchOverview(SwitchOverviewConfig),
12    /// send from the keybinds like arrow keys or tab on switch
13    SwitchSwitch(SwitchSwitchConfig),
14    CloseOverview(CloseOverviewConfig),
15    CloseSwitch,
16    /// send from the gui itself when typing the launcher
17    Type(String),
18    /// send from pressing ESC or repressing openOverview
19    Exit,
20    /// send from the app itself when new monitor / config changes detected
21    Restart,
22}
23#[derive(Debug, Serialize, Deserialize)]
24pub struct OpenSwitch {
25    pub reverse: bool,
26}
27
28#[derive(Debug, Serialize, Deserialize)]
29pub struct SwitchOverviewConfig {
30    pub direction: Direction,
31    pub workspace: bool,
32}
33
34#[derive(Debug, Serialize, Deserialize)]
35pub struct SwitchSwitchConfig {
36    pub reverse: bool,
37}
38
39#[derive(Debug, Serialize, Deserialize)]
40pub enum CloseOverviewConfig {
41    LauncherClick(Identifier),
42    LauncherPress(char),
43    Windows(WindowsOverride),
44    None,
45}
46
47#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash, Serialize, Deserialize)]
48pub enum PluginNames {
49    Applications,
50    Shell,
51    Terminal,
52    WebSearch,
53    Calc,
54    Path,
55    Actions,
56}
57
58#[derive(Debug, Clone, Eq, PartialEq, Hash, Serialize, Deserialize)]
59pub struct Identifier {
60    pub plugin: PluginNames,
61    // identifies the box in the launcher results
62    pub data: Option<Box<str>>,
63    // additional data used to get suboption in submenu (only available when launched through click)
64    pub data_additional: Option<Box<str>>,
65}
66
67impl Identifier {
68    #[must_use]
69    pub const fn plugin(plugin: PluginNames) -> Self {
70        Self {
71            plugin,
72            data: None,
73            data_additional: None,
74        }
75    }
76
77    #[must_use]
78    pub const fn data(plugin: PluginNames, data: Box<str>) -> Self {
79        Self {
80            plugin,
81            data: Some(data),
82            data_additional: None,
83        }
84    }
85
86    #[must_use]
87    pub const fn data_additional(
88        plugin: PluginNames,
89        data: Box<str>,
90        data_additional: Box<str>,
91    ) -> Self {
92        Self {
93            plugin,
94            data: Some(data),
95            data_additional: Some(data_additional),
96        }
97    }
98}
99
100#[derive(Debug, Serialize, Deserialize)]
101pub enum WindowsOverride {
102    ClientId(ClientId),
103    WorkspaceID(WorkspaceId),
104}
105
106#[derive(Debug, Serialize, Deserialize, Eq, PartialEq)]
107pub enum Direction {
108    Right,
109    Left,
110    Up,
111    Down,
112}