servoshell/desktop/
window_trait.rs1use std::rc::Rc;
9
10use euclid::{Length, Scale};
11use servo::servo_geometry::{DeviceIndependentIntRect, DeviceIndependentPixel};
12use servo::webrender_api::units::{DeviceIntPoint, DeviceIntSize, DevicePixel};
13use servo::{Cursor, RenderingContext, ScreenGeometry, WebView};
14
15use super::app_state::RunningAppState;
16
17pub(crate) const LINE_HEIGHT: f32 = 76.0;
19pub(crate) const LINE_WIDTH: f32 = 76.0;
20pub(crate) const PIXEL_DELTA_FACTOR: f64 = 4.0;
24
25pub(crate) const MIN_INNER_WIDTH: i32 = 20;
28pub(crate) const MIN_INNER_HEIGHT: i32 = 20;
29
30pub trait WindowPortsMethods {
31 fn id(&self) -> winit::window::WindowId;
32 fn screen_geometry(&self) -> ScreenGeometry;
33 fn device_hidpi_scale_factor(&self) -> Scale<f32, DeviceIndependentPixel, DevicePixel>;
34 fn hidpi_scale_factor(&self) -> Scale<f32, DeviceIndependentPixel, DevicePixel>;
35 fn page_height(&self) -> f32;
36 fn get_fullscreen(&self) -> bool;
37 fn handle_winit_event(&self, state: Rc<RunningAppState>, event: winit::event::WindowEvent);
38 fn set_title(&self, _title: &str) {}
39 fn request_resize(&self, webview: &WebView, outer_size: DeviceIntSize)
42 -> Option<DeviceIntSize>;
43 fn set_position(&self, _point: DeviceIntPoint) {}
44 fn set_fullscreen(&self, _state: bool) {}
45 fn set_cursor(&self, _cursor: Cursor) {}
46 #[cfg(feature = "webxr")]
47 fn new_glwindow(
48 &self,
49 event_loop: &winit::event_loop::ActiveEventLoop,
50 ) -> Rc<dyn servo::webxr::glwindow::GlWindow>;
51 fn winit_window(&self) -> Option<&winit::window::Window>;
52 fn toolbar_height(&self) -> Length<f32, DeviceIndependentPixel>;
53 fn set_toolbar_height(&self, height: Length<f32, DeviceIndependentPixel>);
54 fn rendering_context(&self) -> Rc<dyn RenderingContext>;
56 fn show_ime(
57 &self,
58 _input_type: servo::InputMethodType,
59 _text: Option<(String, i32)>,
60 _multiline: bool,
61 _position: servo::webrender_api::units::DeviceIntRect,
62 ) {
63 }
64 fn hide_ime(&self) {}
65 fn theme(&self) -> servo::Theme {
66 servo::Theme::Light
67 }
68 fn window_rect(&self) -> DeviceIndependentIntRect;
69 fn maximize(&self, webview: &WebView);
70}