| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/workspace/workspace_window_resizer.h" | 5 #include "ash/wm/workspace/workspace_window_resizer.h" |
| 6 | 6 |
| 7 #include "ash/wm/window_util.h" |
| 7 #include "ui/aura/window.h" | 8 #include "ui/aura/window.h" |
| 8 #include "ui/aura/window_delegate.h" | 9 #include "ui/aura/window_delegate.h" |
| 9 #include "ui/aura/window_property.h" | 10 #include "ui/aura/window_property.h" |
| 10 #include "ui/base/hit_test.h" | 11 #include "ui/base/hit_test.h" |
| 11 #include "ui/gfx/compositor/scoped_layer_animation_settings.h" | 12 #include "ui/gfx/compositor/scoped_layer_animation_settings.h" |
| 12 #include "ui/gfx/compositor/layer.h" | 13 #include "ui/gfx/compositor/layer.h" |
| 13 #include "ui/gfx/screen.h" | 14 #include "ui/gfx/screen.h" |
| 14 #include "ui/gfx/transform.h" | 15 #include "ui/gfx/transform.h" |
| 15 | 16 |
| 16 DECLARE_WINDOW_PROPERTY_TYPE(int) | 17 DECLARE_WINDOW_PROPERTY_TYPE(int) |
| 17 | 18 |
| 18 namespace ash { | 19 namespace ash { |
| 19 namespace internal { | 20 namespace internal { |
| 20 | 21 |
| 21 namespace { | 22 namespace { |
| 22 | 23 |
| 23 const aura::WindowProperty<int> kHeightBeforeObscuredProp = {0}; | 24 const aura::WindowProperty<int> kHeightBeforeObscuredProp = {0}; |
| 24 const aura::WindowProperty<int>* const kHeightBeforeObscuredKey = | 25 const aura::WindowProperty<int>* const kHeightBeforeObscuredKey = |
| 25 &kHeightBeforeObscuredProp; | 26 &kHeightBeforeObscuredProp; |
| 26 | 27 |
| 27 } // namespace | 28 } // namespace |
| 28 | 29 |
| 29 WorkspaceWindowResizer::WorkspaceWindowResizer(aura::Window* window, | 30 WorkspaceWindowResizer::WorkspaceWindowResizer(aura::Window* window, |
| 30 const gfx::Point& location, | 31 const gfx::Point& location, |
| 31 int window_component, | 32 int window_component, |
| 32 int grid_size) | 33 int grid_size) |
| 33 : WindowResizer(window, location, window_component, grid_size) { | 34 : WindowResizer(window, location, window_component, grid_size), |
| 35 constrain_size_(wm::IsWindowNormal(window)) { |
| 34 if (is_resizable() && GetHeightBeforeObscured(window) && | 36 if (is_resizable() && GetHeightBeforeObscured(window) && |
| 37 constrain_size_ && |
| 35 (!WindowTouchesBottomOfScreen() || | 38 (!WindowTouchesBottomOfScreen() || |
| 36 bounds_change() != kBoundsChange_Repositions)) { | 39 bounds_change() != kBoundsChange_Repositions)) { |
| 37 ClearHeightBeforeObscured(window); | 40 ClearHeightBeforeObscured(window); |
| 38 } | 41 } |
| 39 } | 42 } |
| 40 | 43 |
| 41 WorkspaceWindowResizer::~WorkspaceWindowResizer() { | 44 WorkspaceWindowResizer::~WorkspaceWindowResizer() { |
| 42 } | 45 } |
| 43 | 46 |
| 44 gfx::Rect WorkspaceWindowResizer::GetBoundsForDrag(const gfx::Point& location) { | 47 gfx::Rect WorkspaceWindowResizer::GetBoundsForDrag(const gfx::Point& location) { |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 void WorkspaceWindowResizer::ClearHeightBeforeObscured(aura::Window* window) { | 80 void WorkspaceWindowResizer::ClearHeightBeforeObscured(aura::Window* window) { |
| 78 window->SetProperty(kHeightBeforeObscuredKey, 0); | 81 window->SetProperty(kHeightBeforeObscuredKey, 0); |
| 79 } | 82 } |
| 80 | 83 |
| 81 // static | 84 // static |
| 82 int WorkspaceWindowResizer::GetHeightBeforeObscured(aura::Window* window) { | 85 int WorkspaceWindowResizer::GetHeightBeforeObscured(aura::Window* window) { |
| 83 return window->GetProperty(kHeightBeforeObscuredKey); | 86 return window->GetProperty(kHeightBeforeObscuredKey); |
| 84 } | 87 } |
| 85 | 88 |
| 86 void WorkspaceWindowResizer::AdjustBounds(gfx::Rect* bounds) const { | 89 void WorkspaceWindowResizer::AdjustBounds(gfx::Rect* bounds) const { |
| 90 if (!constrain_size_) |
| 91 return; |
| 92 |
| 87 gfx::Rect work_area(gfx::Screen::GetMonitorWorkAreaNearestWindow(window())); | 93 gfx::Rect work_area(gfx::Screen::GetMonitorWorkAreaNearestWindow(window())); |
| 88 if (bounds->bottom() < work_area.bottom()) { | 94 if (bounds->bottom() < work_area.bottom()) { |
| 89 int height = GetHeightBeforeObscured(window()); | 95 int height = GetHeightBeforeObscured(window()); |
| 90 if (!height) | 96 if (!height) |
| 91 return; | 97 return; |
| 92 height = std::max(bounds->height(), height); | 98 height = std::max(bounds->height(), height); |
| 93 bounds->set_height(std::min(work_area.bottom() - bounds->y(), height)); | 99 bounds->set_height(std::min(work_area.bottom() - bounds->y(), height)); |
| 94 return; | 100 return; |
| 95 } | 101 } |
| 96 | 102 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 108 } | 114 } |
| 109 } | 115 } |
| 110 | 116 |
| 111 bool WorkspaceWindowResizer::WindowTouchesBottomOfScreen() const { | 117 bool WorkspaceWindowResizer::WindowTouchesBottomOfScreen() const { |
| 112 gfx::Rect work_area(gfx::Screen::GetMonitorWorkAreaNearestWindow(window())); | 118 gfx::Rect work_area(gfx::Screen::GetMonitorWorkAreaNearestWindow(window())); |
| 113 return window()->bounds().bottom() == work_area.bottom(); | 119 return window()->bounds().bottom() == work_area.bottom(); |
| 114 } | 120 } |
| 115 | 121 |
| 116 } // namespace internal | 122 } // namespace internal |
| 117 } // namespace ash | 123 } // namespace ash |
| OLD | NEW |