| 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/display_controller.h" | 7 #include "ash/display/display_controller.h" |
| 8 #include "ash/root_window_controller.h" | 8 #include "ash/root_window_controller.h" |
| 9 #include "ash/screen_ash.h" | 9 #include "ash/screen_ash.h" |
| 10 #include "ash/shelf/shelf.h" | 10 #include "ash/shelf/shelf.h" |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 is_docked_ = dock_layout_->is_dragged_window_docked(); | 106 is_docked_ = dock_layout_->is_dragged_window_docked(); |
| 107 // Whenever a window is dragged out of the dock it will be auto-sized | 107 // Whenever a window is dragged out of the dock it will be auto-sized |
| 108 // in the dock if it gets docked again. | 108 // in the dock if it gets docked again. |
| 109 if (!is_docked_) | 109 if (!is_docked_) |
| 110 was_bounds_changed_by_user_ = false; | 110 was_bounds_changed_by_user_ = false; |
| 111 } | 111 } |
| 112 | 112 |
| 113 void DockedWindowResizer::CompleteDrag() { | 113 void DockedWindowResizer::CompleteDrag() { |
| 114 // The root window can change when dragging into a different screen. | 114 // The root window can change when dragging into a different screen. |
| 115 next_window_resizer_->CompleteDrag(); | 115 next_window_resizer_->CompleteDrag(); |
| 116 FinishedDragging(); | 116 FinishedDragging(aura::client::MOVE_SUCCESSFUL); |
| 117 } | 117 } |
| 118 | 118 |
| 119 void DockedWindowResizer::RevertDrag() { | 119 void DockedWindowResizer::RevertDrag() { |
| 120 next_window_resizer_->RevertDrag(); | 120 next_window_resizer_->RevertDrag(); |
| 121 // Restore docked state to what it was before the drag if necessary. | 121 // Restore docked state to what it was before the drag if necessary. |
| 122 if (is_docked_ != was_docked_) { | 122 if (is_docked_ != was_docked_) { |
| 123 is_docked_ = was_docked_; | 123 is_docked_ = was_docked_; |
| 124 if (is_docked_) | 124 if (is_docked_) |
| 125 dock_layout_->DockDraggedWindow(GetTarget()); | 125 dock_layout_->DockDraggedWindow(GetTarget()); |
| 126 else | 126 else |
| 127 dock_layout_->UndockDraggedWindow(); | 127 dock_layout_->UndockDraggedWindow(); |
| 128 } | 128 } |
| 129 FinishedDragging(); | 129 FinishedDragging(aura::client::MOVE_CANCELED); |
| 130 } | 130 } |
| 131 | 131 |
| 132 DockedWindowResizer::DockedWindowResizer(WindowResizer* next_window_resizer, | 132 DockedWindowResizer::DockedWindowResizer(WindowResizer* next_window_resizer, |
| 133 wm::WindowState* window_state) | 133 wm::WindowState* window_state) |
| 134 : WindowResizer(window_state), | 134 : WindowResizer(window_state), |
| 135 next_window_resizer_(next_window_resizer), | 135 next_window_resizer_(next_window_resizer), |
| 136 dock_layout_(NULL), | 136 dock_layout_(NULL), |
| 137 initial_dock_layout_(NULL), | 137 initial_dock_layout_(NULL), |
| 138 did_move_or_resize_(false), | 138 did_move_or_resize_(false), |
| 139 was_docked_(false), | 139 was_docked_(false), |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 GetTarget()->GetRootWindow(), | 206 GetTarget()->GetRootWindow(), |
| 207 kShellWindowId_DockedContainer); | 207 kShellWindowId_DockedContainer); |
| 208 wm::ReparentChildWithTransientChildren(GetTarget(), | 208 wm::ReparentChildWithTransientChildren(GetTarget(), |
| 209 GetTarget()->parent(), | 209 GetTarget()->parent(), |
| 210 docked_container); | 210 docked_container); |
| 211 } | 211 } |
| 212 if (is_docked_) | 212 if (is_docked_) |
| 213 dock_layout_->DockDraggedWindow(GetTarget()); | 213 dock_layout_->DockDraggedWindow(GetTarget()); |
| 214 } | 214 } |
| 215 | 215 |
| 216 void DockedWindowResizer::FinishedDragging() { | 216 void DockedWindowResizer::FinishedDragging( |
| 217 aura::client::WindowMoveResult move_result) { |
| 217 if (!did_move_or_resize_) | 218 if (!did_move_or_resize_) |
| 218 return; | 219 return; |
| 219 did_move_or_resize_ = false; | 220 did_move_or_resize_ = false; |
| 220 aura::Window* window = GetTarget(); | 221 aura::Window* window = GetTarget(); |
| 221 const bool is_attached_panel = window->type() == ui::wm::WINDOW_TYPE_PANEL && | 222 const bool is_attached_panel = window->type() == ui::wm::WINDOW_TYPE_PANEL && |
| 222 window_state_->panel_attached(); | 223 window_state_->panel_attached(); |
| 223 const bool is_resized = | 224 const bool is_resized = |
| 224 (details().bounds_change & WindowResizer::kBoundsChange_Resizes) != 0; | 225 (details().bounds_change & WindowResizer::kBoundsChange_Resizes) != 0; |
| 225 | 226 |
| 226 // When drag is completed the dragged docked window is resized to the bounds | 227 // When drag is completed the dragged docked window is resized to the bounds |
| (...skipping 11 matching lines...) Expand all Loading... |
| 238 gfx::Rect restore_bounds = window->GetBoundsInScreen(); | 239 gfx::Rect restore_bounds = window->GetBoundsInScreen(); |
| 239 restore_bounds.set_height( | 240 restore_bounds.set_height( |
| 240 window_state_->GetRestoreBoundsInScreen().height()); | 241 window_state_->GetRestoreBoundsInScreen().height()); |
| 241 window_state_->SetRestoreBoundsInScreen(restore_bounds); | 242 window_state_->SetRestoreBoundsInScreen(restore_bounds); |
| 242 } | 243 } |
| 243 | 244 |
| 244 // Check if the window needs to be docked or returned to workspace. | 245 // Check if the window needs to be docked or returned to workspace. |
| 245 DockedAction action = MaybeReparentWindowOnDragCompletion(is_resized, | 246 DockedAction action = MaybeReparentWindowOnDragCompletion(is_resized, |
| 246 is_attached_panel); | 247 is_attached_panel); |
| 247 dock_layout_->FinishDragging( | 248 dock_layout_->FinishDragging( |
| 248 action, | 249 move_result == aura::client::MOVE_CANCELED ? DOCKED_ACTION_NONE : action, |
| 249 details().source == aura::client::WINDOW_MOVE_SOURCE_MOUSE ? | 250 details().source == aura::client::WINDOW_MOVE_SOURCE_MOUSE ? |
| 250 DOCKED_ACTION_SOURCE_MOUSE : DOCKED_ACTION_SOURCE_TOUCH); | 251 DOCKED_ACTION_SOURCE_MOUSE : DOCKED_ACTION_SOURCE_TOUCH); |
| 251 | 252 |
| 252 // If we started the drag in one root window and moved into another root | 253 // If we started the drag in one root window and moved into another root |
| 253 // but then canceled the drag we may need to inform the original layout | 254 // but then canceled the drag we may need to inform the original layout |
| 254 // manager that the drag is finished. | 255 // manager that the drag is finished. |
| 255 if (initial_dock_layout_ != dock_layout_) | 256 if (initial_dock_layout_ != dock_layout_) |
| 256 initial_dock_layout_->FinishDragging( | 257 initial_dock_layout_->FinishDragging( |
| 257 DOCKED_ACTION_NONE, | 258 DOCKED_ACTION_NONE, |
| 258 details().source == aura::client::WINDOW_MOVE_SOURCE_MOUSE ? | 259 details().source == aura::client::WINDOW_MOVE_SOURCE_MOUSE ? |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 311 // before. | 312 // before. |
| 312 if (is_docked_) { | 313 if (is_docked_) { |
| 313 wm::GetWindowState(window)->set_bounds_changed_by_user( | 314 wm::GetWindowState(window)->set_bounds_changed_by_user( |
| 314 was_docked_ && (is_resized || was_bounds_changed_by_user_)); | 315 was_docked_ && (is_resized || was_bounds_changed_by_user_)); |
| 315 } | 316 } |
| 316 return action; | 317 return action; |
| 317 } | 318 } |
| 318 | 319 |
| 319 } // namespace internal | 320 } // namespace internal |
| 320 } // namespace ash | 321 } // namespace ash |
| OLD | NEW |