1#![allow(unused)]
2
3use crate::{
4 Action, AnyWindowHandle, BackgroundExecutor, ClipboardItem, CursorStyle, DisplayId,
5 ForegroundExecutor, Keymap, LinuxDispatcher, LinuxTextSystem, Menu, PathPromptOptions,
6 Platform, PlatformDisplay, PlatformInput, PlatformTextSystem, PlatformWindow, Result,
7 SemanticVersion, Task, WindowOptions,
8};
9
10use futures::channel::oneshot;
11use parking_lot::Mutex;
12
13use std::{
14 path::{Path, PathBuf},
15 rc::Rc,
16 sync::Arc,
17 time::Duration,
18};
19use time::UtcOffset;
20
21pub(crate) struct LinuxPlatform(Mutex<LinuxPlatformState>);
22
23pub(crate) struct LinuxPlatformState {
24 background_executor: BackgroundExecutor,
25 foreground_executor: ForegroundExecutor,
26 text_system: Arc<LinuxTextSystem>,
27}
28
29impl Default for LinuxPlatform {
30 fn default() -> Self {
31 Self::new()
32 }
33}
34
35impl LinuxPlatform {
36 pub(crate) fn new() -> Self {
37 let dispatcher = Arc::new(LinuxDispatcher::new());
38 Self(Mutex::new(LinuxPlatformState {
39 background_executor: BackgroundExecutor::new(dispatcher.clone()),
40 foreground_executor: ForegroundExecutor::new(dispatcher),
41 text_system: Arc::new(LinuxTextSystem::new()),
42 }))
43 }
44}
45
46impl Platform for LinuxPlatform {
47 fn background_executor(&self) -> BackgroundExecutor {
48 self.0.lock().background_executor.clone()
49 }
50
51 fn foreground_executor(&self) -> crate::ForegroundExecutor {
52 self.0.lock().foreground_executor.clone()
53 }
54
55 fn text_system(&self) -> Arc<dyn PlatformTextSystem> {
56 self.0.lock().text_system.clone()
57 }
58
59 fn run(&self, on_finish_launching: Box<dyn FnOnce()>) {
60 unimplemented!()
61 }
62
63 fn quit(&self) {
64 unimplemented!()
65 }
66
67 fn restart(&self) {
68 unimplemented!()
69 }
70
71 fn activate(&self, ignoring_other_apps: bool) {
72 unimplemented!()
73 }
74
75 fn hide(&self) {
76 unimplemented!()
77 }
78
79 fn hide_other_apps(&self) {
80 unimplemented!()
81 }
82
83 fn unhide_other_apps(&self) {
84 unimplemented!()
85 }
86
87 fn displays(&self) -> Vec<Rc<dyn PlatformDisplay>> {
88 unimplemented!()
89 }
90
91 fn display(&self, id: DisplayId) -> Option<Rc<dyn PlatformDisplay>> {
92 unimplemented!()
93 }
94
95 fn active_window(&self) -> Option<AnyWindowHandle> {
96 unimplemented!()
97 }
98
99 fn open_window(
100 &self,
101 handle: AnyWindowHandle,
102 options: WindowOptions,
103 ) -> Box<dyn PlatformWindow> {
104 unimplemented!()
105 }
106
107 fn set_display_link_output_callback(
108 &self,
109 display_id: DisplayId,
110 callback: Box<dyn FnMut() + Send>,
111 ) {
112 unimplemented!()
113 }
114
115 fn start_display_link(&self, display_id: DisplayId) {
116 unimplemented!()
117 }
118
119 fn stop_display_link(&self, display_id: DisplayId) {
120 unimplemented!()
121 }
122
123 fn open_url(&self, url: &str) {
124 unimplemented!()
125 }
126
127 fn on_open_urls(&self, callback: Box<dyn FnMut(Vec<String>)>) {
128 unimplemented!()
129 }
130
131 fn prompt_for_paths(
132 &self,
133 options: PathPromptOptions,
134 ) -> oneshot::Receiver<Option<Vec<PathBuf>>> {
135 unimplemented!()
136 }
137
138 fn prompt_for_new_path(&self, directory: &Path) -> oneshot::Receiver<Option<PathBuf>> {
139 unimplemented!()
140 }
141
142 fn reveal_path(&self, path: &Path) {
143 unimplemented!()
144 }
145
146 fn on_become_active(&self, callback: Box<dyn FnMut()>) {
147 unimplemented!()
148 }
149
150 fn on_resign_active(&self, callback: Box<dyn FnMut()>) {
151 unimplemented!()
152 }
153
154 fn on_quit(&self, callback: Box<dyn FnMut()>) {
155 unimplemented!()
156 }
157
158 fn on_reopen(&self, callback: Box<dyn FnMut()>) {
159 unimplemented!()
160 }
161
162 fn on_event(&self, callback: Box<dyn FnMut(PlatformInput) -> bool>) {
163 unimplemented!()
164 }
165
166 fn on_app_menu_action(&self, callback: Box<dyn FnMut(&dyn Action)>) {
167 unimplemented!()
168 }
169
170 fn on_will_open_app_menu(&self, callback: Box<dyn FnMut()>) {
171 unimplemented!()
172 }
173
174 fn on_validate_app_menu_command(&self, callback: Box<dyn FnMut(&dyn Action) -> bool>) {
175 unimplemented!()
176 }
177
178 fn os_name(&self) -> &'static str {
179 "Linux"
180 }
181
182 fn double_click_interval(&self) -> Duration {
183 unimplemented!()
184 }
185
186 fn os_version(&self) -> Result<SemanticVersion> {
187 unimplemented!()
188 }
189
190 fn app_version(&self) -> Result<SemanticVersion> {
191 unimplemented!()
192 }
193
194 fn app_path(&self) -> Result<PathBuf> {
195 unimplemented!()
196 }
197
198 fn set_menus(&self, menus: Vec<Menu>, keymap: &Keymap) {
199 unimplemented!()
200 }
201
202 fn local_timezone(&self) -> UtcOffset {
203 unimplemented!()
204 }
205
206 fn path_for_auxiliary_executable(&self, name: &str) -> Result<PathBuf> {
207 unimplemented!()
208 }
209
210 fn set_cursor_style(&self, style: CursorStyle) {
211 unimplemented!()
212 }
213
214 fn should_auto_hide_scrollbars(&self) -> bool {
215 unimplemented!()
216 }
217
218 fn write_to_clipboard(&self, item: ClipboardItem) {
219 unimplemented!()
220 }
221
222 fn read_from_clipboard(&self) -> Option<ClipboardItem> {
223 unimplemented!()
224 }
225
226 fn write_credentials(&self, url: &str, username: &str, password: &[u8]) -> Task<Result<()>> {
227 unimplemented!()
228 }
229
230 fn read_credentials(&self, url: &str) -> Task<Result<Option<(String, Vec<u8>)>>> {
231 unimplemented!()
232 }
233
234 fn delete_credentials(&self, url: &str) -> Task<Result<()>> {
235 unimplemented!()
236 }
237}
238
239#[cfg(test)]
240mod tests {
241 use crate::ClipboardItem;
242
243 use super::*;
244
245 fn build_platform() -> LinuxPlatform {
246 let platform = LinuxPlatform::new();
247 platform
248 }
249}