| 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 | 9 |
| 10 #include "ash/display/display_controller.h" | 10 #include "ash/display/display_controller.h" |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 // comments in wm::GetRootWindowRelativeToWindow() for details. | 117 // comments in wm::GetRootWindowRelativeToWindow() for details. |
| 118 | 118 |
| 119 int grid_size = event_flags & ui::EF_CONTROL_DOWN ? | 119 int grid_size = event_flags & ui::EF_CONTROL_DOWN ? |
| 120 0 : ash::Shell::GetInstance()->GetGridSize(); | 120 0 : ash::Shell::GetInstance()->GetGridSize(); |
| 121 gfx::Rect bounds = // in |window()->parent()|'s coordinates. | 121 gfx::Rect bounds = // in |window()->parent()|'s coordinates. |
| 122 CalculateBoundsForDrag(details_, location_in_parent, grid_size); | 122 CalculateBoundsForDrag(details_, location_in_parent, grid_size); |
| 123 | 123 |
| 124 if (wm::IsWindowNormal(window())) | 124 if (wm::IsWindowNormal(window())) |
| 125 AdjustBoundsForMainWindow(&bounds, grid_size); | 125 AdjustBoundsForMainWindow(&bounds, grid_size); |
| 126 if (bounds != window()->bounds()) { | 126 if (bounds != window()->bounds()) { |
| 127 if (!did_move_or_resize_) | 127 if (!did_move_or_resize_) { |
| 128 if (!details_.restore_bounds.IsEmpty()) |
| 129 ClearRestoreBounds(window()); |
| 128 RestackWindows(); | 130 RestackWindows(); |
| 131 } |
| 129 did_move_or_resize_ = true; | 132 did_move_or_resize_ = true; |
| 130 } | 133 } |
| 131 | 134 |
| 132 const bool in_original_root = (window()->GetRootWindow() == current_root); | 135 const bool in_original_root = (window()->GetRootWindow() == current_root); |
| 133 // Hide a phantom window for snapping if the cursor is in another root window. | 136 // Hide a phantom window for snapping if the cursor is in another root window. |
| 134 if (in_original_root) | 137 if (in_original_root) |
| 135 UpdateSnapPhantomWindow(location_in_parent, bounds, grid_size); | 138 UpdateSnapPhantomWindow(location_in_parent, bounds, grid_size); |
| 136 else | 139 else |
| 137 snap_phantom_window_controller_.reset(); | 140 snap_phantom_window_controller_.reset(); |
| 138 | 141 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 156 | 159 |
| 157 void WorkspaceWindowResizer::CompleteDrag(int event_flags) { | 160 void WorkspaceWindowResizer::CompleteDrag(int event_flags) { |
| 158 window()->layer()->SetOpacity(details_.initial_opacity); | 161 window()->layer()->SetOpacity(details_.initial_opacity); |
| 159 drag_phantom_window_controller_.reset(); | 162 drag_phantom_window_controller_.reset(); |
| 160 snap_phantom_window_controller_.reset(); | 163 snap_phantom_window_controller_.reset(); |
| 161 if (!did_move_or_resize_ || details_.window_component != HTCAPTION) | 164 if (!did_move_or_resize_ || details_.window_component != HTCAPTION) |
| 162 return; | 165 return; |
| 163 | 166 |
| 164 if (snap_type_ == SNAP_LEFT_EDGE || snap_type_ == SNAP_RIGHT_EDGE) { | 167 if (snap_type_ == SNAP_LEFT_EDGE || snap_type_ == SNAP_RIGHT_EDGE) { |
| 165 if (!GetRestoreBoundsInScreen(window())) | 168 if (!GetRestoreBoundsInScreen(window())) |
| 166 SetRestoreBoundsInParent(window(), details_.initial_bounds); | 169 SetRestoreBoundsInParent(window(), details_.restore_bounds.IsEmpty() ? |
| 170 details_.initial_bounds : |
| 171 details_.restore_bounds); |
| 167 window()->SetBounds(snap_sizer_->target_bounds()); | 172 window()->SetBounds(snap_sizer_->target_bounds()); |
| 168 return; | 173 return; |
| 169 } | 174 } |
| 170 | 175 |
| 171 int grid_size = event_flags & ui::EF_CONTROL_DOWN ? | 176 int grid_size = event_flags & ui::EF_CONTROL_DOWN ? |
| 172 0 : ash::Shell::GetInstance()->GetGridSize(); | 177 0 : ash::Shell::GetInstance()->GetGridSize(); |
| 173 gfx::Rect bounds(GetFinalBounds(window()->bounds(), grid_size)); | 178 gfx::Rect bounds(GetFinalBounds(window()->bounds(), grid_size)); |
| 174 | 179 |
| 175 // Check if the destination is another display. | 180 // Check if the destination is another display. |
| 176 gfx::Point last_mouse_location_in_screen = last_mouse_location_; | 181 gfx::Point last_mouse_location_in_screen = last_mouse_location_; |
| (...skipping 30 matching lines...) Expand all Loading... |
| 207 void WorkspaceWindowResizer::RevertDrag() { | 212 void WorkspaceWindowResizer::RevertDrag() { |
| 208 window()->layer()->SetOpacity(details_.initial_opacity); | 213 window()->layer()->SetOpacity(details_.initial_opacity); |
| 209 drag_phantom_window_controller_.reset(); | 214 drag_phantom_window_controller_.reset(); |
| 210 snap_phantom_window_controller_.reset(); | 215 snap_phantom_window_controller_.reset(); |
| 211 Shell::GetInstance()->mouse_cursor_filter()->HideSharedEdgeIndicator(); | 216 Shell::GetInstance()->mouse_cursor_filter()->HideSharedEdgeIndicator(); |
| 212 | 217 |
| 213 if (!did_move_or_resize_) | 218 if (!did_move_or_resize_) |
| 214 return; | 219 return; |
| 215 | 220 |
| 216 window()->SetBounds(details_.initial_bounds); | 221 window()->SetBounds(details_.initial_bounds); |
| 222 if (!details_.restore_bounds.IsEmpty()) |
| 223 SetRestoreBoundsInScreen(details_.window, details_.restore_bounds); |
| 224 |
| 217 if (details_.window_component == HTRIGHT) { | 225 if (details_.window_component == HTRIGHT) { |
| 218 int last_x = details_.initial_bounds.right(); | 226 int last_x = details_.initial_bounds.right(); |
| 219 for (size_t i = 0; i < attached_windows_.size(); ++i) { | 227 for (size_t i = 0; i < attached_windows_.size(); ++i) { |
| 220 gfx::Rect bounds(attached_windows_[i]->bounds()); | 228 gfx::Rect bounds(attached_windows_[i]->bounds()); |
| 221 bounds.set_x(last_x); | 229 bounds.set_x(last_x); |
| 222 bounds.set_width(initial_size_[i]); | 230 bounds.set_width(initial_size_[i]); |
| 223 attached_windows_[i]->SetBounds(bounds); | 231 attached_windows_[i]->SetBounds(bounds); |
| 224 last_x = attached_windows_[i]->bounds().right(); | 232 last_x = attached_windows_[i]->bounds().right(); |
| 225 } | 233 } |
| 226 } else { | 234 } else { |
| (...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 615 gfx::Rect layer_bounds = layer_->bounds(); | 623 gfx::Rect layer_bounds = layer_->bounds(); |
| 616 layer_bounds.set_origin(gfx::Point(0, 0)); | 624 layer_bounds.set_origin(gfx::Point(0, 0)); |
| 617 layer_->SetBounds(layer_bounds); | 625 layer_->SetBounds(layer_bounds); |
| 618 layer_->SetVisible(false); | 626 layer_->SetVisible(false); |
| 619 // Detach it from the current container. | 627 // Detach it from the current container. |
| 620 layer_->parent()->Remove(layer_); | 628 layer_->parent()->Remove(layer_); |
| 621 } | 629 } |
| 622 | 630 |
| 623 } // namespace internal | 631 } // namespace internal |
| 624 } // namespace ash | 632 } // namespace ash |
| OLD | NEW |