| 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/window_resizer.h" | 5 #include "ash/wm/window_resizer.h" |
| 6 | 6 |
| 7 #include "ash/shell.h" | 7 #include "ash/shell.h" |
| 8 #include "ash/wm/root_window_event_filter.h" | 8 #include "ash/wm/root_window_event_filter.h" |
| 9 #include "ui/aura/client/aura_constants.h" | 9 #include "ui/aura/client/aura_constants.h" |
| 10 #include "ui/aura/root_window.h" | 10 #include "ui/aura/root_window.h" |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 return (location / grid_size + 1) * grid_size; | 99 return (location / grid_size + 1) * grid_size; |
| 100 } | 100 } |
| 101 | 101 |
| 102 gfx::Point ConvertPointToParent(aura::Window* window, | 102 gfx::Point ConvertPointToParent(aura::Window* window, |
| 103 const gfx::Point& point) { | 103 const gfx::Point& point) { |
| 104 gfx::Point result(point); | 104 gfx::Point result(point); |
| 105 aura::Window::ConvertPointToWindow(window, window->parent(), &result); | 105 aura::Window::ConvertPointToWindow(window, window->parent(), &result); |
| 106 return result; | 106 return result; |
| 107 } | 107 } |
| 108 | 108 |
| 109 bool IsNormalWindow(aura::Window* window) { | |
| 110 return window->GetProperty(aura::client::kShowStateKey) == | |
| 111 ui::SHOW_STATE_NORMAL || | |
| 112 window->GetProperty(aura::client::kShowStateKey) == | |
| 113 ui::SHOW_STATE_DEFAULT; | |
| 114 } | |
| 115 | |
| 116 } // namespace | 109 } // namespace |
| 117 | 110 |
| 118 // static | 111 // static |
| 119 const int WindowResizer::kBoundsChange_None = 0; | 112 const int WindowResizer::kBoundsChange_None = 0; |
| 120 // static | 113 // static |
| 121 const int WindowResizer::kBoundsChange_Repositions = 1; | 114 const int WindowResizer::kBoundsChange_Repositions = 1; |
| 122 // static | 115 // static |
| 123 const int WindowResizer::kBoundsChange_Resizes = 2; | 116 const int WindowResizer::kBoundsChange_Resizes = 2; |
| 124 | 117 |
| 125 // static | 118 // static |
| 126 const int WindowResizer::kBoundsChangeDirection_None = 0; | 119 const int WindowResizer::kBoundsChangeDirection_None = 0; |
| 127 // static | 120 // static |
| 128 const int WindowResizer::kBoundsChangeDirection_Horizontal = 1; | 121 const int WindowResizer::kBoundsChangeDirection_Horizontal = 1; |
| 129 // static | 122 // static |
| 130 const int WindowResizer::kBoundsChangeDirection_Vertical = 2; | 123 const int WindowResizer::kBoundsChangeDirection_Vertical = 2; |
| 131 | 124 |
| 132 WindowResizer::WindowResizer(aura::Window* window, | 125 WindowResizer::WindowResizer(aura::Window* window, |
| 133 const gfx::Point& location, | 126 const gfx::Point& location, |
| 134 int window_component, | 127 int window_component, |
| 135 int grid_size) | 128 int grid_size) |
| 136 : window_(window), | 129 : window_(window), |
| 137 initial_bounds_(window->bounds()), | 130 initial_bounds_(window->bounds()), |
| 138 initial_location_in_parent_(ConvertPointToParent(window, location)), | 131 initial_location_in_parent_(ConvertPointToParent(window, location)), |
| 139 window_component_(window_component), | 132 window_component_(window_component), |
| 140 bounds_change_(GetBoundsChangeForWindowComponent(window_component_)), | 133 bounds_change_(GetBoundsChangeForWindowComponent(window_component_)), |
| 141 position_change_direction_( | 134 position_change_direction_( |
| 142 GetPositionChangeDirectionForWindowComponent(window_component_)), | 135 GetPositionChangeDirectionForWindowComponent(window_component_)), |
| 143 size_change_direction_( | 136 size_change_direction_( |
| 144 GetSizeChangeDirectionForWindowComponent(window_component_)), | 137 GetSizeChangeDirectionForWindowComponent(window_component_)), |
| 145 is_resizable_(bounds_change_ != kBoundsChangeDirection_None && | 138 is_resizable_(bounds_change_ != kBoundsChangeDirection_None), |
| 146 IsNormalWindow(window)), | |
| 147 grid_size_(grid_size), | 139 grid_size_(grid_size), |
| 148 did_move_or_resize_(false), | 140 did_move_or_resize_(false), |
| 149 root_filter_(NULL) { | 141 root_filter_(NULL) { |
| 150 if (is_resizable_) { | 142 if (is_resizable_) { |
| 151 root_filter_ = Shell::GetInstance()->root_filter(); | 143 root_filter_ = Shell::GetInstance()->root_filter(); |
| 152 if (root_filter_) | 144 if (root_filter_) |
| 153 root_filter_->LockCursor(); | 145 root_filter_->LockCursor(); |
| 154 } | 146 } |
| 155 } | 147 } |
| 156 | 148 |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 355 int max_height = gfx::Screen::GetMonitorAreaNearestWindow(window_).height(); | 347 int max_height = gfx::Screen::GetMonitorAreaNearestWindow(window_).height(); |
| 356 if (height > max_height) { | 348 if (height > max_height) { |
| 357 height = max_height; | 349 height = max_height; |
| 358 *delta_y = -y_multiplier * (initial_bounds_.height() - max_height); | 350 *delta_y = -y_multiplier * (initial_bounds_.height() - max_height); |
| 359 } | 351 } |
| 360 } | 352 } |
| 361 return height; | 353 return height; |
| 362 } | 354 } |
| 363 | 355 |
| 364 } // namespace aura | 356 } // namespace aura |
| OLD | NEW |