| 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/screen_ash.h" | 7 #include "ash/screen_ash.h" |
| 8 #include "ash/shell.h" | 8 #include "ash/shell.h" |
| 9 #include "ash/wm/dock/dock_edge_types.h" |
| 9 #include "ash/wm/property_util.h" | 10 #include "ash/wm/property_util.h" |
| 10 #include "ash/wm/window_util.h" | 11 #include "ash/wm/window_util.h" |
| 11 #include "ui/aura/client/aura_constants.h" | 12 #include "ui/aura/client/aura_constants.h" |
| 12 #include "ui/aura/root_window.h" | 13 #include "ui/aura/root_window.h" |
| 13 #include "ui/aura/window.h" | 14 #include "ui/aura/window.h" |
| 14 #include "ui/aura/window_delegate.h" | 15 #include "ui/aura/window_delegate.h" |
| 15 #include "ui/base/hit_test.h" | 16 #include "ui/base/hit_test.h" |
| 16 #include "ui/base/ui_base_types.h" | 17 #include "ui/base/ui_base_types.h" |
| 17 #include "ui/compositor/scoped_layer_animation_settings.h" | 18 #include "ui/compositor/scoped_layer_animation_settings.h" |
| 18 #include "ui/gfx/display.h" | 19 #include "ui/gfx/display.h" |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 | 170 |
| 170 // static | 171 // static |
| 171 gfx::Rect WindowResizer::CalculateBoundsForDrag( | 172 gfx::Rect WindowResizer::CalculateBoundsForDrag( |
| 172 const Details& details, | 173 const Details& details, |
| 173 const gfx::Point& passed_location) { | 174 const gfx::Point& passed_location) { |
| 174 if (!details.is_resizable) | 175 if (!details.is_resizable) |
| 175 return details.initial_bounds_in_parent; | 176 return details.initial_bounds_in_parent; |
| 176 | 177 |
| 177 gfx::Point location = passed_location; | 178 gfx::Point location = passed_location; |
| 178 gfx::Rect work_area = | 179 gfx::Rect work_area = |
| 179 ScreenAsh::GetDisplayWorkAreaBoundsInParent(details.window); | 180 (GetDockEdges(details.window) == DOCK_EDGE_NONE) ? |
| 181 ScreenAsh::GetDisplayWorkAreaBoundsInParent(details.window) : |
| 182 ScreenAsh::GetDisplayBoundsInParent(details.window); |
| 180 | 183 |
| 181 int delta_x = location.x() - details.initial_location_in_parent.x(); | 184 int delta_x = location.x() - details.initial_location_in_parent.x(); |
| 182 int delta_y = location.y() - details.initial_location_in_parent.y(); | 185 int delta_y = location.y() - details.initial_location_in_parent.y(); |
| 183 | 186 |
| 184 // The minimize size constraint may limit how much we change the window | 187 // The minimize size constraint may limit how much we change the window |
| 185 // position. For example, dragging the left edge to the right should stop | 188 // position. For example, dragging the left edge to the right should stop |
| 186 // repositioning the window when the minimize size is reached. | 189 // repositioning the window when the minimize size is reached. |
| 187 gfx::Size size = GetSizeForDrag(details, &delta_x, &delta_y); | 190 gfx::Size size = GetSizeForDrag(details, &delta_x, &delta_y); |
| 188 gfx::Point origin = GetOriginForDrag(details, delta_x, delta_y); | 191 gfx::Point origin = GetOriginForDrag(details, delta_x, delta_y); |
| 189 gfx::Rect new_bounds(origin, size); | 192 gfx::Rect new_bounds(origin, size); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 } | 244 } |
| 242 | 245 |
| 243 // Make sure that |new_bounds| doesn't leave any of the displays. Note that | 246 // Make sure that |new_bounds| doesn't leave any of the displays. Note that |
| 244 // the |work_area| above isn't good for this check since it is the work area | 247 // the |work_area| above isn't good for this check since it is the work area |
| 245 // for the current display but the window can move to a different one. | 248 // for the current display but the window can move to a different one. |
| 246 aura::Window* parent = details.window->parent(); | 249 aura::Window* parent = details.window->parent(); |
| 247 gfx::Rect new_bounds_in_screen = | 250 gfx::Rect new_bounds_in_screen = |
| 248 ScreenAsh::ConvertRectToScreen(parent, new_bounds); | 251 ScreenAsh::ConvertRectToScreen(parent, new_bounds); |
| 249 const gfx::Display& display = | 252 const gfx::Display& display = |
| 250 Shell::GetScreen()->GetDisplayMatching(new_bounds_in_screen); | 253 Shell::GetScreen()->GetDisplayMatching(new_bounds_in_screen); |
| 251 gfx::Rect screen_work_area = display.work_area(); | 254 gfx::Rect screen_work_area; |
| 255 if (GetDockEdges(details.window) == DOCK_EDGE_NONE) |
| 256 screen_work_area = display.work_area(); |
| 257 else |
| 258 screen_work_area = display.bounds(); |
| 252 screen_work_area.Inset(kMinimumOnScreenArea, 0); | 259 screen_work_area.Inset(kMinimumOnScreenArea, 0); |
| 253 if (!screen_work_area.Intersects(new_bounds_in_screen)) { | 260 if (!screen_work_area.Intersects(new_bounds_in_screen)) { |
| 254 // Make sure that the x origin does not leave the current display. | 261 // Make sure that the x origin does not leave the current display. |
| 255 new_bounds_in_screen.set_x( | 262 new_bounds_in_screen.set_x( |
| 256 std::max(screen_work_area.x() - new_bounds.width(), | 263 std::max(screen_work_area.x() - new_bounds.width(), |
| 257 std::min(screen_work_area.right(), | 264 std::min(screen_work_area.right(), |
| 258 new_bounds_in_screen.x()))); | 265 new_bounds_in_screen.x()))); |
| 259 new_bounds = | 266 new_bounds = |
| 260 ScreenAsh::ConvertRectFromScreen(parent, new_bounds_in_screen); | 267 ScreenAsh::ConvertRectFromScreen(parent, new_bounds_in_screen); |
| 261 } | 268 } |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 363 if (height > max_height) { | 370 if (height > max_height) { |
| 364 height = max_height; | 371 height = max_height; |
| 365 *delta_y = -y_multiplier * (details.initial_bounds_in_parent.height() - | 372 *delta_y = -y_multiplier * (details.initial_bounds_in_parent.height() - |
| 366 max_height); | 373 max_height); |
| 367 } | 374 } |
| 368 } | 375 } |
| 369 return height; | 376 return height; |
| 370 } | 377 } |
| 371 | 378 |
| 372 } // namespace aura | 379 } // namespace aura |
| OLD | NEW |