aboutsummaryrefslogtreecommitdiffstats
path: root/src/api/wayland/monitor.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/monitor.rs
parentaace58d203e403e3b128a7f1454af4f034f1c9b3 (diff)
downloadglutin-42551d20fdab796548e42e8699ba7d905417d257.tar.gz
glutin-42551d20fdab796548e42e8699ba7d905417d257.zip
api/wayland: output and fullscreen handling.
Diffstat (limited to 'src/api/wayland/monitor.rs')
-rw-r--r--src/api/wayland/monitor.rs59
1 files changed, 53 insertions, 6 deletions
diff --git a/src/api/wayland/monitor.rs b/src/api/wayland/monitor.rs
index 3a42f1f..d87d4b6 100644
--- a/src/api/wayland/monitor.rs
+++ b/src/api/wayland/monitor.rs
@@ -1,28 +1,75 @@
use std::collections::VecDeque;
+use wayland_client::{ProxyId, EventIterator};
+use wayland_client::wayland::output::WlOutput;
+
+use super::context::WAYLAND_CONTEXT;
+
#[derive(Clone)]
-pub struct MonitorId;
+pub struct MonitorId(ProxyId);
#[inline]
pub fn get_available_monitors() -> VecDeque<MonitorId> {
- unimplemented!()
+ WAYLAND_CONTEXT.as_ref().map(|ctxt|
+ ctxt.monitor_ids().into_iter().map(MonitorId).collect()
+ ).unwrap_or(VecDeque::new())
}
#[inline]
pub fn get_primary_monitor() -> MonitorId {
- unimplemented!()
+ WAYLAND_CONTEXT.as_ref().and_then(|ctxt|
+ ctxt.monitor_ids().into_iter().next().map(MonitorId)
+ ).expect("wayland: No monitor available.")
}
impl MonitorId {
pub fn get_name(&self) -> Option<String> {
- unimplemented!()
+ WAYLAND_CONTEXT.as_ref().and_then(|ctxt| ctxt.monitor_name(self.0))
}
#[inline]
pub fn get_native_identifier(&self) -> ::native_monitor::NativeMonitorId {
- unimplemented!()
+ ::native_monitor::NativeMonitorId::Unavailable
}
pub fn get_dimensions(&self) -> (u32, u32) {
- unimplemented!()
+ WAYLAND_CONTEXT.as_ref().and_then(|ctxt| ctxt.monitor_dimensions(self.0)).unwrap()
+ }
+}
+
+pub fn proxid_from_monitorid(x: &MonitorId) -> ProxyId {
+ x.0
+}
+
+pub fn init_monitors(outputs: &mut Vec<(WlOutput, u32, u32, String)>, evts: EventIterator) {
+ use wayland_client::{Event, Proxy};
+ use wayland_client::wayland::WaylandProtocolEvent;
+ use wayland_client::wayland::output::{WlOutputEvent, WlOutputMode};
+
+ for evt in evts {
+ match evt {
+ Event::Wayland(WaylandProtocolEvent::WlOutput(pid, oevt)) => match oevt {
+ WlOutputEvent::Geometry(_, _, _, _, _, maker, model, _) => {
+ for o in outputs.iter_mut() {
+ if o.0.id() == pid {
+ o.3 = format!("{} - {}", maker, model);
+ break
+ }
+ }
+ },
+ WlOutputEvent::Mode(flags, width, height, _) => {
+ if flags.contains(WlOutputMode::Current) {
+ for o in outputs.iter_mut() {
+ if o.0.id() == pid {
+ o.1 = width as u32;
+ o.2 = height as u32;
+ break
+ }
+ }
+ }
+ },
+ _ => {}
+ },
+ _ => {}
+ }
}
} \ No newline at end of file