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

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

Issue 314433003: ash: Make wm::WindowState's c'tor private. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merge Created 6 years, 6 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 | « ash/wm/window_state.h ('k') | no next file » | 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/window_state.h"
6 6
7 #include "ash/ash_switches.h" 7 #include "ash/ash_switches.h"
8 #include "ash/root_window_controller.h" 8 #include "ash/root_window_controller.h"
9 #include "ash/screen_util.h" 9 #include "ash/screen_util.h"
10 #include "ash/shell_window_ids.h" 10 #include "ash/shell_window_ids.h"
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 case ui::SHOW_STATE_DETACHED: 74 case ui::SHOW_STATE_DETACHED:
75 case ui::SHOW_STATE_END: 75 case ui::SHOW_STATE_END:
76 NOTREACHED() << "No WMEvent defined for the show state:" 76 NOTREACHED() << "No WMEvent defined for the show state:"
77 << requested_show_state; 77 << requested_show_state;
78 } 78 }
79 return WM_EVENT_NORMAL; 79 return WM_EVENT_NORMAL;
80 } 80 }
81 81
82 } // namespace 82 } // namespace
83 83
84 WindowState::WindowState(aura::Window* window)
85 : window_(window),
86 window_position_managed_(false),
87 bounds_changed_by_user_(false),
88 panel_attached_(true),
89 ignored_by_shelf_(false),
90 can_consume_system_keys_(false),
91 top_row_keys_are_function_keys_(false),
92 unminimize_to_restore_bounds_(false),
93 in_immersive_fullscreen_(false),
94 hide_shelf_when_fullscreen_(true),
95 minimum_visibility_(false),
96 can_be_dragged_(true),
97 ignore_property_change_(false),
98 current_state_(new DefaultState(ToWindowStateType(GetShowState()))) {
99 window_->AddObserver(this);
100 }
101
102 WindowState::~WindowState() { 84 WindowState::~WindowState() {
103 // WindowState is registered as an owned property of |window_|, and window 85 // WindowState is registered as an owned property of |window_|, and window
104 // unregisters all of its observers in its d'tor before destroying its 86 // unregisters all of its observers in its d'tor before destroying its
105 // properties. As a result, window_->RemoveObserver() doesn't need to (and 87 // properties. As a result, window_->RemoveObserver() doesn't need to (and
106 // shouldn't) be called here. 88 // shouldn't) be called here.
107 } 89 }
108 90
109 bool WindowState::HasDelegate() const { 91 bool WindowState::HasDelegate() const {
110 return delegate_; 92 return delegate_;
111 } 93 }
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 void WindowState::OnWindowPropertyChanged(aura::Window* window, 291 void WindowState::OnWindowPropertyChanged(aura::Window* window,
310 const void* key, 292 const void* key,
311 intptr_t old) { 293 intptr_t old) {
312 DCHECK_EQ(window, window_); 294 DCHECK_EQ(window, window_);
313 if (key == aura::client::kShowStateKey && !ignore_property_change_) { 295 if (key == aura::client::kShowStateKey && !ignore_property_change_) {
314 WMEvent event(WMEventTypeFromShowState(GetShowState())); 296 WMEvent event(WMEventTypeFromShowState(GetShowState()));
315 OnWMEvent(&event); 297 OnWMEvent(&event);
316 } 298 }
317 } 299 }
318 300
301 WindowState::WindowState(aura::Window* window)
302 : window_(window),
303 window_position_managed_(false),
304 bounds_changed_by_user_(false),
305 panel_attached_(true),
306 ignored_by_shelf_(false),
307 can_consume_system_keys_(false),
308 top_row_keys_are_function_keys_(false),
309 unminimize_to_restore_bounds_(false),
310 in_immersive_fullscreen_(false),
311 hide_shelf_when_fullscreen_(true),
312 minimum_visibility_(false),
313 can_be_dragged_(true),
314 ignore_property_change_(false),
315 current_state_(new DefaultState(ToWindowStateType(GetShowState()))) {
316 window_->AddObserver(this);
317 }
318
319 ui::WindowShowState WindowState::GetShowState() const {
320 return window_->GetProperty(aura::client::kShowStateKey);
321 }
322
319 void WindowState::SetBoundsInScreen( 323 void WindowState::SetBoundsInScreen(
320 const gfx::Rect& bounds_in_screen) { 324 const gfx::Rect& bounds_in_screen) {
321 gfx::Rect bounds_in_parent = 325 gfx::Rect bounds_in_parent =
322 ScreenUtil::ConvertRectFromScreen(window_->parent(), 326 ScreenUtil::ConvertRectFromScreen(window_->parent(),
323 bounds_in_screen); 327 bounds_in_screen);
324 window_->SetBounds(bounds_in_parent); 328 window_->SetBounds(bounds_in_parent);
325 } 329 }
326 330
327 ui::WindowShowState WindowState::GetShowState() const {
328 return window_->GetProperty(aura::client::kShowStateKey);
329 }
330
331 void WindowState::AdjustSnappedBounds(gfx::Rect* bounds) { 331 void WindowState::AdjustSnappedBounds(gfx::Rect* bounds) {
332 if (is_dragged() || !IsSnapped()) 332 if (is_dragged() || !IsSnapped())
333 return; 333 return;
334 gfx::Rect maximized_bounds = ScreenUtil::GetMaximizedWindowBoundsInParent( 334 gfx::Rect maximized_bounds = ScreenUtil::GetMaximizedWindowBoundsInParent(
335 window_); 335 window_);
336 if (GetStateType() == WINDOW_STATE_TYPE_LEFT_SNAPPED) 336 if (GetStateType() == WINDOW_STATE_TYPE_LEFT_SNAPPED)
337 bounds->set_x(maximized_bounds.x()); 337 bounds->set_x(maximized_bounds.x());
338 else if (GetStateType() == WINDOW_STATE_TYPE_RIGHT_SNAPPED) 338 else if (GetStateType() == WINDOW_STATE_TYPE_RIGHT_SNAPPED)
339 bounds->set_x(maximized_bounds.right() - bounds->width()); 339 bounds->set_x(maximized_bounds.right() - bounds->width());
340 bounds->set_y(maximized_bounds.y()); 340 bounds->set_y(maximized_bounds.y());
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
450 } 450 }
451 return settings; 451 return settings;
452 } 452 }
453 453
454 const WindowState* GetWindowState(const aura::Window* window) { 454 const WindowState* GetWindowState(const aura::Window* window) {
455 return GetWindowState(const_cast<aura::Window*>(window)); 455 return GetWindowState(const_cast<aura::Window*>(window));
456 } 456 }
457 457
458 } // namespace wm 458 } // namespace wm
459 } // namespace ash 459 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/window_state.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698