Move available_monitors and primary_monitor to EventLoopWindowTarget (#1616)
This commit is contained in:
parent
dd866a74a6
commit
3d5d05eac7
14 changed files with 121 additions and 110 deletions
|
|
@ -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>(
|
||||
|
|
|
|||
|
|
@ -245,8 +245,6 @@ pub struct EventLoop<T: 'static> {
|
|||
poll: Poll,
|
||||
// The wayland display
|
||||
pub display: Arc<Display>,
|
||||
// The output manager
|
||||
pub outputs: OutputMgr,
|
||||
// The cursor manager
|
||||
cursor_manager: Arc<Mutex<CursorManager>>,
|
||||
kbd_channel: Receiver<Event<'static, ()>>,
|
||||
|
|
@ -277,6 +275,8 @@ pub struct EventLoopWindowTarget<T> {
|
|||
pub display: Arc<Display>,
|
||||
// The list of seats
|
||||
pub seats: Arc<Mutex<Vec<(u32, wl_seat::WlSeat)>>>,
|
||||
// The output manager
|
||||
pub outputs: OutputMgr,
|
||||
_marker: ::std::marker::PhantomData<T>,
|
||||
}
|
||||
|
||||
|
|
@ -418,10 +418,10 @@ impl<T: 'static> EventLoop<T> {
|
|||
.unwrap();
|
||||
|
||||
let cursor_manager_clone = cursor_manager.clone();
|
||||
let outputs = env.outputs.clone();
|
||||
Ok(EventLoop {
|
||||
poll,
|
||||
display: display.clone(),
|
||||
outputs: env.outputs.clone(),
|
||||
user_sender,
|
||||
user_channel,
|
||||
kbd_channel,
|
||||
|
|
@ -435,6 +435,7 @@ impl<T: 'static> EventLoop<T> {
|
|||
cleanup_needed: Arc::new(Mutex::new(false)),
|
||||
seats,
|
||||
display,
|
||||
outputs,
|
||||
_marker: ::std::marker::PhantomData,
|
||||
}),
|
||||
_marker: ::std::marker::PhantomData,
|
||||
|
|
@ -633,14 +634,6 @@ impl<T: 'static> EventLoop<T> {
|
|||
callback(Event::LoopDestroyed, &self.window_target, &mut control_flow);
|
||||
}
|
||||
|
||||
pub fn primary_monitor(&self) -> MonitorHandle {
|
||||
primary_monitor(&self.outputs)
|
||||
}
|
||||
|
||||
pub fn available_monitors(&self) -> VecDeque<MonitorHandle> {
|
||||
available_monitors(&self.outputs)
|
||||
}
|
||||
|
||||
pub fn window_target(&self) -> &RootELW<T> {
|
||||
&self.window_target
|
||||
}
|
||||
|
|
@ -650,6 +643,14 @@ impl<T> EventLoopWindowTarget<T> {
|
|||
pub fn display(&self) -> &Display {
|
||||
&*self.display
|
||||
}
|
||||
|
||||
pub fn available_monitors(&self) -> VecDeque<MonitorHandle> {
|
||||
available_monitors(&self.outputs)
|
||||
}
|
||||
|
||||
pub fn primary_monitor(&self) -> MonitorHandle {
|
||||
primary_monitor(&self.outputs)
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -258,10 +258,6 @@ impl<T: 'static> EventLoop<T> {
|
|||
&self.target
|
||||
}
|
||||
|
||||
pub(crate) fn x_connection(&self) -> &Arc<XConnection> {
|
||||
get_xtarget(&self.target).x_connection()
|
||||
}
|
||||
|
||||
pub fn run_return<F>(&mut self, mut callback: F)
|
||||
where
|
||||
F: FnMut(Event<'_, T>, &RootELW<T>, &mut ControlFlow),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue