diff --git a/CHANGELOG.md b/CHANGELOG.md index 62d62ca2..b6ccb22d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ `get_inner_size`. - **Breaking:** `EventsLoop` is `!Send` and `!Sync` because of platform-dependant constraints, but `Window`, `WindowId`, `DeviceId` and `MonitorId` guaranteed to be `Send`. +- `MonitorId::get_position` now returns `(i32, i32)` instead of `(u32, u32)`. # Version 0.8.3 (2017-10-11) diff --git a/src/platform/android/mod.rs b/src/platform/android/mod.rs index ca10a94e..a3caa2f4 100644 --- a/src/platform/android/mod.rs +++ b/src/platform/android/mod.rs @@ -160,7 +160,7 @@ impl MonitorId { } #[inline] - pub fn get_position(&self) -> (u32, u32) { + pub fn get_position(&self) -> (i32, i32) { // Android assumes single screen (0, 0) } diff --git a/src/platform/emscripten/mod.rs b/src/platform/emscripten/mod.rs index a3389cf0..d72c4e44 100644 --- a/src/platform/emscripten/mod.rs +++ b/src/platform/emscripten/mod.rs @@ -34,7 +34,7 @@ impl MonitorId { } #[inline] - pub fn get_position(&self) -> (u32, u32) { + pub fn get_position(&self) -> (i32, i32) { unimplemented!() } diff --git a/src/platform/ios/mod.rs b/src/platform/ios/mod.rs index 51480977..2542b673 100644 --- a/src/platform/ios/mod.rs +++ b/src/platform/ios/mod.rs @@ -141,7 +141,7 @@ impl MonitorId { } #[inline] - pub fn get_position(&self) -> (u32, u32) { + pub fn get_position(&self) -> (i32, i32) { // iOS assumes single screen (0, 0) } diff --git a/src/platform/linux/mod.rs b/src/platform/linux/mod.rs index 6079466a..33f7c3cc 100644 --- a/src/platform/linux/mod.rs +++ b/src/platform/linux/mod.rs @@ -88,7 +88,7 @@ impl MonitorId { } #[inline] - pub fn get_position(&self) -> (u32, u32) { + pub fn get_position(&self) -> (i32, i32) { match self { &MonitorId::X(ref m) => m.get_position(), &MonitorId::Wayland(ref m) => m.get_position(), @@ -97,7 +97,10 @@ impl MonitorId { #[inline] pub fn get_hidpi_factor(&self) -> f32 { - 1.0 + match self { + &MonitorId::X(ref m) => m.get_hidpi_factor(), + &MonitorId::Wayland(ref m) => m.get_hidpi_factor(), + } } } diff --git a/src/platform/linux/wayland/context.rs b/src/platform/linux/wayland/context.rs index 8c592de8..57018e80 100644 --- a/src/platform/linux/wayland/context.rs +++ b/src/platform/linux/wayland/context.rs @@ -37,7 +37,7 @@ struct OutputInfo { id: u32, scale: f32, pix_size: (u32, u32), - pix_pos: (u32, u32), + pix_pos: (i32, i32), name: String } @@ -162,7 +162,7 @@ impl wl_output::Handler for WaylandEnv { { for m in self.monitors.iter_mut().filter(|m| m.output.equals(proxy)) { m.name = format!("{} ({})", model, make); - m.pix_pos = (x as u32, y as u32); + m.pix_pos = (x, y); break; } } @@ -397,7 +397,7 @@ impl MonitorId { (0,0) } - pub fn get_position(&self) -> (u32, u32) { + pub fn get_position(&self) -> (i32, i32) { let mut guard = self.ctxt.evq.lock().unwrap(); let state = guard.state(); let env = state.get_handler::(self.ctxt.env_id); diff --git a/src/platform/linux/wayland/window.rs b/src/platform/linux/wayland/window.rs index 8a7eb113..0e633565 100644 --- a/src/platform/linux/wayland/window.rs +++ b/src/platform/linux/wayland/window.rs @@ -204,6 +204,8 @@ impl Window { let mut find = default; for monitor in monitors { let (mx, my) = monitor.get_position(); + let mx = mx as u32; + let my = my as u32; let (mw, mh) = monitor.get_dimensions(); let (mxo, myo) = (mx+mw-1, my+mh-1); let (ox, oy) = (cmp::max(wx, mx), cmp::max(wy, my)); diff --git a/src/platform/linux/x11/monitor.rs b/src/platform/linux/x11/monitor.rs index cd05b153..76293c78 100644 --- a/src/platform/linux/x11/monitor.rs +++ b/src/platform/linux/x11/monitor.rs @@ -12,7 +12,7 @@ pub struct MonitorId { /// The size of the monitor dimensions: (u32, u32), /// The position of the monitor in the X screen - position: (u32, u32), + position: (i32, i32), /// If the monitor is the primary one primary: bool, } @@ -40,7 +40,7 @@ pub fn get_available_monitors(x: &Arc) -> Vec { id: i as u32, name, dimensions: (monitor.width as u32, monitor.height as u32), - position: (monitor.x as u32, monitor.y as u32), + position: (monitor.x as i32, monitor.y as i32), primary: (monitor.primary != 0), }); } @@ -61,7 +61,7 @@ pub fn get_available_monitors(x: &Arc) -> Vec { id: crtcid as u32, name, dimensions: ((*crtc).width as u32, (*crtc).height as u32), - position: ((*crtc).x as u32, (*crtc).y as u32), + position: ((*crtc).x as i32, (*crtc).y as i32), primary: true, }); } @@ -98,7 +98,7 @@ impl MonitorId { self.dimensions } - pub fn get_position(&self) -> (u32, u32) { + pub fn get_position(&self) -> (i32, i32) { self.position } diff --git a/src/platform/linux/x11/window.rs b/src/platform/linux/x11/window.rs index be8bcdd8..2c1403c1 100644 --- a/src/platform/linux/x11/window.rs +++ b/src/platform/linux/x11/window.rs @@ -332,6 +332,8 @@ impl Window2 { let mut find = default; for monitor in monitors { let (mx, my) = monitor.get_position(); + let mx = mx as u32; + let my = my as u32; let (mw, mh) = monitor.get_dimensions(); let (mxo, myo) = (mx+mw-1, my+mh-1); let (ox, oy) = (cmp::max(wx, mx), cmp::max(wy, my)); diff --git a/src/platform/macos/monitor.rs b/src/platform/macos/monitor.rs index 85bca223..8f3b1ed1 100644 --- a/src/platform/macos/monitor.rs +++ b/src/platform/macos/monitor.rs @@ -50,7 +50,7 @@ impl MonitorId { } #[inline] - pub fn get_position(&self) -> (u32, u32) { + pub fn get_position(&self) -> (i32, i32) { unimplemented!() } diff --git a/src/platform/windows/monitor.rs b/src/platform/windows/monitor.rs index 7653fd78..90c8527e 100644 --- a/src/platform/windows/monitor.rs +++ b/src/platform/windows/monitor.rs @@ -27,8 +27,8 @@ pub struct MonitorId { /// The position of the monitor in pixels on the desktop. /// - /// A window that is positionned at these coordinates will overlap the monitor. - position: (u32, u32), + /// A window that is positioned at these coordinates will overlap the monitor. + position: (i32, i32), /// The current resolution in pixels on the monitor. dimensions: (u32, u32), @@ -111,7 +111,7 @@ impl EventsLoop { } let point: &winapi::POINTL = mem::transmute(&dev.union1); - let position = (point.x as u32, point.y as u32); + let position = (point.x as i32, point.y as i32); let dimensions = (dev.dmPelsWidth as u32, dev.dmPelsHeight as u32); @@ -176,9 +176,9 @@ impl MonitorId { &self.adapter_name } - /// A window that is positionned at these coordinates will overlap the monitor. + /// A window that is positioned at these coordinates will overlap the monitor. #[inline] - pub fn get_position(&self) -> (u32, u32) { + pub fn get_position(&self) -> (i32, i32) { self.position } diff --git a/src/window.rs b/src/window.rs index 55ed9e15..d4e11aed 100644 --- a/src/window.rs +++ b/src/window.rs @@ -370,7 +370,7 @@ impl MonitorId { /// Returns the top-left corner position of the monitor relative to the larger full /// screen area. #[inline] - pub fn get_position(&self) -> (u32, u32) { + pub fn get_position(&self) -> (i32, i32) { self.inner.get_position() }