| 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/display/window_tree_host_manager.h" | 7 #include "ash/display/window_tree_host_manager.h" |
| 8 #include "ash/root_window_controller.h" | 8 #include "ash/root_window_controller.h" |
| 9 #include "ash/screen_util.h" | 9 #include "ash/screen_util.h" |
| 10 #include "ash/shelf/shelf.h" | 10 #include "ash/shelf/shelf.h" |
| 11 #include "ash/shelf/shelf_types.h" | 11 #include "ash/shelf/shelf_types.h" |
| 12 #include "ash/shelf/shelf_widget.h" | 12 #include "ash/shelf/shelf_widget.h" |
| 13 #include "ash/shell.h" | 13 #include "ash/shell.h" |
| 14 #include "ash/shell_window_ids.h" | 14 #include "ash/shell_window_ids.h" |
| 15 #include "ash/wm/aura/wm_window_aura.h" |
| 16 #include "ash/wm/common/window_parenting_utils.h" |
| 15 #include "ash/wm/common/wm_event.h" | 17 #include "ash/wm/common/wm_event.h" |
| 16 #include "ash/wm/dock/docked_window_layout_manager.h" | 18 #include "ash/wm/dock/docked_window_layout_manager.h" |
| 17 #include "ash/wm/window_state.h" | 19 #include "ash/wm/window_state.h" |
| 18 #include "ash/wm/window_state_aura.h" | 20 #include "ash/wm/window_state_aura.h" |
| 19 #include "ash/wm/window_util.h" | 21 #include "ash/wm/window_util.h" |
| 20 #include "ash/wm/workspace/magnetism_matcher.h" | 22 #include "ash/wm/workspace/magnetism_matcher.h" |
| 21 #include "ash/wm/workspace/workspace_window_resizer.h" | 23 #include "ash/wm/workspace/workspace_window_resizer.h" |
| 22 #include "base/command_line.h" | 24 #include "base/command_line.h" |
| 23 #include "base/memory/weak_ptr.h" | 25 #include "base/memory/weak_ptr.h" |
| 24 #include "ui/aura/client/aura_constants.h" | 26 #include "ui/aura/client/aura_constants.h" |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 // Reparent workspace windows during the drag to elevate them above workspace. | 205 // Reparent workspace windows during the drag to elevate them above workspace. |
| 204 // Other windows for which the DockedWindowResizer is instantiated include | 206 // Other windows for which the DockedWindowResizer is instantiated include |
| 205 // panels and windows that are already docked. Those do not need reparenting. | 207 // panels and windows that are already docked. Those do not need reparenting. |
| 206 if (GetTarget()->type() != ui::wm::WINDOW_TYPE_PANEL && | 208 if (GetTarget()->type() != ui::wm::WINDOW_TYPE_PANEL && |
| 207 GetTarget()->parent()->id() == kShellWindowId_DefaultContainer) { | 209 GetTarget()->parent()->id() == kShellWindowId_DefaultContainer) { |
| 208 // Reparent the window into the docked windows container in order to get it | 210 // Reparent the window into the docked windows container in order to get it |
| 209 // on top of other docked windows. | 211 // on top of other docked windows. |
| 210 aura::Window* docked_container = Shell::GetContainer( | 212 aura::Window* docked_container = Shell::GetContainer( |
| 211 GetTarget()->GetRootWindow(), | 213 GetTarget()->GetRootWindow(), |
| 212 kShellWindowId_DockedContainer); | 214 kShellWindowId_DockedContainer); |
| 213 wm::ReparentChildWithTransientChildren(GetTarget(), | 215 ReparentChildWithTransientChildren( |
| 214 GetTarget()->parent(), | 216 ash::wm::WmWindowAura::Get(GetTarget()), |
| 215 docked_container); | 217 ash::wm::WmWindowAura::Get(GetTarget()->parent()), |
| 218 ash::wm::WmWindowAura::Get(docked_container)); |
| 216 if (!resizer) | 219 if (!resizer) |
| 217 return; | 220 return; |
| 218 } | 221 } |
| 219 if (is_docked_) | 222 if (is_docked_) |
| 220 dock_layout_->DockDraggedWindow(GetTarget()); | 223 dock_layout_->DockDraggedWindow(GetTarget()); |
| 221 } | 224 } |
| 222 | 225 |
| 223 void DockedWindowResizer::FinishedDragging( | 226 void DockedWindowResizer::FinishedDragging( |
| 224 aura::client::WindowMoveResult move_result) { | 227 aura::client::WindowMoveResult move_result) { |
| 225 if (!did_move_or_resize_) | 228 if (!did_move_or_resize_) |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 aura::Window* window = GetTarget(); | 282 aura::Window* window = GetTarget(); |
| 280 | 283 |
| 281 // Check if the window needs to be docked or returned to workspace. | 284 // Check if the window needs to be docked or returned to workspace. |
| 282 DockedAction action = DOCKED_ACTION_NONE; | 285 DockedAction action = DOCKED_ACTION_NONE; |
| 283 aura::Window* dock_container = Shell::GetContainer( | 286 aura::Window* dock_container = Shell::GetContainer( |
| 284 window->GetRootWindow(), | 287 window->GetRootWindow(), |
| 285 kShellWindowId_DockedContainer); | 288 kShellWindowId_DockedContainer); |
| 286 if ((is_resized || !is_attached_panel) && | 289 if ((is_resized || !is_attached_panel) && |
| 287 is_docked_ != (window->parent() == dock_container)) { | 290 is_docked_ != (window->parent() == dock_container)) { |
| 288 if (is_docked_) { | 291 if (is_docked_) { |
| 289 wm::ReparentChildWithTransientChildren(window, | 292 wm::ReparentChildWithTransientChildren( |
| 290 window->parent(), | 293 wm::WmWindowAura::Get(window), |
| 291 dock_container); | 294 wm::WmWindowAura::Get(window->parent()), |
| 295 wm::WmWindowAura::Get(dock_container)); |
| 292 action = DOCKED_ACTION_DOCK; | 296 action = DOCKED_ACTION_DOCK; |
| 293 } else if (window->parent()->id() == kShellWindowId_DockedContainer) { | 297 } else if (window->parent()->id() == kShellWindowId_DockedContainer) { |
| 294 // Reparent the window back to workspace. | 298 // Reparent the window back to workspace. |
| 295 // We need to be careful to give ParentWindowWithContext a location in | 299 // We need to be careful to give ParentWindowWithContext a location in |
| 296 // the right root window (matching the logic in DragWindowResizer) based | 300 // the right root window (matching the logic in DragWindowResizer) based |
| 297 // on which root window a mouse pointer is in. We want to undock into the | 301 // on which root window a mouse pointer is in. We want to undock into the |
| 298 // right screen near the edge of a multiscreen setup (based on where the | 302 // right screen near the edge of a multiscreen setup (based on where the |
| 299 // mouse is). | 303 // mouse is). |
| 300 gfx::Rect near_last_location(last_location_, gfx::Size()); | 304 gfx::Rect near_last_location(last_location_, gfx::Size()); |
| 301 // Reparenting will cause Relayout and possible dock shrinking. | 305 // Reparenting will cause Relayout and possible dock shrinking. |
| 302 aura::Window* previous_parent = window->parent(); | 306 aura::Window* previous_parent = window->parent(); |
| 303 aura::client::ParentWindowWithContext(window, window, near_last_location); | 307 aura::client::ParentWindowWithContext(window, window, near_last_location); |
| 304 if (window->parent() != previous_parent) { | 308 if (window->parent() != previous_parent) { |
| 305 wm::ReparentTransientChildrenOfChild(window, | 309 wm::ReparentTransientChildrenOfChild( |
| 306 previous_parent, | 310 ash::wm::WmWindowAura::Get(window), |
| 307 window->parent()); | 311 ash::wm::WmWindowAura::Get(previous_parent), |
| 312 ash::wm::WmWindowAura::Get(window->parent())); |
| 308 } | 313 } |
| 309 action = was_docked_ ? DOCKED_ACTION_UNDOCK : DOCKED_ACTION_NONE; | 314 action = was_docked_ ? DOCKED_ACTION_UNDOCK : DOCKED_ACTION_NONE; |
| 310 } | 315 } |
| 311 } else { | 316 } else { |
| 312 // |action| is recorded in UMA and used to maintain |window_state_|. | 317 // |action| is recorded in UMA and used to maintain |window_state_|. |
| 313 if (is_resized && is_docked_ && was_docked_) | 318 if (is_resized && is_docked_ && was_docked_) |
| 314 action = DOCKED_ACTION_RESIZE; | 319 action = DOCKED_ACTION_RESIZE; |
| 315 else if (is_docked_ && was_docked_) | 320 else if (is_docked_ && was_docked_) |
| 316 action = DOCKED_ACTION_REORDER; | 321 action = DOCKED_ACTION_REORDER; |
| 317 else if (is_docked_ && !was_docked_) | 322 else if (is_docked_ && !was_docked_) |
| (...skipping 18 matching lines...) Expand all Loading... |
| 336 } else if (wm::GetWindowState(window)->IsDocked() && | 341 } else if (wm::GetWindowState(window)->IsDocked() && |
| 337 action == DOCKED_ACTION_UNDOCK) { | 342 action == DOCKED_ACTION_UNDOCK) { |
| 338 const wm::WMEvent event(wm::WM_EVENT_NORMAL); | 343 const wm::WMEvent event(wm::WM_EVENT_NORMAL); |
| 339 window_state_->OnWMEvent(&event); | 344 window_state_->OnWMEvent(&event); |
| 340 } | 345 } |
| 341 | 346 |
| 342 return action; | 347 return action; |
| 343 } | 348 } |
| 344 | 349 |
| 345 } // namespace ash | 350 } // namespace ash |
| OLD | NEW |