mirror of
https://github.com/italicsjenga/winit-sonoma-fix.git
synced 2024-12-24 06:11:30 +11:00
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
This commit is contained in:
parent
1703d0417a
commit
ec393e4a90
|
@ -1,5 +1,7 @@
|
||||||
# Unreleased
|
# Unreleased
|
||||||
|
|
||||||
|
- On Windows, non-resizable windows now have the maximization button disabled. This is consistent with behavior on macOS and popular X11 WMs.
|
||||||
|
|
||||||
# Version 0.16.1 (2018-07-02)
|
# Version 0.16.1 (2018-07-02)
|
||||||
|
|
||||||
- Added logging through `log`. Logging will become more extensive over time.
|
- Added logging through `log`. Logging will become more extensive over time.
|
||||||
|
|
|
@ -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::raw_input::register_all_mice_and_keyboards_for_raw_input;
|
||||||
use platform::platform::util;
|
use platform::platform::util;
|
||||||
|
|
||||||
|
const WS_RESIZABLE: DWORD = winuser::WS_SIZEBOX | winuser::WS_MAXIMIZEBOX;
|
||||||
|
|
||||||
/// The Win32 implementation of the main `Window` object.
|
/// The Win32 implementation of the main `Window` object.
|
||||||
pub struct Window {
|
pub struct Window {
|
||||||
/// Main handle for the window.
|
/// Main handle for the window.
|
||||||
|
@ -294,9 +296,9 @@ impl Window {
|
||||||
winuser::GetWindowLongW(self.window.0, winuser::GWL_STYLE)
|
winuser::GetWindowLongW(self.window.0, winuser::GWL_STYLE)
|
||||||
};
|
};
|
||||||
if resizable {
|
if resizable {
|
||||||
style |= winuser::WS_SIZEBOX as LONG;
|
style |= WS_RESIZABLE as LONG;
|
||||||
} else {
|
} else {
|
||||||
style &= !winuser::WS_SIZEBOX as LONG;
|
style &= !WS_RESIZABLE as LONG;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
|
@ -544,9 +546,9 @@ impl Window {
|
||||||
let _ = Self::grab_cursor_inner(&window, false);
|
let _ = Self::grab_cursor_inner(&window, false);
|
||||||
|
|
||||||
if resizable {
|
if resizable {
|
||||||
style |= winuser::WS_SIZEBOX as LONG;
|
style |= WS_RESIZABLE as LONG;
|
||||||
} else {
|
} 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_STYLE, style);
|
||||||
winuser::SetWindowLongW(window.0, winuser::GWL_EXSTYLE, ex_style);
|
winuser::SetWindowLongW(window.0, winuser::GWL_EXSTYLE, ex_style);
|
||||||
|
@ -951,7 +953,7 @@ unsafe fn init(
|
||||||
};
|
};
|
||||||
|
|
||||||
if !attributes.resizable {
|
if !attributes.resizable {
|
||||||
style &= !winuser::WS_SIZEBOX;
|
style &= !WS_RESIZABLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if pl_attribs.parent.is_some() {
|
if pl_attribs.parent.is_some() {
|
||||||
|
|
Loading…
Reference in a new issue