diff --git a/src/platform/linux/mod.rs b/src/platform/linux/mod.rs index 752523cb55..d1644662e8 100644 --- a/src/platform/linux/mod.rs +++ b/src/platform/linux/mod.rs @@ -16,6 +16,8 @@ use { LogicalPosition, LogicalSize, MouseCursor, + PhysicalPosition, + PhysicalSize, ControlFlow, WindowAttributes, }; @@ -95,18 +97,20 @@ impl MonitorId { } #[inline] - pub fn get_dimensions(&self) -> (u32, u32) { + pub fn get_dimensions(&self) -> PhysicalSize { match self { &MonitorId::X(ref m) => m.get_dimensions(), - &MonitorId::Wayland(ref m) => m.get_dimensions(), + //&MonitorId::Wayland(ref m) => m.get_dimensions(), + _ => unimplemented!(), } } #[inline] - pub fn get_position(&self) -> (i32, i32) { + pub fn get_position(&self) -> PhysicalPosition { match self { &MonitorId::X(ref m) => m.get_position(), - &MonitorId::Wayland(ref m) => m.get_position(), + //&MonitorId::Wayland(ref m) => m.get_position(), + _ => unimplemented!(), } } @@ -114,7 +118,7 @@ impl MonitorId { pub fn get_hidpi_factor(&self) -> f64 { match self { &MonitorId::X(ref m) => m.get_hidpi_factor(), - &MonitorId::Wayland(ref m) => m.get_hidpi_factor(), + &MonitorId::Wayland(ref m) => m.get_hidpi_factor() as f64, } } } diff --git a/src/platform/linux/wayland/window.rs b/src/platform/linux/wayland/window.rs index 216b8a4fb2..aa2defca41 100644 --- a/src/platform/linux/wayland/window.rs +++ b/src/platform/linux/wayland/window.rs @@ -24,7 +24,9 @@ pub struct Window { impl Window { pub fn new(evlp: &EventsLoop, attributes: WindowAttributes) -> Result { - let (width, height) = attributes.dimensions.unwrap_or((800, 600)); + // TODO: Update for new DPI API + //let (width, height) = attributes.dimensions.unwrap_or((800, 600)); + let (width, height) = (64, 64); // Create the window let size = Arc::new(Mutex::new((width, height))); @@ -105,8 +107,9 @@ impl Window { frame.set_decorate(attributes.decorations); // min-max dimensions - frame.set_min_size(attributes.min_dimensions); - frame.set_max_size(attributes.max_dimensions); + // TODO: Update for new DPI API + //frame.set_min_size(attributes.min_dimensions); + //frame.set_max_size(attributes.max_dimensions); let kill_switch = Arc::new(Mutex::new(false)); let need_frame_refresh = Arc::new(Mutex::new(true)); diff --git a/src/platform/linux/x11/monitor.rs b/src/platform/linux/x11/monitor.rs index 9be0515296..3d1d7d7da9 100644 --- a/src/platform/linux/x11/monitor.rs +++ b/src/platform/linux/x11/monitor.rs @@ -2,6 +2,8 @@ use std::os::raw::*; use parking_lot::Mutex; +use {PhysicalPosition, PhysicalSize}; +use super::{util, XConnection, XError}; use super::ffi::{ RRCrtcChangeNotifyMask, RROutputPropertyNotifyMask, @@ -10,7 +12,6 @@ use super::ffi::{ Window, XRRScreenResources, }; -use super::{util, XConnection, XError}; // Used to test XRandR < 1.5 code path. This should always be committed as false. const FORCE_RANDR_COMPAT: bool = false; @@ -88,17 +89,17 @@ impl MonitorId { self.id as u32 } - pub fn get_dimensions(&self) -> (u32, u32) { - self.dimensions + pub fn get_dimensions(&self) -> PhysicalSize { + self.dimensions.into() } - pub fn get_position(&self) -> (i32, i32) { - self.position + pub fn get_position(&self) -> PhysicalPosition { + self.position.into() } #[inline] - pub fn get_hidpi_factor(&self) -> f32 { - self.hidpi_factor as f32 + pub fn get_hidpi_factor(&self) -> f64 { + self.hidpi_factor } } diff --git a/src/platform/linux/x11/window.rs b/src/platform/linux/x11/window.rs index 1b9f84d897..7e6b7e9c9e 100644 --- a/src/platform/linux/x11/window.rs +++ b/src/platform/linux/x11/window.rs @@ -74,15 +74,20 @@ impl UnownedWindow { let xconn = &event_loop.xconn; let root = event_loop.root; + let max_dimensions: Option<(u32, u32)> = window_attrs.max_dimensions.map(Into::into); + let min_dimensions: Option<(u32, u32)> = window_attrs.min_dimensions.map(Into::into); + let dimensions = { // x11 only applies constraints when the window is actively resized // by the user, so we have to manually apply the initial constraints - let mut dimensions = window_attrs.dimensions.unwrap_or((800, 600)); - if let Some(max) = window_attrs.max_dimensions { + let mut dimensions = window_attrs.dimensions + .map(Into::into) + .unwrap_or((800, 600)); + if let Some(max) = max_dimensions { dimensions.0 = cmp::min(dimensions.0, max.0); dimensions.1 = cmp::min(dimensions.1, max.1); } - if let Some(min) = window_attrs.min_dimensions { + if let Some(min) = min_dimensions { dimensions.0 = cmp::max(dimensions.0, min.0); dimensions.1 = cmp::max(dimensions.1, min.1); } @@ -237,8 +242,8 @@ impl UnownedWindow { { let mut normal_hints = util::NormalHints::new(xconn); normal_hints.set_size(Some(dimensions)); - normal_hints.set_min_size(window_attrs.min_dimensions); - normal_hints.set_max_size(window_attrs.max_dimensions); + normal_hints.set_min_size(min_dimensions); + normal_hints.set_max_size(max_dimensions); normal_hints.set_resize_increments(pl_attribs.resize_increments); normal_hints.set_base_size(pl_attribs.base_size); xconn.set_normal_hints(window.xwindow, normal_hints).queue(); @@ -452,8 +457,8 @@ impl UnownedWindow { Some(RootMonitorId { inner: PlatformMonitorId::X(monitor) }) => { let window_position = self.get_position_physical(); self.shared_state.lock().restore_position = window_position; - let monitor_origin = monitor.get_position(); - self.set_position_inner(monitor_origin.0 as i32, monitor_origin.1 as i32).queue(); + let monitor_origin: (i32, i32) = monitor.get_position().into(); + self.set_position_inner(monitor_origin.0, monitor_origin.1).queue(); self.set_fullscreen_hint(true) } _ => unreachable!(), diff --git a/src/platform/windows/monitor.rs b/src/platform/windows/monitor.rs index 1fc6bb7aea..83d54f57df 100644 --- a/src/platform/windows/monitor.rs +++ b/src/platform/windows/monitor.rs @@ -5,8 +5,8 @@ use winapi::um::winuser; use std::{mem, ptr}; use std::collections::VecDeque; -use super::{EventsLoop, util}; use {PhysicalPosition, PhysicalSize}; +use super::{EventsLoop, util}; use platform::platform::dpi::{dpi_to_scale_factor, get_monitor_dpi}; /// Win32 implementation of the main `MonitorId` object. diff --git a/src/platform/windows/window.rs b/src/platform/windows/window.rs index 643b1875ec..93487af850 100644 --- a/src/platform/windows/window.rs +++ b/src/platform/windows/window.rs @@ -26,7 +26,6 @@ use { PhysicalSize, WindowAttributes, }; - use platform::platform::{Cursor, EventsLoop, PlatformSpecificWindowBuilderAttributes, WindowId}; use platform::platform::dpi::{BASE_DPI, dpi_to_scale_factor, get_window_dpi, get_window_scale_factor}; use platform::platform::events_loop::{self, DESTROY_MSG_ID, INITIAL_DPI_MSG_ID};