From e1ddd3bdbc28d945d39d30840b34cf329f5eaff5 Mon Sep 17 00:00:00 2001 From: Birunthan Mohanathas Date: Mon, 17 Jul 2017 23:51:42 +0300 Subject: [PATCH] Stop sending resize event for minimized windows on Windows This makes it consistent with macOS. This also fixes BrowserView auto-resize on Windows when minimizing and restoring the window. Previously it would incorrectly grow too in some cases. --- atom/browser/native_window_views.cc | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/atom/browser/native_window_views.cc b/atom/browser/native_window_views.cc index 3452323546c4..a00943f5549f 100644 --- a/atom/browser/native_window_views.cc +++ b/atom/browser/native_window_views.cc @@ -1121,17 +1121,20 @@ void NativeWindowViews::OnWidgetBoundsChanged( if (widget != window_.get()) return; - if (widget_size_ != bounds.size()) { + // Note: We intentionally use `GetBounds()` instead of `bounds` to properly + // handle minimized windows on Windows. + const auto new_bounds = GetBounds(); + if (widget_size_ != new_bounds.size()) { if (browser_view_) { const auto flags = static_cast(browser_view_) ->GetAutoResizeFlags(); int width_delta = 0; int height_delta = 0; if (flags & kAutoResizeWidth) { - width_delta = bounds.width() - widget_size_.width(); + width_delta = new_bounds.width() - widget_size_.width(); } if (flags & kAutoResizeHeight) { - height_delta = bounds.height() - widget_size_.height(); + height_delta = new_bounds.height() - widget_size_.height(); } auto* view = browser_view_->GetInspectableWebContentsView()->GetView(); @@ -1142,7 +1145,7 @@ void NativeWindowViews::OnWidgetBoundsChanged( } NotifyWindowResize(); - widget_size_ = bounds.size(); + widget_size_ = new_bounds.size(); } }