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

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

Issue 10871020: Move Fullscreen stuff onto FullscreenHandler type that hangs off NWW. This is the first step in mov… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « ui/views/win/fullscreen_handler.h ('k') | ui/views/win/scoped_fullscreen_visibility.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "ui/views/win/fullscreen_handler.h"
6
7 #include "base/logging.h"
8 // TODO(beng): Temporary dependancy until fullscreen moves to
9 // HWNDMessageHandler.
10 #include "ui/views/widget/widget.h"
11 #include "ui/views/win/scoped_fullscreen_visibility.h"
12
13 namespace views {
14
15 ////////////////////////////////////////////////////////////////////////////////
16 // FullscreenHandler, public:
17
18 FullscreenHandler::FullscreenHandler(Widget* widget)
19 : widget_(widget),
20 fullscreen_(false),
21 metro_snap_(false) {
22 }
23
24 FullscreenHandler::~FullscreenHandler() {
25 }
26
27 void FullscreenHandler::SetFullscreen(bool fullscreen) {
28 if (fullscreen_ == fullscreen)
29 return;
30
31 SetFullscreenImpl(fullscreen, false);
32 }
33
34 void FullscreenHandler::SetMetroSnap(bool metro_snap) {
35 if (metro_snap_ == metro_snap)
36 return;
37
38 SetFullscreenImpl(metro_snap, true);
39 metro_snap_ = metro_snap;
40 }
41
42 gfx::Rect FullscreenHandler::GetRestoreBounds() const {
43 return gfx::Rect(saved_window_info_.window_rect);
44 }
45
46 ////////////////////////////////////////////////////////////////////////////////
47 // FullscreenHandler, private:
48
49 void FullscreenHandler::SetFullscreenImpl(bool fullscreen, bool for_metro) {
50 ScopedFullscreenVisibility visibility(widget_->GetNativeView());
51
52 // Save current window state if not already fullscreen.
53 if (!fullscreen_) {
54 // Save current window information. We force the window into restored mode
55 // before going fullscreen because Windows doesn't seem to hide the
56 // taskbar if the window is in the maximized state.
57 saved_window_info_.maximized = widget_->IsMaximized();
58 if (saved_window_info_.maximized)
59 widget_->Restore();
60 saved_window_info_.style =
61 GetWindowLong(widget_->GetNativeView(), GWL_STYLE);
62 saved_window_info_.ex_style =
63 GetWindowLong(widget_->GetNativeView(), GWL_EXSTYLE);
64 GetWindowRect(widget_->GetNativeView(), &saved_window_info_.window_rect);
65 }
66
67 fullscreen_ = fullscreen;
68
69 if (fullscreen_) {
70 // Set new window style and size.
71 SetWindowLong(widget_->GetNativeView(), GWL_STYLE,
72 saved_window_info_.style & ~(WS_CAPTION | WS_THICKFRAME));
73 SetWindowLong(widget_->GetNativeView(), GWL_EXSTYLE,
74 saved_window_info_.ex_style & ~(WS_EX_DLGMODALFRAME |
75 WS_EX_WINDOWEDGE | WS_EX_CLIENTEDGE | WS_EX_STATICEDGE));
76
77 // On expand, if we're given a window_rect, grow to it, otherwise do
78 // not resize.
79 if (!for_metro) {
80 MONITORINFO monitor_info;
81 monitor_info.cbSize = sizeof(monitor_info);
82 GetMonitorInfo(MonitorFromWindow(widget_->GetNativeView(),
83 MONITOR_DEFAULTTONEAREST),
84 &monitor_info);
85 gfx::Rect window_rect(monitor_info.rcMonitor);
86 SetWindowPos(widget_->GetNativeView(), NULL,
87 window_rect.x(), window_rect.y(),
88 window_rect.width(), window_rect.height(),
89 SWP_NOZORDER | SWP_NOACTIVATE | SWP_FRAMECHANGED);
90 }
91 } else {
92 // Reset original window style and size. The multiple window size/moves
93 // here are ugly, but if SetWindowPos() doesn't redraw, the taskbar won't be
94 // repainted. Better-looking methods welcome.
95 SetWindowLong(widget_->GetNativeView(), GWL_STYLE,
96 saved_window_info_.style);
97 SetWindowLong(widget_->GetNativeView(), GWL_EXSTYLE,
98 saved_window_info_.ex_style);
99
100 if (!for_metro) {
101 // On restore, resize to the previous saved rect size.
102 gfx::Rect new_rect(saved_window_info_.window_rect);
103 SetWindowPos(widget_->GetNativeView(), NULL,
104 new_rect.x(), new_rect.y(),
105 new_rect.width(), new_rect.height(),
106 SWP_NOZORDER | SWP_NOACTIVATE | SWP_FRAMECHANGED);
107 }
108 if (saved_window_info_.maximized)
109 widget_->Maximize();
110 }
111 }
112
113 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/win/fullscreen_handler.h ('k') | ui/views/win/scoped_fullscreen_visibility.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698