Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: ui/views/win/fullscreen_handler.cc

Issue 1859283003: Avoid restoring maximized window down when going fullscreen. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/views/win/fullscreen_handler.h ('k') | ui/views/win/hwnd_message_handler.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/views/win/fullscreen_handler.h" 5 #include "ui/views/win/fullscreen_handler.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/win/win_util.h" 9 #include "base/win/win_util.h"
10 #include "ui/base/win/shell.h" 10 #include "ui/base/win/shell.h"
(...skipping 28 matching lines...) Expand all
39 scoped_ptr<ScopedFullscreenVisibility> visibility; 39 scoped_ptr<ScopedFullscreenVisibility> visibility;
40 40
41 // With Aero enabled disabling the visibility causes the window to disappear 41 // With Aero enabled disabling the visibility causes the window to disappear
42 // for several frames, which looks worse than doing other updates 42 // for several frames, which looks worse than doing other updates
43 // non-atomically. 43 // non-atomically.
44 if (!ui::win::IsAeroGlassEnabled()) 44 if (!ui::win::IsAeroGlassEnabled())
45 visibility.reset(new ScopedFullscreenVisibility(hwnd_)); 45 visibility.reset(new ScopedFullscreenVisibility(hwnd_));
46 46
47 // Save current window state if not already fullscreen. 47 // Save current window state if not already fullscreen.
48 if (!fullscreen_) { 48 if (!fullscreen_) {
49 // Save current window information. We force the window into restored mode
50 // before going fullscreen because Windows doesn't seem to hide the
51 // taskbar if the window is in the maximized state.
52 saved_window_info_.maximized = !!::IsZoomed(hwnd_);
53 if (saved_window_info_.maximized)
54 ::SendMessage(hwnd_, WM_SYSCOMMAND, SC_RESTORE, 0);
55 saved_window_info_.style = GetWindowLong(hwnd_, GWL_STYLE); 49 saved_window_info_.style = GetWindowLong(hwnd_, GWL_STYLE);
56 saved_window_info_.ex_style = GetWindowLong(hwnd_, GWL_EXSTYLE); 50 saved_window_info_.ex_style = GetWindowLong(hwnd_, GWL_EXSTYLE);
57 GetWindowRect(hwnd_, &saved_window_info_.window_rect); 51 GetWindowRect(hwnd_, &saved_window_info_.window_rect);
58 } 52 }
59 53
60 fullscreen_ = fullscreen; 54 fullscreen_ = fullscreen;
61 55
62 if (fullscreen_) { 56 if (fullscreen_) {
63 // Set new window style and size. 57 // Set new window style and size.
64 SetWindowLong(hwnd_, GWL_STYLE, 58 SetWindowLong(hwnd_, GWL_STYLE,
(...skipping 17 matching lines...) Expand all
82 // here are ugly, but if SetWindowPos() doesn't redraw, the taskbar won't be 76 // here are ugly, but if SetWindowPos() doesn't redraw, the taskbar won't be
83 // repainted. Better-looking methods welcome. 77 // repainted. Better-looking methods welcome.
84 SetWindowLong(hwnd_, GWL_STYLE, saved_window_info_.style); 78 SetWindowLong(hwnd_, GWL_STYLE, saved_window_info_.style);
85 SetWindowLong(hwnd_, GWL_EXSTYLE, saved_window_info_.ex_style); 79 SetWindowLong(hwnd_, GWL_EXSTYLE, saved_window_info_.ex_style);
86 80
87 // On restore, resize to the previous saved rect size. 81 // On restore, resize to the previous saved rect size.
88 gfx::Rect new_rect(saved_window_info_.window_rect); 82 gfx::Rect new_rect(saved_window_info_.window_rect);
89 SetWindowPos(hwnd_, NULL, new_rect.x(), new_rect.y(), new_rect.width(), 83 SetWindowPos(hwnd_, NULL, new_rect.x(), new_rect.y(), new_rect.width(),
90 new_rect.height(), 84 new_rect.height(),
91 SWP_NOZORDER | SWP_NOACTIVATE | SWP_FRAMECHANGED); 85 SWP_NOZORDER | SWP_NOACTIVATE | SWP_FRAMECHANGED);
92 if (saved_window_info_.maximized)
93 ::SendMessage(hwnd_, WM_SYSCOMMAND, SC_MAXIMIZE, 0);
94 } 86 }
95 } 87 }
96 88
97 } // namespace views 89 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/win/fullscreen_handler.h ('k') | ui/views/win/hwnd_message_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698