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/shell_window_ids.h" | 9 #include "ash/shell_window_ids.h" |
10 #include "ash/wm/coordinate_conversion.h" | 10 #include "ash/wm/coordinate_conversion.h" |
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
256 // be still hit by the cursor. | 256 // be still hit by the cursor. |
257 if (details.initial_location_in_parent.x() > | 257 if (details.initial_location_in_parent.x() > |
258 details.initial_bounds_in_parent.x() + details.restore_bounds.width()) | 258 details.initial_bounds_in_parent.x() + details.restore_bounds.width()) |
259 new_bounds.set_x(location.x() - details.restore_bounds.width() / 2); | 259 new_bounds.set_x(location.x() - details.restore_bounds.width() / 2); |
260 } | 260 } |
261 | 261 |
262 // Make sure that |new_bounds| doesn't leave any of the displays. Note that | 262 // Make sure that |new_bounds| doesn't leave any of the displays. Note that |
263 // the |work_area| above isn't good for this check since it is the work area | 263 // the |work_area| above isn't good for this check since it is the work area |
264 // for the current display but the window can move to a different one. | 264 // for the current display but the window can move to a different one. |
265 aura::Window* parent = details.window->parent(); | 265 aura::Window* parent = details.window->parent(); |
266 gfx::Rect new_bounds_in_screen = | 266 gfx::Point passed_location_in_screen(passed_location); |
267 ScreenAsh::ConvertRectToScreen(parent, new_bounds); | 267 wm::ConvertPointToScreen(parent, &passed_location_in_screen); |
| 268 gfx::Rect near_passed_location(passed_location_in_screen, gfx::Size()); |
| 269 // Use a pointer location (matching the logic in DragWindowResizer) to |
| 270 // calculate the target display after the drag. |
268 const gfx::Display& display = | 271 const gfx::Display& display = |
269 Shell::GetScreen()->GetDisplayMatching(new_bounds_in_screen); | 272 Shell::GetScreen()->GetDisplayMatching(near_passed_location); |
270 aura::Window* dock_container = Shell::GetContainer( | 273 aura::Window* dock_container = Shell::GetContainer( |
271 wm::GetRootWindowMatching(new_bounds_in_screen), | 274 wm::GetRootWindowMatching(near_passed_location), |
272 internal::kShellWindowId_DockedContainer); | 275 internal::kShellWindowId_DockedContainer); |
273 internal::DockedWindowLayoutManager* dock_layout = | 276 internal::DockedWindowLayoutManager* dock_layout = |
274 static_cast<internal::DockedWindowLayoutManager*>( | 277 static_cast<internal::DockedWindowLayoutManager*>( |
275 dock_container->layout_manager()); | 278 dock_container->layout_manager()); |
276 | 279 |
277 gfx::Rect screen_work_area = display.work_area(); | 280 gfx::Rect screen_work_area = display.work_area(); |
278 screen_work_area.Union(dock_layout->docked_bounds()); | 281 screen_work_area.Union(dock_layout->docked_bounds()); |
279 screen_work_area.Inset(kMinimumOnScreenArea, 0); | 282 screen_work_area.Inset(kMinimumOnScreenArea, 0); |
| 283 gfx::Rect new_bounds_in_screen = |
| 284 ScreenAsh::ConvertRectToScreen(parent, new_bounds); |
280 if (!screen_work_area.Intersects(new_bounds_in_screen)) { | 285 if (!screen_work_area.Intersects(new_bounds_in_screen)) { |
281 // Make sure that the x origin does not leave the current display. | 286 // Make sure that the x origin does not leave the current display. |
282 new_bounds_in_screen.set_x( | 287 new_bounds_in_screen.set_x( |
283 std::max(screen_work_area.x() - new_bounds.width(), | 288 std::max(screen_work_area.x() - new_bounds.width(), |
284 std::min(screen_work_area.right(), | 289 std::min(screen_work_area.right(), |
285 new_bounds_in_screen.x()))); | 290 new_bounds_in_screen.x()))); |
286 new_bounds = | 291 new_bounds = |
287 ScreenAsh::ConvertRectFromScreen(parent, new_bounds_in_screen); | 292 ScreenAsh::ConvertRectFromScreen(parent, new_bounds_in_screen); |
288 } | 293 } |
289 } | 294 } |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
418 if (height > max_height) { | 423 if (height > max_height) { |
419 height = max_height; | 424 height = max_height; |
420 *delta_y = -y_multiplier * (details.initial_bounds_in_parent.height() - | 425 *delta_y = -y_multiplier * (details.initial_bounds_in_parent.height() - |
421 max_height); | 426 max_height); |
422 } | 427 } |
423 } | 428 } |
424 return height; | 429 return height; |
425 } | 430 } |
426 | 431 |
427 } // namespace aura | 432 } // namespace aura |
OLD | NEW |