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" |
27 #include "ui/wm/core/window_util.h" | 28 #include "ui/wm/core/window_util.h" |
28 | 29 |
29 namespace ash { | 30 namespace ash { |
30 namespace wm { | 31 namespace wm { |
31 | 32 |
32 namespace { | 33 namespace { |
33 | 34 |
34 // A tentative class to set the bounds on the window. | 35 // A tentative class to set the bounds on the window. |
35 // TODO(oshima): Once all logic is cleaned up, move this to the real layout | 36 // TODO(oshima): Once all logic is cleaned up, move this to the real layout |
36 // manager with proper friendship. | 37 // manager with proper friendship. |
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
350 OnPreWindowStateTypeChange(this, old_window_state_type)); | 351 OnPreWindowStateTypeChange(this, old_window_state_type)); |
351 } | 352 } |
352 | 353 |
353 void WindowState::NotifyPostStateTypeChange( | 354 void WindowState::NotifyPostStateTypeChange( |
354 WindowStateType old_window_state_type) { | 355 WindowStateType old_window_state_type) { |
355 FOR_EACH_OBSERVER(WindowStateObserver, observer_list_, | 356 FOR_EACH_OBSERVER(WindowStateObserver, observer_list_, |
356 OnPostWindowStateTypeChange(this, old_window_state_type)); | 357 OnPostWindowStateTypeChange(this, old_window_state_type)); |
357 } | 358 } |
358 | 359 |
359 void WindowState::SetBoundsDirect(const gfx::Rect& bounds) { | 360 void WindowState::SetBoundsDirect(const gfx::Rect& bounds) { |
360 BoundsSetter().SetBounds(window_, bounds); | 361 gfx::Rect actual_new_bounds(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); |
361 } | 376 } |
362 | 377 |
363 void WindowState::SetBoundsConstrained(const gfx::Rect& bounds) { | 378 void WindowState::SetBoundsConstrained(const gfx::Rect& bounds) { |
364 gfx::Rect work_area_in_parent = | 379 gfx::Rect work_area_in_parent = |
365 ScreenUtil::GetDisplayWorkAreaBoundsInParent(window_); | 380 ScreenUtil::GetDisplayWorkAreaBoundsInParent(window_); |
366 gfx::Rect child_bounds(bounds); | 381 gfx::Rect child_bounds(bounds); |
367 AdjustBoundsSmallerThan(work_area_in_parent.size(), &child_bounds); | 382 AdjustBoundsSmallerThan(work_area_in_parent.size(), &child_bounds); |
368 SetBoundsDirect(child_bounds); | 383 SetBoundsDirect(child_bounds); |
369 } | 384 } |
370 | 385 |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
430 } | 445 } |
431 return settings; | 446 return settings; |
432 } | 447 } |
433 | 448 |
434 const WindowState* GetWindowState(const aura::Window* window) { | 449 const WindowState* GetWindowState(const aura::Window* window) { |
435 return GetWindowState(const_cast<aura::Window*>(window)); | 450 return GetWindowState(const_cast<aura::Window*>(window)); |
436 } | 451 } |
437 | 452 |
438 } // namespace wm | 453 } // namespace wm |
439 } // namespace ash | 454 } // namespace ash |
OLD | NEW |