| 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 <algorithm> | 7 #include <algorithm> |
| 8 #include <cmath> | 8 #include <cmath> |
| 9 #include <utility> | 9 #include <utility> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 WorkspaceWindowResizer* WorkspaceWindowResizer::Create( | 115 WorkspaceWindowResizer* WorkspaceWindowResizer::Create( |
| 116 aura::Window* window, | 116 aura::Window* window, |
| 117 const gfx::Point& location_in_parent, | 117 const gfx::Point& location_in_parent, |
| 118 int window_component, | 118 int window_component, |
| 119 const std::vector<aura::Window*>& attached_windows) { | 119 const std::vector<aura::Window*>& attached_windows) { |
| 120 Details details(window, location_in_parent, window_component); | 120 Details details(window, location_in_parent, window_component); |
| 121 return details.is_resizable ? | 121 return details.is_resizable ? |
| 122 new WorkspaceWindowResizer(details, attached_windows) : NULL; | 122 new WorkspaceWindowResizer(details, attached_windows) : NULL; |
| 123 } | 123 } |
| 124 | 124 |
| 125 void WorkspaceWindowResizer::Drag(const gfx::Point& location, int event_flags) { | 125 void WorkspaceWindowResizer::Drag(const gfx::Point& location_in_parent, |
| 126 std::pair<aura::RootWindow*, gfx::Point> actual_location = | 126 int event_flags) { |
| 127 wm::GetRootWindowRelativeToWindow(window()->parent(), location); | |
| 128 aura::RootWindow* current_root = actual_location.first; | |
| 129 gfx::Point location_in_parent = actual_location.second; | |
| 130 aura::Window::ConvertPointToTarget(current_root, | |
| 131 window()->parent(), | |
| 132 &location_in_parent); | |
| 133 last_mouse_location_ = location_in_parent; | 127 last_mouse_location_ = location_in_parent; |
| 134 | 128 |
| 135 // Do not use |location| below this point, use |location_in_parent| instead. | |
| 136 // When the pointer is on |window()->GetRootWindow()|, |location| and | |
| 137 // |location_in_parent| have the same value and both of them are in | |
| 138 // |window()->parent()|'s coordinates, but once the pointer enters the | |
| 139 // other root window, you will see an unexpected value on the former. See | |
| 140 // comments in wm::GetRootWindowRelativeToWindow() for details. | |
| 141 | |
| 142 int grid_size = event_flags & ui::EF_CONTROL_DOWN ? 0 : kScreenEdgeInset; | 129 int grid_size = event_flags & ui::EF_CONTROL_DOWN ? 0 : kScreenEdgeInset; |
| 143 gfx::Rect bounds = // in |window()->parent()|'s coordinates. | 130 gfx::Rect bounds = // in |window()->parent()|'s coordinates. |
| 144 CalculateBoundsForDrag(details_, location_in_parent); | 131 CalculateBoundsForDrag(details_, location_in_parent); |
| 145 | 132 |
| 146 if (wm::IsWindowNormal(window())) | 133 if (wm::IsWindowNormal(window())) |
| 147 AdjustBoundsForMainWindow(&bounds, grid_size); | 134 AdjustBoundsForMainWindow(&bounds, grid_size); |
| 148 | 135 |
| 149 if (bounds != window()->bounds()) { | 136 if (bounds != window()->bounds()) { |
| 150 if (!did_move_or_resize_) { | 137 if (!did_move_or_resize_) { |
| 151 if (!details_.restore_bounds.IsEmpty()) | 138 if (!details_.restore_bounds.IsEmpty()) |
| 152 ClearRestoreBounds(window()); | 139 ClearRestoreBounds(window()); |
| 153 RestackWindows(); | 140 RestackWindows(); |
| 154 } | 141 } |
| 155 did_move_or_resize_ = true; | 142 did_move_or_resize_ = true; |
| 156 } | 143 } |
| 157 | 144 |
| 158 const bool in_original_root = (window()->GetRootWindow() == current_root); | 145 gfx::Point location_in_screen = location_in_parent; |
| 146 wm::ConvertPointToScreen(window()->parent(), &location_in_screen); |
| 147 const bool in_original_root = |
| 148 wm::GetRootWindowAt(location_in_screen) == window()->GetRootWindow(); |
| 159 // Hide a phantom window for snapping if the cursor is in another root window. | 149 // Hide a phantom window for snapping if the cursor is in another root window. |
| 160 if (in_original_root) { | 150 if (in_original_root) { |
| 161 UpdateSnapPhantomWindow(location_in_parent, bounds); | 151 UpdateSnapPhantomWindow(location_in_parent, bounds); |
| 162 } else { | 152 } else { |
| 163 snap_type_ = SNAP_NONE; | 153 snap_type_ = SNAP_NONE; |
| 164 snap_phantom_window_controller_.reset(); | 154 snap_phantom_window_controller_.reset(); |
| 165 } | 155 } |
| 166 | 156 |
| 167 if (!attached_windows_.empty()) | 157 if (!attached_windows_.empty()) |
| 168 LayoutAttachedWindows(bounds); | 158 LayoutAttachedWindows(bounds); |
| (...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 655 gfx::Rect layer_bounds = layer_->bounds(); | 645 gfx::Rect layer_bounds = layer_->bounds(); |
| 656 layer_bounds.set_origin(gfx::Point(0, 0)); | 646 layer_bounds.set_origin(gfx::Point(0, 0)); |
| 657 layer_->SetBounds(layer_bounds); | 647 layer_->SetBounds(layer_bounds); |
| 658 layer_->SetVisible(false); | 648 layer_->SetVisible(false); |
| 659 // Detach it from the current container. | 649 // Detach it from the current container. |
| 660 layer_->parent()->Remove(layer_); | 650 layer_->parent()->Remove(layer_); |
| 661 } | 651 } |
| 662 | 652 |
| 663 } // namespace internal | 653 } // namespace internal |
| 664 } // namespace ash | 654 } // namespace ash |
| OLD | NEW |