Remember bounds instead of size
authorCheng Zhao <zcbenz@gmail.com>
Sat, 9 Jul 2016 14:10:36 +0000 (23:10 +0900)
committerCheng Zhao <zcbenz@gmail.com>
Sat, 9 Jul 2016 14:10:36 +0000 (23:10 +0900)
atom/browser/native_window_views.cc
atom/browser/native_window_views.h
atom/browser/native_window_views_win.cc

index 7b65dfc8be6d5f7f91a08bba17e0696a167394fb..0bb16d364b0d91639acaeafa07d96ff91c890102 100644 (file)
@@ -279,13 +279,6 @@ NativeWindowViews::NativeWindowViews(
   AddChildView(web_view_);
 
 #if defined(OS_WIN)
-  // Save initial window state.
-  if (fullscreen)
-    last_window_state_ = ui::SHOW_STATE_FULLSCREEN;
-  else
-    last_window_state_ = ui::SHOW_STATE_NORMAL;
-  last_normal_size_ = widget_size_;
-
   if (!has_frame()) {
     // Set Window style so that we get a minimize and maximize animation when
     // frameless.
@@ -325,6 +318,15 @@ NativeWindowViews::NativeWindowViews(
 
   window_->CenterWindow(size);
   Layout();
+
+#if defined(OS_WIN)
+  // Save initial window state.
+  if (fullscreen)
+    last_window_state_ = ui::SHOW_STATE_FULLSCREEN;
+  else
+    last_window_state_ = ui::SHOW_STATE_NORMAL;
+  last_normal_bounds_ = GetBounds();
+#endif
 }
 
 NativeWindowViews::~NativeWindowViews() {
@@ -419,7 +421,7 @@ void NativeWindowViews::Maximize() {
 #if defined(OS_WIN)
   // For window without WS_THICKFRAME style, we can not call Maximize().
   if (!thick_frame_) {
-    last_normal_size_ = GetSize();
+    last_normal_bounds_ = GetBounds();
     auto display =
         gfx::Screen::GetScreen()->GetDisplayNearestPoint(GetPosition());
     SetBounds(display.work_area(), false);
@@ -437,7 +439,7 @@ void NativeWindowViews::Maximize() {
 void NativeWindowViews::Unmaximize() {
 #if defined(OS_WIN)
   if (!thick_frame_) {
-    NativeWindow::SetSize(last_normal_size_);
+    SetBounds(last_normal_bounds_, false);
     return;
   }
 #endif
@@ -482,12 +484,12 @@ void NativeWindowViews::SetFullScreen(bool fullscreen) {
   // For window without WS_THICKFRAME style, we can not call SetFullscreen().
   if (!thick_frame_) {
     if (fullscreen) {
-      last_normal_size_ = GetSize();
+      last_normal_bounds_ = GetBounds();
       auto display =
           gfx::Screen::GetScreen()->GetDisplayNearestPoint(GetPosition());
       SetBounds(display.bounds(), false);
     } else {
-      NativeWindow::SetSize(last_normal_size_);
+      SetBounds(last_normal_bounds_, false);
     }
     return;
   }
index f3ca27077fe87a2c3337fec375cc4685bc8b49e8..4c7d0efca1aec02432b5f2b924b94ba4a68d05dc 100644 (file)
@@ -212,7 +212,7 @@ class NativeWindowViews : public NativeWindow,
   // to receive the wrong size (#2498). To circumvent that, we keep tabs on the
   // size of the window while in the normal state (not maximized, minimized or
   // fullscreen), so we restore it correctly.
-  gfx::Size last_normal_size_;
+  gfx::Rect last_normal_bounds_;
 
   // In charge of running taskbar related APIs.
   TaskbarHost taskbar_host_;
index 038ab105222d29825a93bc1b5dc4120eb80e5728..c49533033cd5750be5778dcdd5a6a895fda1f1a0 100644 (file)
@@ -140,7 +140,7 @@ void NativeWindowViews::HandleSizeEvent(WPARAM w_param, LPARAM l_param) {
     case SIZE_RESTORED:
       if (last_window_state_ == ui::SHOW_STATE_NORMAL) {
         // Window was resized so we save it's new size.
-        last_normal_size_ = GetSize();
+        last_normal_bounds_ = GetBounds();
       } else {
         switch (last_window_state_) {
           case ui::SHOW_STATE_MAXIMIZED:
@@ -148,7 +148,7 @@ void NativeWindowViews::HandleSizeEvent(WPARAM w_param, LPARAM l_param) {
 
             // When the window is restored we resize it to the previous known
             // normal size.
-            NativeWindow::SetSize(last_normal_size_);
+            SetBounds(last_normal_bounds_, false);
 
             NotifyWindowUnmaximize();
             break;
@@ -161,7 +161,7 @@ void NativeWindowViews::HandleSizeEvent(WPARAM w_param, LPARAM l_param) {
 
               // When the window is restored we resize it to the previous known
               // normal size.
-              NativeWindow::SetSize(last_normal_size_);
+              SetBounds(last_normal_bounds_, false);
 
               NotifyWindowRestore();
             }