Chromium Code Reviews| 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, int event_flags) { |
|
oshima
2012/09/18 23:10:15
can you specify the coordinates in name?
mazda
2012/09/18 23:44:57
Done.
| |
| 126 std::pair<aura::RootWindow*, gfx::Point> actual_location = | 126 last_mouse_location_ = location; |
| 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; | |
| 134 | |
| 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 | 127 |
| 142 int grid_size = event_flags & ui::EF_CONTROL_DOWN ? 0 : kScreenEdgeInset; | 128 int grid_size = event_flags & ui::EF_CONTROL_DOWN ? 0 : kScreenEdgeInset; |
| 143 gfx::Rect bounds = // in |window()->parent()|'s coordinates. | 129 gfx::Rect bounds = // in |window()->parent()|'s coordinates. |
| 144 CalculateBoundsForDrag(details_, location_in_parent); | 130 CalculateBoundsForDrag(details_, location); |
| 145 | 131 |
| 146 if (wm::IsWindowNormal(window())) | 132 if (wm::IsWindowNormal(window())) |
| 147 AdjustBoundsForMainWindow(&bounds, grid_size); | 133 AdjustBoundsForMainWindow(&bounds, grid_size); |
| 148 | 134 |
| 149 if (bounds != window()->bounds()) { | 135 if (bounds != window()->bounds()) { |
| 150 if (!did_move_or_resize_) { | 136 if (!did_move_or_resize_) { |
| 151 if (!details_.restore_bounds.IsEmpty()) | 137 if (!details_.restore_bounds.IsEmpty()) |
| 152 ClearRestoreBounds(window()); | 138 ClearRestoreBounds(window()); |
| 153 RestackWindows(); | 139 RestackWindows(); |
| 154 } | 140 } |
| 155 did_move_or_resize_ = true; | 141 did_move_or_resize_ = true; |
| 156 } | 142 } |
| 157 | 143 |
| 158 const bool in_original_root = (window()->GetRootWindow() == current_root); | 144 gfx::Point location_in_screen = location; |
| 145 wm::ConvertPointToScreen(window()->parent(), &location_in_screen); | |
| 146 const bool in_original_root = | |
| 147 wm::GetRootWindowAt(location_in_screen) == window()->GetRootWindow(); | |
| 159 // Hide a phantom window for snapping if the cursor is in another root window. | 148 // Hide a phantom window for snapping if the cursor is in another root window. |
| 160 if (in_original_root) { | 149 if (in_original_root) { |
| 161 UpdateSnapPhantomWindow(location_in_parent, bounds); | 150 UpdateSnapPhantomWindow(location, bounds); |
| 162 } else { | 151 } else { |
| 163 snap_type_ = SNAP_NONE; | 152 snap_type_ = SNAP_NONE; |
| 164 snap_phantom_window_controller_.reset(); | 153 snap_phantom_window_controller_.reset(); |
| 165 } | 154 } |
| 166 | 155 |
| 167 if (!attached_windows_.empty()) | 156 if (!attached_windows_.empty()) |
| 168 LayoutAttachedWindows(bounds); | 157 LayoutAttachedWindows(bounds); |
| 169 if (bounds != window()->bounds()) { | 158 if (bounds != window()->bounds()) { |
| 170 bool destroyed = false; | 159 bool destroyed = false; |
| 171 destroyed_ = &destroyed; | 160 destroyed_ = &destroyed; |
| (...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 655 gfx::Rect layer_bounds = layer_->bounds(); | 644 gfx::Rect layer_bounds = layer_->bounds(); |
| 656 layer_bounds.set_origin(gfx::Point(0, 0)); | 645 layer_bounds.set_origin(gfx::Point(0, 0)); |
| 657 layer_->SetBounds(layer_bounds); | 646 layer_->SetBounds(layer_bounds); |
| 658 layer_->SetVisible(false); | 647 layer_->SetVisible(false); |
| 659 // Detach it from the current container. | 648 // Detach it from the current container. |
| 660 layer_->parent()->Remove(layer_); | 649 layer_->parent()->Remove(layer_); |
| 661 } | 650 } |
| 662 | 651 |
| 663 } // namespace internal | 652 } // namespace internal |
| 664 } // namespace ash | 653 } // namespace ash |
| OLD | NEW |