aboutsummaryrefslogtreecommitdiffstats
path: root/src/api/x11
diff options
context:
space:
mode:
authorIvo Wetzel <ivo.wetzel@googlemail.com>2016-03-25 19:52:57 +0100
committerIvo Wetzel <ivo.wetzel@googlemail.com>2016-03-25 19:52:57 +0100
commit1b7a3cd31febc38b4d0d39d06f99639469a5823d (patch)
tree3bb43ff7ebc4b4237a06dac69576987721c3a52d /src/api/x11
parent7a5e47c446801c40e9048668feb54f3d76dc2442 (diff)
downloadglutin-1b7a3cd31febc38b4d0d39d06f99639469a5823d.tar.gz
glutin-1b7a3cd31febc38b4d0d39d06f99639469a5823d.zip
Correctly apply initial size constraints for x11 windows.
Diffstat (limited to 'src/api/x11')
-rw-r--r--src/api/x11/window.rs20
1 files changed, 18 insertions, 2 deletions
diff --git a/src/api/x11/window.rs b/src/api/x11/window.rs
index aeb7efe..b84dc09 100644
--- a/src/api/x11/window.rs
+++ b/src/api/x11/window.rs
@@ -3,7 +3,7 @@ use CreationError;
use CreationError::OsError;
use libc;
use std::borrow::Borrow;
-use std::{mem, ptr};
+use std::{mem, ptr, cmp};
use std::cell::Cell;
use std::sync::atomic::AtomicBool;
use std::collections::VecDeque;
@@ -310,7 +310,23 @@ impl Window {
pf_reqs: &PixelFormatRequirements, opengl: &GlAttributes<&Window>)
-> Result<Window, CreationError>
{
- let dimensions = window_attrs.max_dimensions.unwrap_or(window_attrs.dimensions.unwrap_or((800, 600)));
+ 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 {
+ dimensions.0 = cmp::min(dimensions.0, max.0);
+ dimensions.1 = cmp::min(dimensions.1, max.1);
+ }
+
+ if let Some(min) = window_attrs.min_dimensions {
+ dimensions.0 = cmp::max(dimensions.0, min.0);
+ dimensions.1 = cmp::max(dimensions.1, min.1);
+ }
+ dimensions
+
+ };
let screen_id = match window_attrs.monitor {
Some(PlatformMonitorId::X(MonitorId(_, monitor))) => monitor as i32,