Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: don't restore maximized BrowserWindow when calling showInactive (#…
…33020) * fix: don't restore maximized BrowserWindow when calling showInactive * chore: update patches Co-authored-by: David Sanders <dsanders11@ucsbalum.com> Co-authored-by: PatchUp <73610968+patchup[bot]@users.noreply.github.com>
- Loading branch information
1 parent
8391e52
commit a9fe62c
Showing
3 changed files
with
59 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
patches/chromium/fix_don_t_restore_maximized_windows_when_calling_showinactive.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 | ||
From: David Sanders <dsanders11@ucsbalum.com> | ||
Date: Fri, 11 Feb 2022 22:37:39 +0000 | ||
Subject: fix: don't restore maximized windows when calling ShowInactive | ||
|
||
This is a backport from Chromium of | ||
https://chromium-review.googlesource.com/c/chromium/src/+/3371573. | ||
|
||
diff --git a/ui/views/win/hwnd_message_handler.cc b/ui/views/win/hwnd_message_handler.cc | ||
index f7c1232b0893c366aeeb77e6df0bbd275b6f7bd4..ef01843018cfada041330c3ed75d9d55c3225049 100644 | ||
--- a/ui/views/win/hwnd_message_handler.cc | ||
+++ b/ui/views/win/hwnd_message_handler.cc | ||
@@ -664,9 +664,16 @@ void HWNDMessageHandler::Show(ui::WindowShowState show_state, | ||
SetWindowPlacement(hwnd(), &placement); | ||
native_show_state = SW_SHOWMAXIMIZED; | ||
} else { | ||
+ const bool is_maximized = IsMaximized(); | ||
+ | ||
+ // Use SW_SHOW/SW_SHOWNA instead of SW_SHOWNORMAL/SW_SHOWNOACTIVATE so that | ||
+ // the window is not restored to its original position if it is maximized. | ||
+ // This could be used unconditionally for ui::SHOW_STATE_INACTIVE, but | ||
+ // cross-platform behavior when showing a minimized window is inconsistent, | ||
+ // some platforms restore the position, some do not. See crbug.com/1296710 | ||
switch (show_state) { | ||
case ui::SHOW_STATE_INACTIVE: | ||
- native_show_state = SW_SHOWNOACTIVATE; | ||
+ native_show_state = is_maximized ? SW_SHOWNA : SW_SHOWNOACTIVATE; | ||
break; | ||
case ui::SHOW_STATE_MAXIMIZED: | ||
native_show_state = SW_SHOWMAXIMIZED; | ||
@@ -677,9 +684,9 @@ void HWNDMessageHandler::Show(ui::WindowShowState show_state, | ||
case ui::SHOW_STATE_NORMAL: | ||
if ((GetWindowLong(hwnd(), GWL_EXSTYLE) & WS_EX_TRANSPARENT) || | ||
(GetWindowLong(hwnd(), GWL_EXSTYLE) & WS_EX_NOACTIVATE)) { | ||
- native_show_state = SW_SHOWNOACTIVATE; | ||
+ native_show_state = is_maximized ? SW_SHOWNA : SW_SHOWNOACTIVATE; | ||
} else { | ||
- native_show_state = SW_SHOWNORMAL; | ||
+ native_show_state = is_maximized ? SW_SHOW : SW_SHOWNORMAL; | ||
} | ||
break; | ||
case ui::SHOW_STATE_FULLSCREEN: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters