OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/dock/docked_window_resizer.h" | 5 #include "ash/wm/dock/docked_window_resizer.h" |
6 | 6 |
7 #include "ash/ash_switches.h" | 7 #include "ash/ash_switches.h" |
8 #include "ash/display/display_controller.h" | 8 #include "ash/display/display_controller.h" |
9 #include "ash/launcher/launcher.h" | 9 #include "ash/launcher/launcher.h" |
10 #include "ash/root_window_controller.h" | 10 #include "ash/root_window_controller.h" |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 if (new_dock_layout && new_dock_layout != dock_layout_) { | 99 if (new_dock_layout && new_dock_layout != dock_layout_) { |
100 // The window is being dragged to a new display. If the previous | 100 // The window is being dragged to a new display. If the previous |
101 // container is the current parent of the window it will be informed of | 101 // container is the current parent of the window it will be informed of |
102 // the end of drag when the window is reparented, otherwise let the | 102 // the end of drag when the window is reparented, otherwise let the |
103 // previous container know the drag is complete. If we told the | 103 // previous container know the drag is complete. If we told the |
104 // window's parent that the drag was complete it would begin | 104 // window's parent that the drag was complete it would begin |
105 // positioning the window. | 105 // positioning the window. |
106 if (is_docked_ && dock_layout_->is_dragged_window_docked()) | 106 if (is_docked_ && dock_layout_->is_dragged_window_docked()) |
107 dock_layout_->UndockDraggedWindow(); | 107 dock_layout_->UndockDraggedWindow(); |
108 if (dock_layout_ != initial_dock_layout_) | 108 if (dock_layout_ != initial_dock_layout_) |
109 dock_layout_->FinishDragging(); | 109 dock_layout_->FinishDragging( |
| 110 DOCKED_ACTION_NONE, |
| 111 details_.source == aura::client::WINDOW_MOVE_SOURCE_MOUSE ? |
| 112 DOCKED_ACTION_SOURCE_MOUSE : DOCKED_ACTION_SOURCE_TOUCH); |
110 is_docked_ = false; | 113 is_docked_ = false; |
111 dock_layout_ = new_dock_layout; | 114 dock_layout_ = new_dock_layout; |
112 // The window's initial layout manager already knows that the drag is | 115 // The window's initial layout manager already knows that the drag is |
113 // in progress for this window. | 116 // in progress for this window. |
114 if (new_dock_layout != initial_dock_layout_) | 117 if (new_dock_layout != initial_dock_layout_) |
115 new_dock_layout->StartDragging(GetTarget()); | 118 new_dock_layout->StartDragging(GetTarget()); |
116 } | 119 } |
117 // Window could get docked by the WorkspaceWindowResizer, update the state. | 120 // Window could get docked by the WorkspaceWindowResizer, update the state. |
118 is_docked_ = dock_layout_->is_dragged_window_docked(); | 121 is_docked_ = dock_layout_->is_dragged_window_docked(); |
119 } | 122 } |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 window->parent(), dock_layout_->dragged_bounds()); | 258 window->parent(), dock_layout_->dragged_bounds()); |
256 if (!bounds.IsEmpty() && bounds.width() != window->bounds().width()) { | 259 if (!bounds.IsEmpty() && bounds.width() != window->bounds().width()) { |
257 window->SetBounds(bounds); | 260 window->SetBounds(bounds); |
258 } | 261 } |
259 } | 262 } |
260 // No longer restore to pre-docked bounds if a window has been resized. | 263 // No longer restore to pre-docked bounds if a window has been resized. |
261 if (is_resized && is_docked_) | 264 if (is_resized && is_docked_) |
262 window_state->ClearRestoreBounds(); | 265 window_state->ClearRestoreBounds(); |
263 | 266 |
264 // Check if the window needs to be docked or returned to workspace. | 267 // Check if the window needs to be docked or returned to workspace. |
| 268 DockedAction action = DOCKED_ACTION_NONE; |
265 aura::Window* dock_container = Shell::GetContainer( | 269 aura::Window* dock_container = Shell::GetContainer( |
266 window->GetRootWindow(), | 270 window->GetRootWindow(), |
267 kShellWindowId_DockedContainer); | 271 kShellWindowId_DockedContainer); |
268 if ((is_resized || !attached_panel) && | 272 if ((is_resized || !attached_panel) && |
269 is_docked_ != (window->parent() == dock_container)) { | 273 is_docked_ != (window->parent() == dock_container)) { |
270 if (is_docked_) { | 274 if (is_docked_) { |
271 wm::ReparentChildWithTransientChildren(dock_container, window); | 275 wm::ReparentChildWithTransientChildren(dock_container, window); |
| 276 action = DOCKED_ACTION_DOCK; |
272 } else if (window->parent()->id() == kShellWindowId_DockedContainer) { | 277 } else if (window->parent()->id() == kShellWindowId_DockedContainer) { |
273 // Reparent the window back to workspace. | 278 // Reparent the window back to workspace. |
274 // We need to be careful to give ParentWindowWithContext a location in | 279 // We need to be careful to give ParentWindowWithContext a location in |
275 // the right root window (matching the logic in DragWindowResizer) based | 280 // the right root window (matching the logic in DragWindowResizer) based |
276 // on which root window a mouse pointer is in. We want to undock into the | 281 // on which root window a mouse pointer is in. We want to undock into the |
277 // right screen near the edge of a multiscreen setup (based on where the | 282 // right screen near the edge of a multiscreen setup (based on where the |
278 // mouse is). | 283 // mouse is). |
279 gfx::Rect near_last_location(last_location_, gfx::Size()); | 284 gfx::Rect near_last_location(last_location_, gfx::Size()); |
280 // Reparenting will cause Relayout and possible dock shrinking. | 285 // Reparenting will cause Relayout and possible dock shrinking. |
281 aura::Window* previous_parent = window->parent(); | 286 aura::Window* previous_parent = window->parent(); |
282 aura::client::ParentWindowWithContext(window, window, near_last_location); | 287 aura::client::ParentWindowWithContext(window, window, near_last_location); |
283 if (window->parent() != previous_parent) | 288 if (window->parent() != previous_parent) |
284 wm::ReparentTransientChildrenOfChild(window->parent(), window); | 289 wm::ReparentTransientChildrenOfChild(window->parent(), window); |
| 290 action = was_docked_ ? DOCKED_ACTION_UNDOCK : DOCKED_ACTION_NONE; |
285 } | 291 } |
| 292 } else { |
| 293 // Docked state was not changed but still need to record a UMA action. |
| 294 if (is_resized && is_docked_ && was_docked_) |
| 295 action = DOCKED_ACTION_RESIZE; |
| 296 else if (is_docked_ && was_docked_) |
| 297 action = DOCKED_ACTION_REORDER; |
| 298 else if (is_docked_ && !was_docked_) |
| 299 action = DOCKED_ACTION_DOCK; |
| 300 else |
| 301 action = DOCKED_ACTION_NONE; |
286 } | 302 } |
287 dock_layout_->FinishDragging(); | 303 dock_layout_->FinishDragging( |
| 304 action, |
| 305 details_.source == aura::client::WINDOW_MOVE_SOURCE_MOUSE ? |
| 306 DOCKED_ACTION_SOURCE_MOUSE : DOCKED_ACTION_SOURCE_TOUCH); |
288 | 307 |
289 // If we started the drag in one root window and moved into another root | 308 // If we started the drag in one root window and moved into another root |
290 // but then canceled the drag we may need to inform the original layout | 309 // but then canceled the drag we may need to inform the original layout |
291 // manager that the drag is finished. | 310 // manager that the drag is finished. |
292 if (initial_dock_layout_ != dock_layout_) | 311 if (initial_dock_layout_ != dock_layout_) |
293 initial_dock_layout_->FinishDragging(); | 312 initial_dock_layout_->FinishDragging( |
| 313 DOCKED_ACTION_NONE, |
| 314 details_.source == aura::client::WINDOW_MOVE_SOURCE_MOUSE ? |
| 315 DOCKED_ACTION_SOURCE_MOUSE : DOCKED_ACTION_SOURCE_TOUCH); |
294 is_docked_ = false; | 316 is_docked_ = false; |
295 } | 317 } |
296 | 318 |
297 } // namespace internal | 319 } // namespace internal |
298 } // namespace ash | 320 } // namespace ash |
OLD | NEW |