From a3921ea88a3783a3001d9d4c85d4c8f96fadeafa Mon Sep 17 00:00:00 2001 From: Victor Berger Date: Sat, 9 May 2015 10:12:31 +0200 Subject: Continue wayland API: WindowProxy, MonitorID, and some other little stuff. --- Cargo.toml | 6 +++--- src/api/wayland/mod.rs | 43 +++++++++++++++++++++++++++++++------------ 2 files changed, 34 insertions(+), 15 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 31d0b0b..32e8d90 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -50,15 +50,15 @@ kernel32-sys = "0.1" [target.i686-unknown-linux-gnu.dependencies] osmesa-sys = "0.0.5" -wayland-client = "0.1.3" +wayland-client = "0.1.4" x11-dl = "=1.0.1" [target.x86_64-unknown-linux-gnu.dependencies] osmesa-sys = "0.0.5" -wayland-client = "0.1.3" +wayland-client = "0.1.4" x11-dl = "=1.0.1" [target.arm-unknown-linux-gnueabihf.dependencies] osmesa-sys = "0.0.5" -wayland-client = "0.1.3" +wayland-client = "0.1.4" x11-dl = "=1.0.1" diff --git a/src/api/wayland/mod.rs b/src/api/wayland/mod.rs index 31e9243..f70d62e 100644 --- a/src/api/wayland/mod.rs +++ b/src/api/wayland/mod.rs @@ -4,7 +4,7 @@ use self::wayland::egl::{EGLSurface, is_egl_available}; use self::wayland::core::{Display, Registry, Compositor, Shell, ShellSurface, Seat, Pointer, default_display, WSurface, SurfaceId, - Surface}; + Surface, Output}; use libc; use api::dlopen; @@ -32,7 +32,8 @@ struct WaylandContext { pub seat: Seat, pub pointer: Option>, windows_event_queues: Arc>>>>>, - current_pointer_surface: Arc>> + current_pointer_surface: Arc>>, + outputs: Vec> } impl WaylandContext { @@ -56,6 +57,7 @@ impl WaylandContext { Some(s) => s, None => return None, }; + let outputs = registry.get_outputs().into_iter().map(Arc::new).collect::>(); // let the other globals get their events display.sync_roundtrip(); @@ -125,7 +127,8 @@ impl WaylandContext { seat: seat, pointer: pointer, windows_event_queues: windows_event_queues, - current_pointer_surface: current_pointer_surface + current_pointer_surface: current_pointer_surface, + outputs: outputs }) } @@ -159,22 +162,35 @@ pub struct WindowProxy; impl WindowProxy { pub fn wakeup_event_loop(&self) { - unimplemented!() + if let Some(ref ctxt) = *WAYLAND_CONTEXT { + ctxt.display.sync(); + } } } -pub struct MonitorID; +pub struct MonitorID { + output: Arc +} pub fn get_available_monitors() -> VecDeque { - VecDeque::new() + WAYLAND_CONTEXT.as_ref().unwrap().outputs.iter().map(|o| MonitorID::new(o.clone())).collect() } pub fn get_primary_monitor() -> MonitorID { - MonitorID + match WAYLAND_CONTEXT.as_ref().unwrap().outputs.iter().next() { + Some(o) => MonitorID::new(o.clone()), + None => panic!("No monitor is available.") + } } impl MonitorID { + fn new(output: Arc) -> MonitorID { + MonitorID { + output: output + } + } + pub fn get_name(&self) -> Option { - unimplemented!(); + Some(format!("{} - {}", self.output.manufacturer(), self.output.model())) } pub fn get_native_identifier(&self) -> ::native_monitor::NativeMonitorId { @@ -182,7 +198,8 @@ impl MonitorID { } pub fn get_dimensions(&self) -> (u32, u32) { - unimplemented!(); + let (w, h) = self.output.dimensions(); + (w as u32, h as u32) } } @@ -282,10 +299,12 @@ impl Window { } pub fn get_position(&self) -> Option<(i32, i32)> { - unimplemented!() + // not available with wayland + None } - pub fn set_position(&self, x: i32, y: i32) { + pub fn set_position(&self, _x: i32, _y: i32) { + // not available with wayland } pub fn get_inner_size(&self) -> Option<(u32, u32)> { @@ -301,7 +320,7 @@ impl Window { } pub fn create_window_proxy(&self) -> WindowProxy { - unimplemented!() + WindowProxy } pub fn poll_events(&self) -> PollEventsIterator { -- cgit v1.2.3