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

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 {
21 namespace wm { 22 namespace wm {
22 23
23 // static 24 // static
24 bool WindowState::IsMaximizedOrFullscreenState(ui::WindowShowState show_state) { 25 bool WindowState::IsMaximizedOrFullscreenState(ui::WindowShowState show_state) {
25 return show_state == ui::SHOW_STATE_FULLSCREEN || 26 return show_state == ui::SHOW_STATE_FULLSCREEN ||
26 show_state == ui::SHOW_STATE_MAXIMIZED; 27 show_state == ui::SHOW_STATE_MAXIMIZED;
27 } 28 }
28 29
29 WindowState::WindowState(aura::Window* window) 30 WindowState::WindowState(aura::Window* window)
30 : window_(window), 31 : window_(window),
31 tracked_by_workspace_(true), 32 tracked_by_workspace_(true),
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 always_restores_to_restore_bounds_(false), 40 always_restores_to_restore_bounds_(false),
41 animate_to_fullscreen_(true),
40 window_show_type_(ToWindowShowType(GetShowState())) { 42 window_show_type_(ToWindowShowType(GetShowState())) {
41 window_->AddObserver(this); 43 window_->AddObserver(this);
42 } 44 }
43 45
44 WindowState::~WindowState() { 46 WindowState::~WindowState() {
45 } 47 }
46 48
49 void WindowState::SetDelegate(WindowStateDelegate* delegate) {
50 DCHECK(!delegate_.get());
51 delegate_.reset(delegate);
52 }
53
47 ui::WindowShowState WindowState::GetShowState() const { 54 ui::WindowShowState WindowState::GetShowState() const {
48 return window_->GetProperty(aura::client::kShowStateKey); 55 return window_->GetProperty(aura::client::kShowStateKey);
49 } 56 }
50 57
51 bool WindowState::IsMinimized() const { 58 bool WindowState::IsMinimized() const {
52 return GetShowState() == ui::SHOW_STATE_MINIMIZED; 59 return GetShowState() == ui::SHOW_STATE_MINIMIZED;
53 } 60 }
54 61
55 bool WindowState::IsMaximized() const { 62 bool WindowState::IsMaximized() const {
56 return GetShowState() == ui::SHOW_STATE_MAXIMIZED; 63 return GetShowState() == ui::SHOW_STATE_MAXIMIZED;
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 window_->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); 154 window_->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL);
148 } 155 }
149 156
150 void WindowState::ToggleMaximized() { 157 void WindowState::ToggleMaximized() {
151 if (IsMaximized()) 158 if (IsMaximized())
152 Restore(); 159 Restore();
153 else if (CanMaximize()) 160 else if (CanMaximize())
154 Maximize(); 161 Maximize();
155 } 162 }
156 163
164 void WindowState::ToggleFullscreen() {
pkotwicz 2013/10/26 03:46:34 You probably want to check CanMaximize() in this f
oshima 2013/10/28 22:57:51 Good point. Done.
165 if (delegate_ && delegate_->ToggleFullscreen(this))
166 return;
167 if (IsFullscreen()) {
168 Restore();
169 } else {
170 window_->SetProperty(aura::client::kShowStateKey,
171 ui::SHOW_STATE_FULLSCREEN);
172 }
173 }
174
157 void WindowState::SetBoundsInScreen( 175 void WindowState::SetBoundsInScreen(
158 const gfx::Rect& bounds_in_screen) { 176 const gfx::Rect& bounds_in_screen) {
159 gfx::Rect bounds_in_parent = 177 gfx::Rect bounds_in_parent =
160 ScreenAsh::ConvertRectFromScreen(window_->parent(), 178 ScreenAsh::ConvertRectFromScreen(window_->parent(),
161 bounds_in_screen); 179 bounds_in_screen);
162 window_->SetBounds(bounds_in_parent); 180 window_->SetBounds(bounds_in_parent);
163 } 181 }
164 182
165 void WindowState::SaveCurrentBoundsForRestore() { 183 void WindowState::SaveCurrentBoundsForRestore() {
166 gfx::Rect bounds_in_screen = 184 gfx::Rect bounds_in_screen =
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 } 287 }
270 return settings; 288 return settings;
271 } 289 }
272 290
273 const WindowState* GetWindowState(const aura::Window* window) { 291 const WindowState* GetWindowState(const aura::Window* window) {
274 return GetWindowState(const_cast<aura::Window*>(window)); 292 return GetWindowState(const_cast<aura::Window*>(window));
275 } 293 }
276 294
277 } // namespace wm 295 } // namespace wm
278 } // namespace ash 296 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698