gpui: Support disabling window resizing and minimizing (#36859)

Add support to disable both window resizing and minimizing.

| | macOS | Windows |
| - | - | - |
| **Unresizable** | <img width="412" height="440"
alt="SCR-20250822-qpea"
src="https://github.com/user-attachments/assets/d6d45510-dc4b-436f-a9fa-ce9cb0b0c411"
/> | <img width="276" height="298" alt="2025-08-22 110757"
src="https://github.com/user-attachments/assets/9deff498-e903-4173-9c26-072dd9409fc1"
/> |
| **Unminimizable** | <img width="412" height="440"
alt="SCR-20250822-qpfl"
src="https://github.com/user-attachments/assets/e1d5f9eb-6de5-4908-8b52-38ccb2e65689"
/> | <img width="276" height="298" alt="2025-08-22 110814"
src="https://github.com/user-attachments/assets/da94b006-3544-4274-8b02-1cab7ca8dd70"
/> |

Release Notes:

- N/A
This commit is contained in:
Floyd Wang
2025-08-27 10:26:57 -07:00
committed by GitHub
parent 45ff22f793
commit 9ca4fb16b2
9 changed files with 77 additions and 8 deletions
+12 -4
View File
@@ -530,6 +530,8 @@ impl MacWindow {
titlebar,
kind,
is_movable,
is_resizable,
is_minimizable,
focus,
show,
display_id,
@@ -545,10 +547,16 @@ impl MacWindow {
let mut style_mask;
if let Some(titlebar) = titlebar.as_ref() {
style_mask = NSWindowStyleMask::NSClosableWindowMask
| NSWindowStyleMask::NSMiniaturizableWindowMask
| NSWindowStyleMask::NSResizableWindowMask
| NSWindowStyleMask::NSTitledWindowMask;
style_mask =
NSWindowStyleMask::NSClosableWindowMask | NSWindowStyleMask::NSTitledWindowMask;
if is_resizable {
style_mask |= NSWindowStyleMask::NSResizableWindowMask;
}
if is_minimizable {
style_mask |= NSWindowStyleMask::NSMiniaturizableWindowMask;
}
if titlebar.appears_transparent {
style_mask |= NSWindowStyleMask::NSFullSizeContentViewWindowMask;
+11 -4
View File
@@ -382,10 +382,17 @@ impl WindowsWindow {
let (mut dwexstyle, dwstyle) = if params.kind == WindowKind::PopUp {
(WS_EX_TOOLWINDOW, WINDOW_STYLE(0x0))
} else {
(
WS_EX_APPWINDOW,
WS_THICKFRAME | WS_SYSMENU | WS_MAXIMIZEBOX | WS_MINIMIZEBOX,
)
let mut dwstyle = WS_SYSMENU;
if params.is_resizable {
dwstyle |= WS_THICKFRAME | WS_MAXIMIZEBOX;
}
if params.is_minimizable {
dwstyle |= WS_MINIMIZEBOX;
}
(WS_EX_APPWINDOW, dwstyle)
};
if !disable_direct_composition {
dwexstyle |= WS_EX_NOREDIRECTIONBITMAP;