| 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/common/wm/workspace/workspace_window_resizer.h" | 5 #include "ash/common/wm/workspace/workspace_window_resizer.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <cmath> | 8 #include <cmath> |
| 9 #include <utility> | 9 #include <utility> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "ash/common/ash_switches.h" | 12 #include "ash/common/ash_switches.h" |
| 13 #include "ash/common/metrics/user_metrics_action.h" | 13 #include "ash/common/metrics/user_metrics_action.h" |
| 14 #include "ash/common/wm/default_window_resizer.h" | 14 #include "ash/common/wm/default_window_resizer.h" |
| 15 #include "ash/common/wm/dock/docked_window_layout_manager.h" | 15 #include "ash/common/wm/dock/docked_window_layout_manager.h" |
| 16 #include "ash/common/wm/dock/docked_window_resizer.h" | 16 #include "ash/common/wm/dock/docked_window_resizer.h" |
| 17 #include "ash/common/wm/panels/panel_window_resizer.h" | 17 #include "ash/common/wm/panels/panel_window_resizer.h" |
| 18 #include "ash/common/wm/window_positioning_utils.h" | 18 #include "ash/common/wm/window_positioning_utils.h" |
| 19 #include "ash/common/wm/window_state.h" | 19 #include "ash/common/wm/window_state.h" |
| 20 #include "ash/common/wm/wm_event.h" | 20 #include "ash/common/wm/wm_event.h" |
| 21 #include "ash/common/wm/wm_screen_util.h" | 21 #include "ash/common/wm/wm_screen_util.h" |
| 22 #include "ash/common/wm/workspace/phantom_window_controller.h" | 22 #include "ash/common/wm/workspace/phantom_window_controller.h" |
| 23 #include "ash/common/wm/workspace/two_step_edge_cycler.h" | 23 #include "ash/common/wm/workspace/two_step_edge_cycler.h" |
| 24 #include "ash/common/wm_lookup.h" | |
| 25 #include "ash/common/wm_shell.h" | 24 #include "ash/common/wm_shell.h" |
| 26 #include "ash/common/wm_window.h" | 25 #include "ash/common/wm_window.h" |
| 27 #include "ash/public/cpp/shell_window_ids.h" | 26 #include "ash/public/cpp/shell_window_ids.h" |
| 28 #include "ash/root_window_controller.h" | 27 #include "ash/root_window_controller.h" |
| 28 #include "ash/shell.h" |
| 29 #include "base/memory/ptr_util.h" | 29 #include "base/memory/ptr_util.h" |
| 30 #include "base/memory/weak_ptr.h" | 30 #include "base/memory/weak_ptr.h" |
| 31 #include "ui/base/hit_test.h" | 31 #include "ui/base/hit_test.h" |
| 32 #include "ui/compositor/layer.h" | 32 #include "ui/compositor/layer.h" |
| 33 #include "ui/display/display.h" | 33 #include "ui/display/display.h" |
| 34 #include "ui/display/screen.h" | 34 #include "ui/display/screen.h" |
| 35 #include "ui/gfx/transform.h" | 35 #include "ui/gfx/transform.h" |
| 36 #include "ui/wm/public/window_types.h" | 36 #include "ui/wm/public/window_types.h" |
| 37 | 37 |
| 38 namespace ash { | 38 namespace ash { |
| (...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 358 | 358 |
| 359 gfx::Point location_in_screen = | 359 gfx::Point location_in_screen = |
| 360 GetTarget()->GetParent()->ConvertPointToScreen(location_in_parent); | 360 GetTarget()->GetParent()->ConvertPointToScreen(location_in_parent); |
| 361 | 361 |
| 362 WmWindow* root = nullptr; | 362 WmWindow* root = nullptr; |
| 363 display::Display display = | 363 display::Display display = |
| 364 display::Screen::GetScreen()->GetDisplayNearestPoint(location_in_screen); | 364 display::Screen::GetScreen()->GetDisplayNearestPoint(location_in_screen); |
| 365 // Track the last screen that the pointer was on to keep the snap phantom | 365 // Track the last screen that the pointer was on to keep the snap phantom |
| 366 // window there. | 366 // window there. |
| 367 if (display.bounds().Contains(location_in_screen)) { | 367 if (display.bounds().Contains(location_in_screen)) { |
| 368 root = WmLookup::Get() | 368 root = |
| 369 ->GetRootWindowControllerWithDisplayId(display.id()) | 369 Shell::GetRootWindowControllerWithDisplayId(display.id())->GetWindow(); |
| 370 ->GetWindow(); | |
| 371 } | 370 } |
| 372 if (!attached_windows_.empty()) | 371 if (!attached_windows_.empty()) |
| 373 LayoutAttachedWindows(&bounds); | 372 LayoutAttachedWindows(&bounds); |
| 374 if (bounds != GetTarget()->GetBounds()) { | 373 if (bounds != GetTarget()->GetBounds()) { |
| 375 // SetBounds needs to be called to update the layout which affects where the | 374 // SetBounds needs to be called to update the layout which affects where the |
| 376 // phantom window is drawn. Keep track if the window was destroyed during | 375 // phantom window is drawn. Keep track if the window was destroyed during |
| 377 // the drag and quit early if so. | 376 // the drag and quit early if so. |
| 378 base::WeakPtr<WorkspaceWindowResizer> resizer( | 377 base::WeakPtr<WorkspaceWindowResizer> resizer( |
| 379 weak_ptr_factory_.GetWeakPtr()); | 378 weak_ptr_factory_.GetWeakPtr()); |
| 380 GetTarget()->SetBounds(bounds); | 379 GetTarget()->SetBounds(bounds); |
| (...skipping 632 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1013 DCHECK(snapped_type == wm::WINDOW_STATE_TYPE_LEFT_SNAPPED || | 1012 DCHECK(snapped_type == wm::WINDOW_STATE_TYPE_LEFT_SNAPPED || |
| 1014 snapped_type == wm::WINDOW_STATE_TYPE_RIGHT_SNAPPED); | 1013 snapped_type == wm::WINDOW_STATE_TYPE_RIGHT_SNAPPED); |
| 1015 gfx::Rect snapped_bounds = wm::GetDisplayWorkAreaBoundsInParent(GetTarget()); | 1014 gfx::Rect snapped_bounds = wm::GetDisplayWorkAreaBoundsInParent(GetTarget()); |
| 1016 if (snapped_type == wm::WINDOW_STATE_TYPE_RIGHT_SNAPPED) | 1015 if (snapped_type == wm::WINDOW_STATE_TYPE_RIGHT_SNAPPED) |
| 1017 snapped_bounds.set_x(snapped_bounds.right() - bounds_in_parent.width()); | 1016 snapped_bounds.set_x(snapped_bounds.right() - bounds_in_parent.width()); |
| 1018 snapped_bounds.set_width(bounds_in_parent.width()); | 1017 snapped_bounds.set_width(bounds_in_parent.width()); |
| 1019 return bounds_in_parent == snapped_bounds; | 1018 return bounds_in_parent == snapped_bounds; |
| 1020 } | 1019 } |
| 1021 | 1020 |
| 1022 } // namespace ash | 1021 } // namespace ash |
| OLD | NEW |