Move available_monitors and primary_monitor to EventLoopWindowTarget (#1616)

This commit is contained in:
Xavier L'Heureux 2020-07-04 15:46:41 -04:00 committed by GitHub
parent dd866a74a6
commit 3d5d05eac7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 121 additions and 110 deletions

View file

@ -602,35 +602,6 @@ impl<T: 'static> EventLoop<T> {
Ok(EventLoop::X(x11::EventLoop::new(xconn)))
}
#[inline]
pub fn available_monitors(&self) -> VecDeque<MonitorHandle> {
match *self {
#[cfg(feature = "wayland")]
EventLoop::Wayland(ref evlp) => evlp
.available_monitors()
.into_iter()
.map(MonitorHandle::Wayland)
.collect(),
#[cfg(feature = "x11")]
EventLoop::X(ref evlp) => evlp
.x_connection()
.available_monitors()
.into_iter()
.map(MonitorHandle::X)
.collect(),
}
}
#[inline]
pub fn primary_monitor(&self) -> MonitorHandle {
match *self {
#[cfg(feature = "wayland")]
EventLoop::Wayland(ref evlp) => MonitorHandle::Wayland(evlp.primary_monitor()),
#[cfg(feature = "x11")]
EventLoop::X(ref evlp) => MonitorHandle::X(evlp.x_connection().primary_monitor()),
}
}
pub fn create_proxy(&self) -> EventLoopProxy<T> {
x11_or_wayland!(match self; EventLoop(evlp) => evlp.create_proxy(); as EventLoopProxy)
}
@ -677,6 +648,39 @@ impl<T> EventLoopWindowTarget<T> {
_ => false,
}
}
#[inline]
pub fn available_monitors(&self) -> VecDeque<MonitorHandle> {
match *self {
#[cfg(feature = "wayland")]
EventLoopWindowTarget::Wayland(ref evlp) => evlp
.available_monitors()
.into_iter()
.map(MonitorHandle::Wayland)
.collect(),
#[cfg(feature = "x11")]
EventLoopWindowTarget::X(ref evlp) => evlp
.x_connection()
.available_monitors()
.into_iter()
.map(MonitorHandle::X)
.collect(),
}
}
#[inline]
pub fn primary_monitor(&self) -> MonitorHandle {
match *self {
#[cfg(feature = "wayland")]
EventLoopWindowTarget::Wayland(ref evlp) => {
MonitorHandle::Wayland(evlp.primary_monitor())
}
#[cfg(feature = "x11")]
EventLoopWindowTarget::X(ref evlp) => {
MonitorHandle::X(evlp.x_connection().primary_monitor())
}
}
}
}
fn sticky_exit_callback<T, F>(