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