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

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

Issue 1921353002: Moves handful of files to ash/wm/common (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@shell_ids
Patch Set: merge to trunk 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 | « ash/wm/common/window_state.h ('k') | ash/wm/common/window_state_delegate.h » ('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 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/common/window_state.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "ash/wm/common/default_state.h"
9 #include "ash/wm/common/window_positioning_utils.h" 10 #include "ash/wm/common/window_positioning_utils.h"
11 #include "ash/wm/common/window_state_delegate.h"
12 #include "ash/wm/common/window_state_observer.h"
10 #include "ash/wm/common/wm_event.h" 13 #include "ash/wm/common/wm_event.h"
11 #include "ash/wm/common/wm_screen_util.h" 14 #include "ash/wm/common/wm_screen_util.h"
12 #include "ash/wm/common/wm_window.h" 15 #include "ash/wm/common/wm_window.h"
13 #include "ash/wm/default_state.h"
14 #include "ash/wm/window_state_delegate.h"
15 #include "ash/wm/window_state_observer.h"
16 #include "base/auto_reset.h" 16 #include "base/auto_reset.h"
17 #include "ui/gfx/display.h" 17 #include "ui/gfx/display.h"
18 #include "ui/gfx/screen.h" 18 #include "ui/gfx/screen.h"
19 19
20 namespace ash { 20 namespace ash {
21 namespace wm { 21 namespace wm {
22 22
23 namespace { 23 namespace {
24 24
25 WMEventType WMEventTypeFromShowState(ui::WindowShowState requested_show_state) { 25 WMEventType WMEventTypeFromShowState(ui::WindowShowState requested_show_state) {
(...skipping 13 matching lines...) Expand all
39 return WM_EVENT_DOCK; 39 return WM_EVENT_DOCK;
40 case ui::SHOW_STATE_END: 40 case ui::SHOW_STATE_END:
41 NOTREACHED() << "No WMEvent defined for the show state:" 41 NOTREACHED() << "No WMEvent defined for the show state:"
42 << requested_show_state; 42 << requested_show_state;
43 } 43 }
44 return WM_EVENT_NORMAL; 44 return WM_EVENT_NORMAL;
45 } 45 }
46 46
47 } // namespace 47 } // namespace
48 48
49 WindowState::~WindowState() { 49 WindowState::~WindowState() {}
50 }
51 50
52 bool WindowState::HasDelegate() const { 51 bool WindowState::HasDelegate() const {
53 return !!delegate_; 52 return !!delegate_;
54 } 53 }
55 54
56 void WindowState::SetDelegate(std::unique_ptr<WindowStateDelegate> delegate) { 55 void WindowState::SetDelegate(std::unique_ptr<WindowStateDelegate> delegate) {
57 DCHECK(!delegate_.get()); 56 DCHECK(!delegate_.get());
58 delegate_ = std::move(delegate); 57 delegate_ = std::move(delegate);
59 } 58 }
60 59
61 WindowStateType WindowState::GetStateType() const { 60 WindowStateType WindowState::GetStateType() const {
62 return current_state_->GetType(); 61 return current_state_->GetType();
63 } 62 }
64 63
65 bool WindowState::IsMinimized() const { 64 bool WindowState::IsMinimized() const {
66 return GetStateType() == WINDOW_STATE_TYPE_MINIMIZED || 65 return GetStateType() == WINDOW_STATE_TYPE_MINIMIZED ||
67 GetStateType() == WINDOW_STATE_TYPE_DOCKED_MINIMIZED; 66 GetStateType() == WINDOW_STATE_TYPE_DOCKED_MINIMIZED;
68 } 67 }
69 68
70 bool WindowState::IsMaximized() const { 69 bool WindowState::IsMaximized() const {
71 return GetStateType() == WINDOW_STATE_TYPE_MAXIMIZED; 70 return GetStateType() == WINDOW_STATE_TYPE_MAXIMIZED;
72 } 71 }
73 72
74 bool WindowState::IsFullscreen() const { 73 bool WindowState::IsFullscreen() const {
75 return GetStateType() == WINDOW_STATE_TYPE_FULLSCREEN; 74 return GetStateType() == WINDOW_STATE_TYPE_FULLSCREEN;
76 } 75 }
77 76
78 bool WindowState::IsMaximizedOrFullscreen() const { 77 bool WindowState::IsMaximizedOrFullscreen() const {
79 return GetStateType() == WINDOW_STATE_TYPE_FULLSCREEN || 78 return GetStateType() == WINDOW_STATE_TYPE_FULLSCREEN ||
80 GetStateType() == WINDOW_STATE_TYPE_MAXIMIZED; 79 GetStateType() == WINDOW_STATE_TYPE_MAXIMIZED;
81 } 80 }
82 81
83 bool WindowState::IsSnapped() const { 82 bool WindowState::IsSnapped() const {
84 return GetStateType() == WINDOW_STATE_TYPE_LEFT_SNAPPED || 83 return GetStateType() == WINDOW_STATE_TYPE_LEFT_SNAPPED ||
85 GetStateType() == WINDOW_STATE_TYPE_RIGHT_SNAPPED; 84 GetStateType() == WINDOW_STATE_TYPE_RIGHT_SNAPPED;
86 } 85 }
87 86
88 bool WindowState::IsNormalStateType() const { 87 bool WindowState::IsNormalStateType() const {
89 return GetStateType() == WINDOW_STATE_TYPE_NORMAL || 88 return GetStateType() == WINDOW_STATE_TYPE_NORMAL ||
90 GetStateType() == WINDOW_STATE_TYPE_DEFAULT; 89 GetStateType() == WINDOW_STATE_TYPE_DEFAULT;
91 } 90 }
92 91
93 bool WindowState::IsNormalOrSnapped() const { 92 bool WindowState::IsNormalOrSnapped() const {
94 return IsNormalStateType() || IsSnapped(); 93 return IsNormalStateType() || IsSnapped();
95 } 94 }
96 95
97 bool WindowState::IsActive() const { 96 bool WindowState::IsActive() const {
98 return window_->IsActive(); 97 return window_->IsActive();
99 } 98 }
100 99
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 238
240 std::unique_ptr<WindowState::State> WindowState::SetStateObject( 239 std::unique_ptr<WindowState::State> WindowState::SetStateObject(
241 std::unique_ptr<WindowState::State> new_state) { 240 std::unique_ptr<WindowState::State> new_state) {
242 current_state_->DetachState(this); 241 current_state_->DetachState(this);
243 std::unique_ptr<WindowState::State> old_object = std::move(current_state_); 242 std::unique_ptr<WindowState::State> old_object = std::move(current_state_);
244 current_state_ = std::move(new_state); 243 current_state_ = std::move(new_state);
245 current_state_->AttachState(this, old_object.get()); 244 current_state_->AttachState(this, old_object.get());
246 return old_object; 245 return old_object;
247 } 246 }
248 247
249 void WindowState::SetPreAutoManageWindowBounds( 248 void WindowState::SetPreAutoManageWindowBounds(const gfx::Rect& bounds) {
250 const gfx::Rect& bounds) {
251 pre_auto_manage_window_bounds_.reset(new gfx::Rect(bounds)); 249 pre_auto_manage_window_bounds_.reset(new gfx::Rect(bounds));
252 } 250 }
253 251
254 void WindowState::AddObserver(WindowStateObserver* observer) { 252 void WindowState::AddObserver(WindowStateObserver* observer) {
255 observer_list_.AddObserver(observer); 253 observer_list_.AddObserver(observer);
256 } 254 }
257 255
258 void WindowState::RemoveObserver(WindowStateObserver* observer) { 256 void WindowState::RemoveObserver(WindowStateObserver* observer) {
259 observer_list_.RemoveObserver(observer); 257 observer_list_.RemoveObserver(observer);
260 } 258 }
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 current_state_(new DefaultState(ToWindowStateType(GetShowState()))) {} 305 current_state_(new DefaultState(ToWindowStateType(GetShowState()))) {}
308 306
309 bool WindowState::GetAlwaysOnTop() const { 307 bool WindowState::GetAlwaysOnTop() const {
310 return window_->IsAlwaysOnTop(); 308 return window_->IsAlwaysOnTop();
311 } 309 }
312 310
313 ui::WindowShowState WindowState::GetShowState() const { 311 ui::WindowShowState WindowState::GetShowState() const {
314 return window_->GetShowState(); 312 return window_->GetShowState();
315 } 313 }
316 314
317 void WindowState::SetBoundsInScreen( 315 void WindowState::SetBoundsInScreen(const gfx::Rect& bounds_in_screen) {
318 const gfx::Rect& bounds_in_screen) {
319 gfx::Rect bounds_in_parent = 316 gfx::Rect bounds_in_parent =
320 window_->GetParent()->ConvertRectFromScreen(bounds_in_screen); 317 window_->GetParent()->ConvertRectFromScreen(bounds_in_screen);
321 window_->SetBounds(bounds_in_parent); 318 window_->SetBounds(bounds_in_parent);
322 } 319 }
323 320
324 void WindowState::AdjustSnappedBounds(gfx::Rect* bounds) { 321 void WindowState::AdjustSnappedBounds(gfx::Rect* bounds) {
325 if (is_dragged() || !IsSnapped()) 322 if (is_dragged() || !IsSnapped())
326 return; 323 return;
327 gfx::Rect maximized_bounds = GetMaximizedWindowBoundsInParent(window_); 324 gfx::Rect maximized_bounds = GetMaximizedWindowBoundsInParent(window_);
328 if (GetStateType() == WINDOW_STATE_TYPE_LEFT_SNAPPED) 325 if (GetStateType() == WINDOW_STATE_TYPE_LEFT_SNAPPED)
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 if (!window_->GetTargetVisibility()) { 386 if (!window_->GetTargetVisibility()) {
390 SetBoundsConstrained(new_bounds); 387 SetBoundsConstrained(new_bounds);
391 return; 388 return;
392 } 389 }
393 390
394 window_->SetBoundsDirectCrossFade(new_bounds); 391 window_->SetBoundsDirectCrossFade(new_bounds);
395 } 392 }
396 393
397 } // namespace wm 394 } // namespace wm
398 } // namespace ash 395 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/common/window_state.h ('k') | ash/wm/common/window_state_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698