monitor: refactor MonitorHandle to store dyn object
This also alters `VideoMode` to be a regular object and not reference the `MonitorHandle`, since it's a static data. Given that `VideoMode` set may change during runtime keeping the reference as a some sort of validity may not be idea and propagating errors when changing video mode could be more reliable.
This commit is contained in:
parent
be1baf164c
commit
f1c5afd84e
43 changed files with 726 additions and 826 deletions
|
|
@ -1,13 +1,14 @@
|
|||
use std::collections::VecDeque;
|
||||
use std::iter;
|
||||
use std::sync::{Arc, Mutex};
|
||||
|
||||
use super::event_loop::EventLoopProxy;
|
||||
use super::{ActiveEventLoop, MonitorHandle, RedoxSocket, WindowProperties};
|
||||
use super::{ActiveEventLoop, RedoxSocket, WindowProperties};
|
||||
use crate::cursor::Cursor;
|
||||
use crate::dpi::{PhysicalInsets, PhysicalPosition, PhysicalSize, Position, Size};
|
||||
use crate::error::{NotSupportedError, RequestError};
|
||||
use crate::monitor::MonitorHandle as CoreMonitorHandle;
|
||||
use crate::window::{self, Fullscreen, ImePurpose, Window as CoreWindow, WindowId};
|
||||
use crate::monitor::{Fullscreen, MonitorHandle as CoreMonitorHandle};
|
||||
use crate::window::{self, ImePurpose, Window as CoreWindow, WindowId};
|
||||
|
||||
// These values match the values uses in the `window_new` function in orbital:
|
||||
// https://gitlab.redox-os.org/redox-os/orbital/-/blob/master/src/scheme.rs
|
||||
|
|
@ -33,7 +34,7 @@ impl Window {
|
|||
el: &ActiveEventLoop,
|
||||
attrs: window::WindowAttributes,
|
||||
) -> Result<Self, RequestError> {
|
||||
let scale = MonitorHandle.scale_factor();
|
||||
let scale = 1.;
|
||||
|
||||
let (x, y) = if let Some(pos) = attrs.position {
|
||||
pos.to_physical::<i32>(scale).into()
|
||||
|
|
@ -161,22 +162,22 @@ impl CoreWindow for Window {
|
|||
|
||||
#[inline]
|
||||
fn primary_monitor(&self) -> Option<CoreMonitorHandle> {
|
||||
Some(CoreMonitorHandle { inner: MonitorHandle })
|
||||
None
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn available_monitors(&self) -> Box<dyn Iterator<Item = CoreMonitorHandle>> {
|
||||
Box::new(vec![CoreMonitorHandle { inner: MonitorHandle }].into_iter())
|
||||
Box::new(iter::empty())
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn current_monitor(&self) -> Option<CoreMonitorHandle> {
|
||||
Some(CoreMonitorHandle { inner: MonitorHandle })
|
||||
None
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn scale_factor(&self) -> f64 {
|
||||
MonitorHandle.scale_factor()
|
||||
1.
|
||||
}
|
||||
|
||||
#[inline]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue