gpui: Fix show: false support on Windows to create an invisible window (#18161)
Release Notes: - N/A - The `show` of WindowOptions is valid on macOS but not on Windows, this changes to fix it to support create an invisible window. ```bash cargo run -p gpui --example window ``` ## Before https://github.com/user-attachments/assets/4157bdaa-39a7-44df-bbdc-30b00e9c61e9 ## After https://github.com/user-attachments/assets/d48fa524-0caa-4f87-932d-01d7a468c488 https://github.com/user-attachments/assets/dd052f15-c8db-4a2a-a6af-a7c0ffecca84
This commit is contained in:
@@ -707,7 +707,7 @@ impl MacWindow {
|
||||
}
|
||||
}
|
||||
|
||||
if focus {
|
||||
if focus && show {
|
||||
native_window.makeKeyAndOrderFront_(nil);
|
||||
} else if show {
|
||||
native_window.orderFront_(nil);
|
||||
|
||||
@@ -287,7 +287,7 @@ impl WindowsWindow {
|
||||
.map(|title| title.as_ref())
|
||||
.unwrap_or(""),
|
||||
);
|
||||
let (dwexstyle, dwstyle) = if params.kind == WindowKind::PopUp {
|
||||
let (dwexstyle, mut dwstyle) = if params.kind == WindowKind::PopUp {
|
||||
(WS_EX_TOOLWINDOW, WINDOW_STYLE(0x0))
|
||||
} else {
|
||||
(
|
||||
@@ -295,6 +295,10 @@ impl WindowsWindow {
|
||||
WS_THICKFRAME | WS_SYSMENU | WS_MAXIMIZEBOX | WS_MINIMIZEBOX,
|
||||
)
|
||||
};
|
||||
if !params.show {
|
||||
dwstyle |= WS_MINIMIZE;
|
||||
}
|
||||
|
||||
let hinstance = get_module_handle();
|
||||
let display = if let Some(display_id) = params.display_id {
|
||||
// if we obtain a display_id, then this ID must be valid.
|
||||
@@ -357,7 +361,12 @@ impl WindowsWindow {
|
||||
drop(lock);
|
||||
SetWindowPlacement(raw_hwnd, &placement)?;
|
||||
}
|
||||
unsafe { ShowWindow(raw_hwnd, SW_SHOW).ok()? };
|
||||
|
||||
if params.show {
|
||||
unsafe { ShowWindow(raw_hwnd, SW_SHOW).ok()? };
|
||||
} else {
|
||||
unsafe { ShowWindow(raw_hwnd, SW_HIDE).ok()? };
|
||||
}
|
||||
|
||||
Ok(Self(state_ptr))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user