1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
//! Multi-window management and fractional DPI scaling for Martensite.
//!
//! This crate provides two cooperating modules:
//!
//! - [`dpi`] — the [`DpiScale`] type for converting between physical and
//! logical pixels with full fractional scale-factor support (e.g. `1.25x`,
//! `1.5x`, `1.75x`), plus runtime updates when a window moves between
//! monitors with different DPIs.
//! - [`manager`] — the [`WindowManager`] which owns every open window,
//! tracks per-window DPI scale factors, and routes [`winit`] window
//! events to the appropriate per-window state via a [`slotmap`]-backed
//! store.
//!
//! # Example
//!
//! ```no_run
//! use martensite_window::{WindowManager, dpi::DpiScale};
//! use winit::application::ApplicationHandler;
//! use winit::event::WindowEvent;
//! use winit::event_loop::{ActiveEventLoop, EventLoop};
//! use winit::window::{WindowAttributes, WindowId};
//!
//! struct App {
//! mgr: WindowManager,
//! }
//!
//! impl ApplicationHandler for App {
//! fn can_create_surfaces(&mut self, event_loop: &dyn ActiveEventLoop) {
//! let attrs = WindowAttributes::default().with_title("Martensite");
//! let _key = self.mgr.create_window(event_loop, attrs)
//! .expect("window creation failed");
//! }
//!
//! fn window_event(
//! &mut self,
//! event_loop: &dyn ActiveEventLoop,
//! id: WindowId,
//! event: WindowEvent,
//! ) {
//! use martensite_window::manager::WindowEventOutcome;
//! match self.mgr.handle_window_event(id, &event) {
//! WindowEventOutcome::CloseRequested => event_loop.exit(),
//! _ => {}
//! }
//! }
//!
//! fn about_to_wait(&mut self, _event_loop: &dyn ActiveEventLoop) {}
//! }
//!
//! let event_loop = EventLoop::new().expect("failed to create event loop");
//! let app = App { mgr: WindowManager::new() };
//! event_loop.run_app(app).expect("event loop exited with error");
//! ```
pub use RequestError;
pub use WindowEvent;
pub use ActiveEventLoop;
pub use ;
pub use DpiScale;
pub use ;