aboutsummaryrefslogtreecommitdiffstats
path: root/src/api/wayland/context.rs
diff options
context:
space:
mode:
authorVictor Berger <victor.berger@m4x.org>2015-12-22 14:35:15 +0100
committerVictor Berger <victor.berger@m4x.org>2015-12-22 14:36:41 +0100
commit42551d20fdab796548e42e8699ba7d905417d257 (patch)
tree28669de2ccbd7cf7b66d114f953f1f236c020933 /src/api/wayland/context.rs
parentaace58d203e403e3b128a7f1454af4f034f1c9b3 (diff)
downloadglutin-42551d20fdab796548e42e8699ba7d905417d257.tar.gz
glutin-42551d20fdab796548e42e8699ba7d905417d257.zip
api/wayland: output and fullscreen handling.
Diffstat (limited to 'src/api/wayland/context.rs')
-rw-r--r--src/api/wayland/context.rs63
1 files changed, 58 insertions, 5 deletions
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<EventIterator>,
- monitors: Vec<WlOutput>,
+ monitors: Vec<(WlOutput, u32, u32, String)>,
queues: Mutex<HashMap<ProxyId, Arc<Mutex<VecDeque<GlutinEvent>>>>>,
known_surfaces: Mutex<HashSet<ProxyId>>,
focuses: Mutex<WaylandFocuses>
@@ -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::<WlOutput>(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<ProxyId>) -> Option<WlShellSurface> {
+ 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<ProxyId> {
+ self.monitors.iter().map(|o| o.0.id()).collect()
+ }
+
+ pub fn monitor_name(&self, pid: ProxyId) -> Option<String> {
+ 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
+ }
}