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:
Kirill Chibisov 2024-09-21 20:27:12 +03:00
parent be1baf164c
commit f1c5afd84e
43 changed files with 726 additions and 826 deletions

View file

@ -2,7 +2,7 @@ use std::cell::Cell;
use std::collections::VecDeque;
use std::sync::{mpsc, Arc, Mutex};
use std::time::Instant;
use std::{mem, slice};
use std::{iter, mem, slice};
use bitflags::bitflags;
use orbclient::{
@ -11,9 +11,7 @@ use orbclient::{
};
use smol_str::SmolStr;
use super::{
MonitorHandle, PlatformSpecificEventLoopAttributes, RedoxSocket, TimeSocket, WindowProperties,
};
use super::{PlatformSpecificEventLoopAttributes, RedoxSocket, TimeSocket, WindowProperties};
use crate::application::ApplicationHandler;
use crate::error::{EventLoopError, NotSupportedError, RequestError};
use crate::event::{self, Ime, Modifiers, StartCause};
@ -711,9 +709,7 @@ impl RootActiveEventLoop for ActiveEventLoop {
}
fn available_monitors(&self) -> Box<dyn Iterator<Item = crate::monitor::MonitorHandle>> {
let mut v = VecDeque::with_capacity(1);
v.push_back(crate::monitor::MonitorHandle { inner: MonitorHandle });
Box::new(v.into_iter())
Box::new(iter::empty())
}
fn system_theme(&self) -> Option<Theme> {
@ -721,7 +717,7 @@ impl RootActiveEventLoop for ActiveEventLoop {
}
fn primary_monitor(&self) -> Option<crate::monitor::MonitorHandle> {
Some(crate::monitor::MonitorHandle { inner: MonitorHandle })
None
}
fn listen_device_events(&self, _allowed: DeviceEvents) {}