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 if let WindowMessageResponse::Request(WindowManagerRequest::DoKeyChar(_)) = self {
48 true
49 } else {
50 false
51 }
52 }
53}
54
55pub struct KeyPress {
57 pub key: char,
58}
59
60impl KeyPress {
61 pub fn is_enter(&self) -> bool {
62 self.key == '𐘂'
63 }
64
65 pub fn is_backspace(&self) -> bool {
66 self.key == '𐘁'
67 }
68
69 pub fn is_escape(&self) -> bool {
70 self.key == '𐘃'
71 }
72
73 pub fn is_up_arrow(&self) -> bool {
74 self.key == '𐙘'
75 }
76
77 pub fn is_down_arrow(&self) -> bool {
78 self.key == '𐘞'
79 }
80
81 pub fn is_left_arrow(&self) -> bool {
82 self.key == '𐙣'
83 }
84
85 pub fn is_right_arrow(&self) -> bool {
86 self.key == '𐙥'
87 }
88
89 pub fn is_arrow(&self) -> bool {
90 self.is_up_arrow() || self.is_down_arrow() || self.is_left_arrow() || self.is_right_arrow()
91 }
92
93 pub fn is_regular(&self) -> bool {
95 !self.is_enter() && !self.is_backspace() && !self.is_escape() && !self.is_arrow()
96 }
97}
98
99#[derive(Clone, Copy, PartialEq)]
100pub enum Direction {
101 Left,
102 Down,
103 Up,
104 Right,
105}
106
107#[derive(PartialEq)]
109pub enum ShortcutType {
110 StartMenu,
111 SwitchWorkspace(u8),
112 MoveWindowToWorkspace(u8),
113 FocusPrevWindow,
114 FocusNextWindow,
115 QuitWindow,
116 MoveWindow(Direction),
117 MoveWindowToEdge(Direction),
118 ChangeWindowSize(Direction),
119 CenterWindow,
120 FullscreenWindow,
121 HalfWidthWindow, ClipboardCopy,
123 ClipboardPaste(String),
125 }
127
128pub type WindowsVec = Vec<(usize, String)>;
129
130#[non_exhaustive]
131pub enum InfoType {
132 WindowsInWorkspace(WindowsVec, usize), }
136
137pub enum WindowMessage {
138 Init(Dimensions),
139 KeyPress(KeyPress),
140 CtrlKeyPress(KeyPress),
141 Shortcut(ShortcutType),
142 Info(InfoType),
143 Focus,
144 Unfocus,
145 FocusClick,
146 ChangeDimensions(Dimensions),
147 Touch(usize, usize),
149 }
151