fix: add check in IsMaximized for non-WS_THICKFRAME windows (#26772)

This commit is contained in:
Michaela Laurencin
2020-12-01 16:20:24 -08:00
committed by GitHub
parent 2a8961b52f
commit 8046f0560a
3 changed files with 36 additions and 5 deletions

View File

@@ -530,6 +530,20 @@ void NativeWindowViews::Unmaximize() {
}
bool NativeWindowViews::IsMaximized() {
// For window without WS_THICKFRAME style, we can not call IsMaximized().
// This path will be used for transparent windows as well.
#if defined(OS_WIN)
if (!(::GetWindowLong(GetAcceleratedWidget(), GWL_STYLE) & WS_THICKFRAME)) {
// Compare the size of the window with the size of the display
auto display = display::Screen::GetScreen()->GetDisplayNearestWindow(
GetNativeWindow());
// Maximized if the window is the same dimensions and placement as the
// display
return GetBounds() == display.work_area();
}
#endif
return widget()->IsMaximized();
}

View File

@@ -149,9 +149,7 @@ std::set<NativeWindowViews*> NativeWindowViews::forwarding_windows_;
HHOOK NativeWindowViews::mouse_hook_ = NULL;
void NativeWindowViews::Maximize() {
// Only use Maximize() when:
// 1. window has WS_THICKFRAME style;
// 2. and window is not frameless when there is autohide taskbar.
// Only use Maximize() when window has WS_THICKFRAME style
if (::GetWindowLong(GetAcceleratedWidget(), GWL_STYLE) & WS_THICKFRAME) {
if (IsVisible())
widget()->Maximize();
@@ -161,8 +159,8 @@ void NativeWindowViews::Maximize() {
return;
} else {
restore_bounds_ = GetBounds();
auto display =
display::Screen::GetScreen()->GetDisplayNearestPoint(GetPosition());
auto display = display::Screen::GetScreen()->GetDisplayNearestWindow(
GetNativeWindow());
SetBounds(display.work_area(), false);
}
}