Compare commits

..

3 Commits

Author SHA1 Message Date
Bastien Orivel
c1ef1acfc0 Update parking_lot and bump version (#593) 2018-07-07 17:21:53 -04:00
Francesca Frangipane
040d3f5d8b Remove incorrect unreachable usage when guessing DPI factor (#592) 2018-07-05 11:52:25 -04:00
Joshua Minter
ec393e4a90 Disable maximize button on non-resizable windows (#588)
* Disabled maximize button

When creating a non resizable window in win32.
Also added example code to test.

* Added to changelog

* Added to documentation

* Removed non_resizable test

* Other suggested PR changes

* Documentation changes

* CHANGELOG nits
2018-07-03 20:15:19 -04:00
4 changed files with 16 additions and 9 deletions

View File

@@ -1,5 +1,10 @@
# Unreleased
# Version 0.16.2 (2018-07-07)
- On Windows, non-resizable windows now have the maximization button disabled. This is consistent with behavior on macOS and popular X11 WMs.
- Corrected incorrect `unreachable!` usage when guessing the DPI factor with no detected monitors.
# Version 0.16.1 (2018-07-02)
- Added logging through `log`. Logging will become more extensive over time.

View File

@@ -1,6 +1,6 @@
[package]
name = "winit"
version = "0.16.1"
version = "0.16.2"
authors = ["The winit contributors, Pierre Krieger <pierre.krieger1708@gmail.com>"]
description = "Cross-platform window creation library."
keywords = ["windowing"]
@@ -57,5 +57,5 @@ features = [
wayland-client = { version = "0.20.6", features = [ "dlopen", "egl", "cursor"] }
smithay-client-toolkit = "0.2.2"
x11-dl = "2.17.5"
parking_lot = "0.5"
parking_lot = "0.6"
percent-encoding = "1.0"

View File

@@ -102,7 +102,7 @@ impl UnownedWindow {
.unwrap_or(1.0)
})
} else {
unreachable!("There are no detected monitors, which should've already caused a panic.");
return Err(OsError(format!("No monitors were detected.")));
};
info!("Guessed window DPI factor: {}", dpi_factor);

View File

@@ -33,6 +33,8 @@ use platform::platform::monitor::get_available_monitors;
use platform::platform::raw_input::register_all_mice_and_keyboards_for_raw_input;
use platform::platform::util;
const WS_RESIZABLE: DWORD = winuser::WS_SIZEBOX | winuser::WS_MAXIMIZEBOX;
/// The Win32 implementation of the main `Window` object.
pub struct Window {
/// Main handle for the window.
@@ -294,9 +296,9 @@ impl Window {
winuser::GetWindowLongW(self.window.0, winuser::GWL_STYLE)
};
if resizable {
style |= winuser::WS_SIZEBOX as LONG;
style |= WS_RESIZABLE as LONG;
} else {
style &= !winuser::WS_SIZEBOX as LONG;
style &= !WS_RESIZABLE as LONG;
}
unsafe {
@@ -544,9 +546,9 @@ impl Window {
let _ = Self::grab_cursor_inner(&window, false);
if resizable {
style |= winuser::WS_SIZEBOX as LONG;
style |= WS_RESIZABLE as LONG;
} else {
style &= !winuser::WS_SIZEBOX as LONG;
style &= !WS_RESIZABLE as LONG;
}
winuser::SetWindowLongW(window.0, winuser::GWL_STYLE, style);
winuser::SetWindowLongW(window.0, winuser::GWL_EXSTYLE, ex_style);
@@ -870,7 +872,7 @@ unsafe fn init(
}
dpi_factor
} else {
unreachable!("There are no detected monitors, which should've already caused a panic.");
return Err(CreationError::OsError(format!("No monitors were detected.")));
};
dpi_factor.unwrap_or_else(|| {
util::get_cursor_pos()
@@ -951,7 +953,7 @@ unsafe fn init(
};
if !attributes.resizable {
style &= !winuser::WS_SIZEBOX;
style &= !WS_RESIZABLE;
}
if pl_attribs.parent.is_some() {