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 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 // other root window, you will see an unexpected value on the former. See | 118 // other root window, you will see an unexpected value on the former. See |
119 // comments in wm::GetRootWindowRelativeToWindow() for details. | 119 // comments in wm::GetRootWindowRelativeToWindow() for details. |
120 | 120 |
121 int grid_size = event_flags & ui::EF_CONTROL_DOWN ? 0 : kScreenEdgeInset; | 121 int grid_size = event_flags & ui::EF_CONTROL_DOWN ? 0 : kScreenEdgeInset; |
122 gfx::Rect bounds = // in |window()->parent()|'s coordinates. | 122 gfx::Rect bounds = // in |window()->parent()|'s coordinates. |
123 CalculateBoundsForDrag(details_, location_in_parent); | 123 CalculateBoundsForDrag(details_, location_in_parent); |
124 | 124 |
125 if (wm::IsWindowNormal(window())) | 125 if (wm::IsWindowNormal(window())) |
126 AdjustBoundsForMainWindow(&bounds, grid_size); | 126 AdjustBoundsForMainWindow(&bounds, grid_size); |
127 if (bounds != window()->bounds()) { | 127 if (bounds != window()->bounds()) { |
128 if (!did_move_or_resize_) | 128 if (!did_move_or_resize_) { |
| 129 if (!details_.restore_bounds.IsEmpty()) |
| 130 ClearRestoreBounds(window()); |
129 RestackWindows(); | 131 RestackWindows(); |
| 132 } |
130 did_move_or_resize_ = true; | 133 did_move_or_resize_ = true; |
131 } | 134 } |
132 | 135 |
133 const bool in_original_root = (window()->GetRootWindow() == current_root); | 136 const bool in_original_root = (window()->GetRootWindow() == current_root); |
134 // Hide a phantom window for snapping if the cursor is in another root window. | 137 // Hide a phantom window for snapping if the cursor is in another root window. |
135 if (in_original_root) | 138 if (in_original_root) |
136 UpdateSnapPhantomWindow(location_in_parent, bounds); | 139 UpdateSnapPhantomWindow(location_in_parent, bounds); |
137 else | 140 else |
138 snap_phantom_window_controller_.reset(); | 141 snap_phantom_window_controller_.reset(); |
139 | 142 |
(...skipping 17 matching lines...) Expand all Loading... |
157 | 160 |
158 void WorkspaceWindowResizer::CompleteDrag(int event_flags) { | 161 void WorkspaceWindowResizer::CompleteDrag(int event_flags) { |
159 window()->layer()->SetOpacity(details_.initial_opacity); | 162 window()->layer()->SetOpacity(details_.initial_opacity); |
160 drag_phantom_window_controller_.reset(); | 163 drag_phantom_window_controller_.reset(); |
161 snap_phantom_window_controller_.reset(); | 164 snap_phantom_window_controller_.reset(); |
162 if (!did_move_or_resize_ || details_.window_component != HTCAPTION) | 165 if (!did_move_or_resize_ || details_.window_component != HTCAPTION) |
163 return; | 166 return; |
164 | 167 |
165 if (snap_type_ == SNAP_LEFT_EDGE || snap_type_ == SNAP_RIGHT_EDGE) { | 168 if (snap_type_ == SNAP_LEFT_EDGE || snap_type_ == SNAP_RIGHT_EDGE) { |
166 if (!GetRestoreBoundsInScreen(window())) | 169 if (!GetRestoreBoundsInScreen(window())) |
167 SetRestoreBoundsInParent(window(), details_.initial_bounds); | 170 SetRestoreBoundsInParent(window(), details_.restore_bounds.IsEmpty() ? |
| 171 details_.initial_bounds : |
| 172 details_.restore_bounds); |
168 window()->SetBounds(snap_sizer_->target_bounds()); | 173 window()->SetBounds(snap_sizer_->target_bounds()); |
169 return; | 174 return; |
170 } | 175 } |
171 | 176 |
172 gfx::Rect bounds(GetFinalBounds(window()->bounds())); | 177 gfx::Rect bounds(GetFinalBounds(window()->bounds())); |
173 | 178 |
174 // Check if the destination is another display. | 179 // Check if the destination is another display. |
175 gfx::Point last_mouse_location_in_screen = last_mouse_location_; | 180 gfx::Point last_mouse_location_in_screen = last_mouse_location_; |
176 wm::ConvertPointToScreen(window()->parent(), &last_mouse_location_in_screen); | 181 wm::ConvertPointToScreen(window()->parent(), &last_mouse_location_in_screen); |
177 const gfx::Display dst_display = | 182 const gfx::Display dst_display = |
(...skipping 11 matching lines...) Expand all Loading... |
189 void WorkspaceWindowResizer::RevertDrag() { | 194 void WorkspaceWindowResizer::RevertDrag() { |
190 window()->layer()->SetOpacity(details_.initial_opacity); | 195 window()->layer()->SetOpacity(details_.initial_opacity); |
191 drag_phantom_window_controller_.reset(); | 196 drag_phantom_window_controller_.reset(); |
192 snap_phantom_window_controller_.reset(); | 197 snap_phantom_window_controller_.reset(); |
193 Shell::GetInstance()->mouse_cursor_filter()->HideSharedEdgeIndicator(); | 198 Shell::GetInstance()->mouse_cursor_filter()->HideSharedEdgeIndicator(); |
194 | 199 |
195 if (!did_move_or_resize_) | 200 if (!did_move_or_resize_) |
196 return; | 201 return; |
197 | 202 |
198 window()->SetBounds(details_.initial_bounds); | 203 window()->SetBounds(details_.initial_bounds); |
| 204 if (!details_.restore_bounds.IsEmpty()) |
| 205 SetRestoreBoundsInScreen(details_.window, details_.restore_bounds); |
| 206 |
199 if (details_.window_component == HTRIGHT) { | 207 if (details_.window_component == HTRIGHT) { |
200 int last_x = details_.initial_bounds.right(); | 208 int last_x = details_.initial_bounds.right(); |
201 for (size_t i = 0; i < attached_windows_.size(); ++i) { | 209 for (size_t i = 0; i < attached_windows_.size(); ++i) { |
202 gfx::Rect bounds(attached_windows_[i]->bounds()); | 210 gfx::Rect bounds(attached_windows_[i]->bounds()); |
203 bounds.set_x(last_x); | 211 bounds.set_x(last_x); |
204 bounds.set_width(initial_size_[i]); | 212 bounds.set_width(initial_size_[i]); |
205 attached_windows_[i]->SetBounds(bounds); | 213 attached_windows_[i]->SetBounds(bounds); |
206 last_x = attached_windows_[i]->bounds().right(); | 214 last_x = attached_windows_[i]->bounds().right(); |
207 } | 215 } |
208 } else { | 216 } else { |
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
579 gfx::Rect layer_bounds = layer_->bounds(); | 587 gfx::Rect layer_bounds = layer_->bounds(); |
580 layer_bounds.set_origin(gfx::Point(0, 0)); | 588 layer_bounds.set_origin(gfx::Point(0, 0)); |
581 layer_->SetBounds(layer_bounds); | 589 layer_->SetBounds(layer_bounds); |
582 layer_->SetVisible(false); | 590 layer_->SetVisible(false); |
583 // Detach it from the current container. | 591 // Detach it from the current container. |
584 layer_->parent()->Remove(layer_); | 592 layer_->parent()->Remove(layer_); |
585 } | 593 } |
586 | 594 |
587 } // namespace internal | 595 } // namespace internal |
588 } // namespace ash | 596 } // namespace ash |
OLD | NEW |