| OLD | NEW |
| 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" |
| 11 #include "ash/wm/default_state.h" | 11 #include "ash/wm/default_state.h" |
| 12 #include "ash/wm/window_animations.h" | 12 #include "ash/wm/window_animations.h" |
| 13 #include "ash/wm/window_properties.h" | 13 #include "ash/wm/window_properties.h" |
| 14 #include "ash/wm/window_state_delegate.h" | 14 #include "ash/wm/window_state_delegate.h" |
| 15 #include "ash/wm/window_state_observer.h" | 15 #include "ash/wm/window_state_observer.h" |
| 16 #include "ash/wm/window_util.h" | 16 #include "ash/wm/window_util.h" |
| 17 #include "ash/wm/wm_event.h" | 17 #include "ash/wm/wm_event.h" |
| 18 #include "base/auto_reset.h" | 18 #include "base/auto_reset.h" |
| 19 #include "base/command_line.h" | 19 #include "base/command_line.h" |
| 20 #include "ui/aura/client/aura_constants.h" | 20 #include "ui/aura/client/aura_constants.h" |
| 21 #include "ui/aura/layout_manager.h" | 21 #include "ui/aura/layout_manager.h" |
| 22 #include "ui/aura/window.h" | 22 #include "ui/aura/window.h" |
| 23 #include "ui/aura/window_delegate.h" | 23 #include "ui/aura/window_delegate.h" |
| 24 #include "ui/compositor/layer_tree_owner.h" | 24 #include "ui/compositor/layer_tree_owner.h" |
| 25 #include "ui/compositor/scoped_layer_animation_settings.h" | 25 #include "ui/compositor/scoped_layer_animation_settings.h" |
| 26 #include "ui/gfx/display.h" | 26 #include "ui/gfx/display.h" |
| 27 #include "ui/gfx/screen.h" | |
| 28 #include "ui/wm/core/window_util.h" | 27 #include "ui/wm/core/window_util.h" |
| 29 | 28 |
| 30 namespace ash { | 29 namespace ash { |
| 31 namespace wm { | 30 namespace wm { |
| 32 | 31 |
| 33 namespace { | 32 namespace { |
| 34 | 33 |
| 35 // A tentative class to set the bounds on the window. | 34 // A tentative class to set the bounds on the window. |
| 36 // TODO(oshima): Once all logic is cleaned up, move this to the real layout | 35 // TODO(oshima): Once all logic is cleaned up, move this to the real layout |
| 37 // manager with proper friendship. | 36 // manager with proper friendship. |
| (...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 351 OnPreWindowStateTypeChange(this, old_window_state_type)); | 350 OnPreWindowStateTypeChange(this, old_window_state_type)); |
| 352 } | 351 } |
| 353 | 352 |
| 354 void WindowState::NotifyPostStateTypeChange( | 353 void WindowState::NotifyPostStateTypeChange( |
| 355 WindowStateType old_window_state_type) { | 354 WindowStateType old_window_state_type) { |
| 356 FOR_EACH_OBSERVER(WindowStateObserver, observer_list_, | 355 FOR_EACH_OBSERVER(WindowStateObserver, observer_list_, |
| 357 OnPostWindowStateTypeChange(this, old_window_state_type)); | 356 OnPostWindowStateTypeChange(this, old_window_state_type)); |
| 358 } | 357 } |
| 359 | 358 |
| 360 void WindowState::SetBoundsDirect(const gfx::Rect& bounds) { | 359 void WindowState::SetBoundsDirect(const gfx::Rect& bounds) { |
| 361 gfx::Rect actual_new_bounds(bounds); | 360 BoundsSetter().SetBounds(window_, bounds); |
| 362 // Ensure we don't go smaller than our minimum bounds in "normal" window | |
| 363 // modes | |
| 364 if (window_->delegate() && !IsMaximized() && !IsFullscreen()) { | |
| 365 // Get the minimum usable size of the minimum size and the screen size. | |
| 366 gfx::Size min_size = window_->delegate()->GetMinimumSize(); | |
| 367 min_size.SetToMin(gfx::Screen::GetScreenFor( | |
| 368 window_)->GetDisplayNearestWindow(window_).work_area().size()); | |
| 369 | |
| 370 actual_new_bounds.set_width( | |
| 371 std::max(min_size.width(), actual_new_bounds.width())); | |
| 372 actual_new_bounds.set_height( | |
| 373 std::max(min_size.height(), actual_new_bounds.height())); | |
| 374 } | |
| 375 BoundsSetter().SetBounds(window_, actual_new_bounds); | |
| 376 } | 361 } |
| 377 | 362 |
| 378 void WindowState::SetBoundsConstrained(const gfx::Rect& bounds) { | 363 void WindowState::SetBoundsConstrained(const gfx::Rect& bounds) { |
| 379 gfx::Rect work_area_in_parent = | 364 gfx::Rect work_area_in_parent = |
| 380 ScreenUtil::GetDisplayWorkAreaBoundsInParent(window_); | 365 ScreenUtil::GetDisplayWorkAreaBoundsInParent(window_); |
| 381 gfx::Rect child_bounds(bounds); | 366 gfx::Rect child_bounds(bounds); |
| 382 AdjustBoundsSmallerThan(work_area_in_parent.size(), &child_bounds); | 367 AdjustBoundsSmallerThan(work_area_in_parent.size(), &child_bounds); |
| 383 SetBoundsDirect(child_bounds); | 368 SetBoundsDirect(child_bounds); |
| 384 } | 369 } |
| 385 | 370 |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 445 } | 430 } |
| 446 return settings; | 431 return settings; |
| 447 } | 432 } |
| 448 | 433 |
| 449 const WindowState* GetWindowState(const aura::Window* window) { | 434 const WindowState* GetWindowState(const aura::Window* window) { |
| 450 return GetWindowState(const_cast<aura::Window*>(window)); | 435 return GetWindowState(const_cast<aura::Window*>(window)); |
| 451 } | 436 } |
| 452 | 437 |
| 453 } // namespace wm | 438 } // namespace wm |
| 454 } // namespace ash | 439 } // namespace ash |
| OLD | NEW |