Web: Implement MonitorHandle (#3801)
Requires getting permission from the user to get "detailed" support. Also enables users to go fullscreen on specific monitors. Exposes platform-specific orientation API. Most functionality depends on browser support, currently only Chromium.
This commit is contained in:
parent
2e97ab3d4f
commit
a0bc3e5dc8
21 changed files with 1493 additions and 120 deletions
|
|
@ -1,4 +1,7 @@
|
|||
use std::cell::Ref;
|
||||
use std::cmp::Ordering;
|
||||
use std::fmt::{self, Debug, Formatter};
|
||||
use std::hash::{Hash, Hasher};
|
||||
use std::rc::Rc;
|
||||
use std::sync::{Arc, Condvar, Mutex};
|
||||
|
||||
|
|
@ -9,6 +12,44 @@ pub struct Dispatcher<T: 'static>(Wrapper<T, Arc<Sender<Closure<T>>>, Closure<T>
|
|||
|
||||
struct Closure<T>(Box<dyn FnOnce(&T) + Send>);
|
||||
|
||||
impl<T> Clone for Dispatcher<T> {
|
||||
fn clone(&self) -> Self {
|
||||
Self(self.0.clone())
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> Debug for Dispatcher<T> {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
|
||||
f.debug_struct("Dispatcher").finish_non_exhaustive()
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> Eq for Dispatcher<T> {}
|
||||
|
||||
impl<T> Hash for Dispatcher<T> {
|
||||
fn hash<H: Hasher>(&self, state: &mut H) {
|
||||
self.0.hash(state);
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> Ord for Dispatcher<T> {
|
||||
fn cmp(&self, other: &Self) -> Ordering {
|
||||
self.0.cmp(&other.0)
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> PartialEq for Dispatcher<T> {
|
||||
fn eq(&self, other: &Self) -> bool {
|
||||
self.0.eq(&other.0)
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> PartialOrd for Dispatcher<T> {
|
||||
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
|
||||
Some(self.cmp(other))
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> Dispatcher<T> {
|
||||
pub fn new(main_thread: MainThreadMarker, value: T) -> (Self, DispatchRunner<T>) {
|
||||
let (sender, receiver) = channel::<Closure<T>>();
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
use std::cell::{Ref, RefCell};
|
||||
use std::cmp;
|
||||
use std::future::Future;
|
||||
use std::hash::{Hash, Hasher};
|
||||
use std::marker::PhantomData;
|
||||
use std::sync::Arc;
|
||||
|
||||
|
|
@ -81,3 +83,29 @@ impl<V, S: Clone + Send, E> Clone for Wrapper<V, S, E> {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<V, S: Clone + Send, E> Eq for Wrapper<V, S, E> {}
|
||||
|
||||
impl<V, S: Clone + Send, E> Hash for Wrapper<V, S, E> {
|
||||
fn hash<H: Hasher>(&self, state: &mut H) {
|
||||
Arc::as_ptr(&self.value.value).hash(state)
|
||||
}
|
||||
}
|
||||
|
||||
impl<V, S: Clone + Send, E> Ord for Wrapper<V, S, E> {
|
||||
fn cmp(&self, other: &Self) -> cmp::Ordering {
|
||||
Arc::as_ptr(&self.value.value).cmp(&Arc::as_ptr(&other.value.value))
|
||||
}
|
||||
}
|
||||
|
||||
impl<V, S: Clone + Send, E> PartialOrd for Wrapper<V, S, E> {
|
||||
fn partial_cmp(&self, other: &Self) -> Option<cmp::Ordering> {
|
||||
Some(self.cmp(other))
|
||||
}
|
||||
}
|
||||
|
||||
impl<V, S: Clone + Send, E> PartialEq for Wrapper<V, S, E> {
|
||||
fn eq(&self, other: &Self) -> bool {
|
||||
Arc::ptr_eq(&self.value.value, &other.value.value)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue