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

Side by Side Diff: ash/wm/window_state.cc

Issue 42353002: Introduce WindowStateDelegate::ToggleFullscreen (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 1 month 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "ash/wm/window_state.h" 5 #include "ash/wm/window_state.h"
6 6
7 #include "ash/root_window_controller.h" 7 #include "ash/root_window_controller.h"
8 #include "ash/screen_ash.h" 8 #include "ash/screen_ash.h"
9 #include "ash/shell_window_ids.h" 9 #include "ash/shell_window_ids.h"
10 #include "ash/wm/window_properties.h" 10 #include "ash/wm/window_properties.h"
11 #include "ash/wm/window_state_delegate.h"
11 #include "ash/wm/window_state_observer.h" 12 #include "ash/wm/window_state_observer.h"
12 #include "ash/wm/window_util.h" 13 #include "ash/wm/window_util.h"
13 #include "ash/wm/wm_types.h" 14 #include "ash/wm/wm_types.h"
14 #include "ui/aura/client/aura_constants.h" 15 #include "ui/aura/client/aura_constants.h"
15 #include "ui/aura/window.h" 16 #include "ui/aura/window.h"
16 #include "ui/aura/window_delegate.h" 17 #include "ui/aura/window_delegate.h"
17 #include "ui/gfx/display.h" 18 #include "ui/gfx/display.h"
18 #include "ui/views/corewm/window_util.h" 19 #include "ui/views/corewm/window_util.h"
19 20
20 namespace ash { 21 namespace ash {
(...skipping 11 matching lines...) Expand all
32 window_position_managed_(false), 33 window_position_managed_(false),
33 bounds_changed_by_user_(false), 34 bounds_changed_by_user_(false),
34 panel_attached_(true), 35 panel_attached_(true),
35 continue_drag_after_reparent_(false), 36 continue_drag_after_reparent_(false),
36 ignored_by_shelf_(false), 37 ignored_by_shelf_(false),
37 can_consume_system_keys_(false), 38 can_consume_system_keys_(false),
38 top_row_keys_are_function_keys_(false), 39 top_row_keys_are_function_keys_(false),
39 window_resizer_(NULL), 40 window_resizer_(NULL),
40 always_restores_to_restore_bounds_(false), 41 always_restores_to_restore_bounds_(false),
41 hide_shelf_when_fullscreen_(true), 42 hide_shelf_when_fullscreen_(true),
43 animate_to_fullscreen_(true),
42 window_show_type_(ToWindowShowType(GetShowState())) { 44 window_show_type_(ToWindowShowType(GetShowState())) {
43 window_->AddObserver(this); 45 window_->AddObserver(this);
44 } 46 }
45 47
46 WindowState::~WindowState() { 48 WindowState::~WindowState() {
47 } 49 }
48 50
51 void WindowState::SetDelegate(WindowStateDelegate* delegate) {
52 DCHECK(!delegate_.get());
53 delegate_.reset(delegate);
54 }
55
49 ui::WindowShowState WindowState::GetShowState() const { 56 ui::WindowShowState WindowState::GetShowState() const {
50 return window_->GetProperty(aura::client::kShowStateKey); 57 return window_->GetProperty(aura::client::kShowStateKey);
51 } 58 }
52 59
53 bool WindowState::IsMinimized() const { 60 bool WindowState::IsMinimized() const {
54 return GetShowState() == ui::SHOW_STATE_MINIMIZED; 61 return GetShowState() == ui::SHOW_STATE_MINIMIZED;
55 } 62 }
56 63
57 bool WindowState::IsMaximized() const { 64 bool WindowState::IsMaximized() const {
58 return GetShowState() == ui::SHOW_STATE_MAXIMIZED; 65 return GetShowState() == ui::SHOW_STATE_MAXIMIZED;
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 window_->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); 156 window_->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL);
150 } 157 }
151 158
152 void WindowState::ToggleMaximized() { 159 void WindowState::ToggleMaximized() {
153 if (IsMaximized()) 160 if (IsMaximized())
154 Restore(); 161 Restore();
155 else if (CanMaximize()) 162 else if (CanMaximize())
156 Maximize(); 163 Maximize();
157 } 164 }
158 165
166 void WindowState::ToggleFullscreen() {
167 // Window which cannot be maximized should not be fullscreened.
168 // It can, however, be restored if it was fullscreened.
169 bool is_fullscreen = IsFullscreen();
170 if (!is_fullscreen && !CanMaximize())
171 return;
172 if (delegate_ && delegate_->ToggleFullscreen(this))
173 return;
174 if (is_fullscreen) {
175 Restore();
176 } else {
177 window_->SetProperty(aura::client::kShowStateKey,
178 ui::SHOW_STATE_FULLSCREEN);
179 }
180 }
181
159 void WindowState::SetBoundsInScreen( 182 void WindowState::SetBoundsInScreen(
160 const gfx::Rect& bounds_in_screen) { 183 const gfx::Rect& bounds_in_screen) {
161 gfx::Rect bounds_in_parent = 184 gfx::Rect bounds_in_parent =
162 ScreenAsh::ConvertRectFromScreen(window_->parent(), 185 ScreenAsh::ConvertRectFromScreen(window_->parent(),
163 bounds_in_screen); 186 bounds_in_screen);
164 window_->SetBounds(bounds_in_parent); 187 window_->SetBounds(bounds_in_parent);
165 } 188 }
166 189
167 void WindowState::SaveCurrentBoundsForRestore() { 190 void WindowState::SaveCurrentBoundsForRestore() {
168 gfx::Rect bounds_in_screen = 191 gfx::Rect bounds_in_screen =
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 } 294 }
272 return settings; 295 return settings;
273 } 296 }
274 297
275 const WindowState* GetWindowState(const aura::Window* window) { 298 const WindowState* GetWindowState(const aura::Window* window) {
276 return GetWindowState(const_cast<aura::Window*>(window)); 299 return GetWindowState(const_cast<aura::Window*>(window));
277 } 300 }
278 301
279 } // namespace wm 302 } // namespace wm
280 } // namespace ash 303 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698