1use std::boxed::Box;
2use std::vec::Vec;
3
4use crate::framebuffer_types::Dimensions;
5use crate::window_manager_types::{ WindowLike, KeyChar };
6
7pub enum WindowManagerMessage {
9 KeyChar(KeyChar),
10 Touch(usize, usize),
11 }
13
14pub type WindowBox = Box<dyn WindowLike>;
16
17#[derive(Debug, PartialEq)]
27pub enum WindowManagerRequest {
28 OpenWindow(String),
29 ClipboardCopy(String),
31 CloseStartMenu,
32 Unlock,
33 Lock,
34 DoKeyChar(KeyChar),
35 }
37
38#[derive(PartialEq, Debug)]
39pub enum WindowMessageResponse {
40 Request(WindowManagerRequest),
41 JustRedraw,
42 DoNothing,
43}
44
45impl WindowMessageResponse {
46 pub fn is_key_char_request(&self) -> bool {
47 matches!(self, WindowMessageResponse::Request(WindowManagerRequest::DoKeyChar(_)))
48 }
49}
50
51pub struct KeyPress {
53 pub key: char,
54}
55
56impl KeyPress {
57 pub fn is_enter(&self) -> bool {
58 self.key == '𐘂'
59 }
60
61 pub fn is_backspace(&self) -> bool {
62 self.key == '𐘁'
63 }
64
65 pub fn is_escape(&self) -> bool {
66 self.key == '𐘃'
67 }
68
69 pub fn is_up_arrow(&self) -> bool {
70 self.key == '𐙘'
71 }
72
73 pub fn is_down_arrow(&self) -> bool {
74 self.key == '𐘞'
75 }
76
77 pub fn is_left_arrow(&self) -> bool {
78 self.key == '𐙣'
79 }
80
81 pub fn is_right_arrow(&self) -> bool {
82 self.key == '𐙥'
83 }
84
85 pub fn is_arrow(&self) -> bool {
86 self.is_up_arrow() || self.is_down_arrow() || self.is_left_arrow() || self.is_right_arrow()
87 }
88
89 pub fn is_regular(&self) -> bool {
91 !self.is_enter() && !self.is_backspace() && !self.is_escape() && !self.is_arrow()
92 }
93}
94
95#[derive(Clone, Copy, PartialEq)]
96pub enum Direction {
97 Left,
98 Down,
99 Up,
100 Right,
101}
102
103#[derive(PartialEq)]
105pub enum ShortcutType {
106 StartMenu,
107 SwitchWorkspace(u8),
108 MoveWindowToWorkspace(u8),
109 FocusPrevWindow,
110 FocusNextWindow,
111 QuitWindow,
112 MoveWindow(Direction),
113 MoveWindowToEdge(Direction),
114 ChangeWindowSize(Direction),
115 CenterWindow,
116 FullscreenWindow,
117 HalfWidthWindow, ClipboardCopy,
119 ClipboardPaste(String),
121 }
123
124pub type WindowsVec = Vec<(usize, String)>;
125
126#[non_exhaustive]
127pub enum InfoType {
128 WindowsInWorkspace(WindowsVec, usize), }
132
133pub enum WindowMessage {
134 Init(Dimensions),
135 KeyPress(KeyPress),
136 CtrlKeyPress(KeyPress),
137 Shortcut(ShortcutType),
138 Info(InfoType),
139 Focus,
140 Unfocus,
141 FocusClick,
142 ChangeDimensions(Dimensions),
143 Touch(usize, usize),
145 }
147