From 42551d20fdab796548e42e8699ba7d905417d257 Mon Sep 17 00:00:00 2001 From: Victor Berger Date: Tue, 22 Dec 2015 14:35:15 +0100 Subject: api/wayland: output and fullscreen handling. --- src/api/wayland/context.rs | 63 ++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 58 insertions(+), 5 deletions(-) (limited to 'src/api/wayland/context.rs') diff --git a/src/api/wayland/context.rs b/src/api/wayland/context.rs index 285f50c..f303b54 100644 --- a/src/api/wayland/context.rs +++ b/src/api/wayland/context.rs @@ -10,7 +10,7 @@ use wayland_client::wayland::get_display; use wayland_client::wayland::compositor::{WlCompositor, WlSurface}; use wayland_client::wayland::output::WlOutput; use wayland_client::wayland::seat::{WlSeat, WlPointer}; -use wayland_client::wayland::shell::WlShell; +use wayland_client::wayland::shell::{WlShell, WlShellSurface}; use wayland_client::wayland::shm::WlShm; use wayland_client::wayland::subcompositor::WlSubcompositor; @@ -42,7 +42,7 @@ pub struct WaylandFocuses { pub struct WaylandContext { inner: InnerEnv, iterator: Mutex, - monitors: Vec, + monitors: Vec<(WlOutput, u32, u32, String)>, queues: Mutex>>>>, known_surfaces: Mutex>, focuses: Mutex @@ -57,13 +57,19 @@ impl WaylandContext { let (mut inner_env, iterator) = InnerEnv::init(display); - let monitors = inner_env.globals.iter() + let mut outputs_events = EventIterator::new(); + + let mut monitors = inner_env.globals.iter() .flat_map(|&(id, _, _)| inner_env.rebind_id::(id)) - .map(|(monitor, _)| monitor) - .collect(); + .map(|(mut monitor, _)| { + monitor.set_evt_iterator(&outputs_events); + (monitor, 0, 0, String::new()) + }).collect(); inner_env.display.sync_roundtrip().unwrap(); + super::monitor::init_monitors(&mut monitors, outputs_events); + Some(WaylandContext { inner: inner_env, iterator: Mutex::new(iterator), @@ -114,6 +120,31 @@ impl WaylandContext { } } + pub fn plain_from(&self, surface: &WlSurface, fullscreen: Option) -> Option { + use wayland_client::wayland::shell::WlShellSurfaceFullscreenMethod; + + let inner = &self.inner; + if let Some((ref shell, _)) = inner.shell { + let shell_surface = shell.get_shell_surface(surface); + if let Some(monitor_id) = fullscreen { + for m in &self.monitors { + if m.0.id() == monitor_id { + shell_surface.set_fullscreen( + WlShellSurfaceFullscreenMethod::Default, + 0, + Some(&m.0) + ); + return Some(shell_surface) + } + } + } + shell_surface.set_toplevel(); + Some(shell_surface) + } else { + None + } + } + pub fn display_ptr(&self) -> *const c_void { self.inner.display.ptr() as *const _ } @@ -155,4 +186,26 @@ impl WaylandContext { }; return guard.read_events().map(|i| Some(i)); } + + pub fn monitor_ids(&self) -> Vec { + self.monitors.iter().map(|o| o.0.id()).collect() + } + + pub fn monitor_name(&self, pid: ProxyId) -> Option { + for o in &self.monitors { + if o.0.id() == pid { + return Some(o.3.clone()) + } + } + None + } + + pub fn monitor_dimensions(&self, pid: ProxyId) -> Option<(u32, u32)> { + for o in &self.monitors { + if o.0.id() == pid { + return Some((o.1, o.2)) + } + } + None + } } -- cgit v1.2.3