window.rs

  1use crate::{
  2    px, AnyWindowHandle, AtlasKey, AtlasTextureId, AtlasTile, BladeAtlas, Bounds, KeyDownEvent,
  3    Keystroke, Pixels, PlatformAtlas, PlatformDisplay, PlatformInput, PlatformInputHandler,
  4    PlatformWindow, Point, Size, TileId, WindowAppearance, WindowBounds, WindowOptions,
  5};
  6use collections::HashMap;
  7use parking_lot::Mutex;
  8use std::{
  9    rc::{Rc, Weak},
 10    sync::{self, Arc},
 11};
 12
 13pub(crate) struct LinuxWindowState {
 14    display: Rc<dyn crate::PlatformDisplay>,
 15    sprite_atlas: Arc<BladeAtlas>,
 16}
 17
 18#[derive(Clone)]
 19pub(crate) struct LinuxWindow(pub(crate) Arc<Mutex<LinuxWindowState>>);
 20
 21impl LinuxWindow {
 22    pub fn new(
 23        options: WindowOptions,
 24        handle: AnyWindowHandle,
 25        display: Rc<dyn PlatformDisplay>,
 26        gpu: &Arc<blade::Context>,
 27    ) -> Self {
 28        Self(Arc::new(Mutex::new(LinuxWindowState {
 29            display,
 30            sprite_atlas: Arc::new(BladeAtlas::new(gpu)),
 31        })))
 32    }
 33}
 34
 35impl PlatformWindow for LinuxWindow {
 36    fn bounds(&self) -> WindowBounds {
 37        unimplemented!()
 38    }
 39
 40    fn content_size(&self) -> Size<Pixels> {
 41        unimplemented!()
 42    }
 43
 44    fn scale_factor(&self) -> f32 {
 45        1.0
 46    }
 47
 48    fn titlebar_height(&self) -> Pixels {
 49        unimplemented!()
 50    }
 51
 52    fn appearance(&self) -> WindowAppearance {
 53        unimplemented!()
 54    }
 55
 56    fn display(&self) -> Rc<dyn crate::PlatformDisplay> {
 57        Rc::clone(&self.0.lock().display)
 58    }
 59
 60    fn mouse_position(&self) -> Point<Pixels> {
 61        Point::default()
 62    }
 63
 64    fn modifiers(&self) -> crate::Modifiers {
 65        crate::Modifiers::default()
 66    }
 67
 68    fn as_any_mut(&mut self) -> &mut dyn std::any::Any {
 69        self
 70    }
 71
 72    fn set_input_handler(&mut self, input_handler: PlatformInputHandler) {}
 73
 74    fn take_input_handler(&mut self) -> Option<PlatformInputHandler> {
 75        None
 76    }
 77
 78    fn prompt(
 79        &self,
 80        _level: crate::PromptLevel,
 81        _msg: &str,
 82        _detail: Option<&str>,
 83        _answers: &[&str],
 84    ) -> futures::channel::oneshot::Receiver<usize> {
 85        unimplemented!()
 86    }
 87
 88    fn activate(&self) {}
 89
 90    fn set_title(&mut self, title: &str) {}
 91
 92    fn set_edited(&mut self, edited: bool) {}
 93
 94    fn show_character_palette(&self) {
 95        unimplemented!()
 96    }
 97
 98    fn minimize(&self) {
 99        unimplemented!()
100    }
101
102    fn zoom(&self) {
103        unimplemented!()
104    }
105
106    fn toggle_full_screen(&self) {
107        unimplemented!()
108    }
109
110    fn on_request_frame(&self, _callback: Box<dyn FnMut()>) {}
111
112    fn on_input(&self, callback: Box<dyn FnMut(crate::PlatformInput) -> bool>) {}
113
114    fn on_active_status_change(&self, callback: Box<dyn FnMut(bool)>) {}
115
116    fn on_resize(&self, callback: Box<dyn FnMut(Size<Pixels>, f32)>) {}
117
118    fn on_fullscreen(&self, _callback: Box<dyn FnMut(bool)>) {}
119
120    fn on_moved(&self, callback: Box<dyn FnMut()>) {}
121
122    fn on_should_close(&self, callback: Box<dyn FnMut() -> bool>) {}
123
124    fn on_close(&self, _callback: Box<dyn FnOnce()>) {
125        unimplemented!()
126    }
127
128    fn on_appearance_changed(&self, _callback: Box<dyn FnMut()>) {
129        unimplemented!()
130    }
131
132    fn is_topmost_for_position(&self, _position: crate::Point<Pixels>) -> bool {
133        unimplemented!()
134    }
135
136    fn invalidate(&self) {}
137
138    fn draw(&self, _scene: &crate::Scene) {}
139
140    fn sprite_atlas(&self) -> sync::Arc<dyn crate::PlatformAtlas> {
141        self.0.lock().sprite_atlas.clone()
142    }
143}