| 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" | |
| 8 #include "ash/root_window_controller.h" | |
| 9 #include "ash/screen_util.h" | |
| 10 #include "ash/shelf/shelf.h" | |
| 11 #include "ash/shelf/shelf_types.h" | |
| 12 #include "ash/shelf/shelf_widget.h" | |
| 13 #include "ash/shell.h" | |
| 14 #include "ash/shell_window_ids.h" | 7 #include "ash/shell_window_ids.h" |
| 15 #include "ash/wm/aura/wm_window_aura.h" | 8 #include "ash/wm/aura/wm_window_aura.h" |
| 16 #include "ash/wm/common/window_parenting_utils.h" | 9 #include "ash/wm/common/window_parenting_utils.h" |
| 17 #include "ash/wm/common/wm_event.h" | 10 #include "ash/wm/common/wm_event.h" |
| 11 #include "ash/wm/common/wm_root_window_controller.h" |
| 12 #include "ash/wm/common/wm_window.h" |
| 18 #include "ash/wm/dock/docked_window_layout_manager.h" | 13 #include "ash/wm/dock/docked_window_layout_manager.h" |
| 19 #include "ash/wm/window_state.h" | 14 #include "ash/wm/window_state.h" |
| 20 #include "ash/wm/window_state_aura.h" | |
| 21 #include "ash/wm/window_util.h" | |
| 22 #include "ash/wm/workspace/magnetism_matcher.h" | 15 #include "ash/wm/workspace/magnetism_matcher.h" |
| 23 #include "ash/wm/workspace/workspace_window_resizer.h" | |
| 24 #include "base/command_line.h" | |
| 25 #include "base/memory/weak_ptr.h" | |
| 26 #include "ui/aura/client/aura_constants.h" | |
| 27 #include "ui/aura/client/window_tree_client.h" | |
| 28 #include "ui/aura/env.h" | |
| 29 #include "ui/aura/window.h" | 16 #include "ui/aura/window.h" |
| 30 #include "ui/aura/window_delegate.h" | |
| 31 #include "ui/aura/window_event_dispatcher.h" | |
| 32 #include "ui/base/hit_test.h" | 17 #include "ui/base/hit_test.h" |
| 33 #include "ui/base/ui_base_types.h" | 18 #include "ui/base/ui_base_types.h" |
| 34 #include "ui/gfx/screen.h" | 19 #include "ui/gfx/screen.h" |
| 35 #include "ui/views/widget/widget.h" | |
| 36 #include "ui/wm/core/coordinate_conversion.h" | |
| 37 | 20 |
| 38 namespace ash { | 21 namespace ash { |
| 39 namespace { | 22 namespace { |
| 40 | 23 |
| 24 DockedWindowLayoutManager* GetDockedLayoutManagerInRoot(wm::WmWindow* root) { |
| 25 wm::WmWindow* dock_container = |
| 26 root->GetChildByShellWindowId(kShellWindowId_DockedContainer); |
| 27 return static_cast<DockedWindowLayoutManager*>( |
| 28 wm::WmWindowAura::GetAuraWindow(dock_container)->layout_manager()); |
| 29 } |
| 30 |
| 41 DockedWindowLayoutManager* GetDockedLayoutManagerAtPoint( | 31 DockedWindowLayoutManager* GetDockedLayoutManagerAtPoint( |
| 42 const gfx::Point& point) { | 32 const gfx::Point& point) { |
| 43 gfx::Display display = ScreenUtil::FindDisplayContainingPoint(point); | 33 gfx::Display display = |
| 44 if (!display.is_valid()) | 34 gfx::Screen::GetScreen()->GetDisplayNearestPoint(point); |
| 45 return NULL; | 35 if (!display.bounds().Contains(point)) |
| 46 aura::Window* root = Shell::GetInstance() | 36 return nullptr; |
| 47 ->window_tree_host_manager() | 37 |
| 48 ->GetRootWindowForDisplayId(display.id()); | 38 return GetDockedLayoutManagerInRoot( |
| 49 aura::Window* dock_container = Shell::GetContainer( | 39 wm::WmRootWindowController::GetWithDisplayId(display.id())->GetWindow()); |
| 50 root, kShellWindowId_DockedContainer); | |
| 51 return static_cast<DockedWindowLayoutManager*>( | |
| 52 dock_container->layout_manager()); | |
| 53 } | 40 } |
| 54 | 41 |
| 55 } // namespace | 42 } // namespace |
| 56 | 43 |
| 57 DockedWindowResizer::~DockedWindowResizer() { | 44 DockedWindowResizer::~DockedWindowResizer() { |
| 58 } | 45 } |
| 59 | 46 |
| 60 // static | 47 // static |
| 61 DockedWindowResizer* | 48 DockedWindowResizer* |
| 62 DockedWindowResizer::Create(WindowResizer* next_window_resizer, | 49 DockedWindowResizer::Create(WindowResizer* next_window_resizer, |
| 63 wm::WindowState* window_state) { | 50 wm::WindowState* window_state) { |
| 64 return new DockedWindowResizer(next_window_resizer, window_state); | 51 return new DockedWindowResizer(next_window_resizer, window_state); |
| 65 } | 52 } |
| 66 | 53 |
| 67 void DockedWindowResizer::Drag(const gfx::Point& location, int event_flags) { | 54 void DockedWindowResizer::Drag(const gfx::Point& location, int event_flags) { |
| 68 last_location_ = location; | 55 last_location_ = GetTarget()->GetParent()->ConvertPointToScreen(location); |
| 69 ::wm::ConvertPointToScreen(GetAuraTarget()->parent(), &last_location_); | |
| 70 base::WeakPtr<DockedWindowResizer> resizer(weak_ptr_factory_.GetWeakPtr()); | 56 base::WeakPtr<DockedWindowResizer> resizer(weak_ptr_factory_.GetWeakPtr()); |
| 71 | 57 |
| 72 if (!did_move_or_resize_) { | 58 if (!did_move_or_resize_) { |
| 73 did_move_or_resize_ = true; | 59 did_move_or_resize_ = true; |
| 74 StartedDragging(resizer); | 60 StartedDragging(resizer); |
| 75 } | 61 } |
| 76 if (!resizer) | 62 if (!resizer) |
| 77 return; | 63 return; |
| 78 | 64 |
| 79 gfx::Point offset; | 65 gfx::Point offset; |
| 80 gfx::Rect bounds(CalculateBoundsForDrag(location)); | 66 gfx::Rect bounds(CalculateBoundsForDrag(location)); |
| 81 MaybeSnapToEdge(bounds, &offset); | 67 MaybeSnapToEdge(bounds, &offset); |
| 82 gfx::Point modified_location(location); | 68 gfx::Point modified_location(location); |
| 83 modified_location.Offset(offset.x(), offset.y()); | 69 modified_location += offset.OffsetFromOrigin(); |
| 84 | 70 |
| 85 next_window_resizer_->Drag(modified_location, event_flags); | 71 next_window_resizer_->Drag(modified_location, event_flags); |
| 86 if (!resizer) | 72 if (!resizer) |
| 87 return; | 73 return; |
| 88 | 74 |
| 89 DockedWindowLayoutManager* new_dock_layout = | 75 DockedWindowLayoutManager* new_dock_layout = |
| 90 GetDockedLayoutManagerAtPoint(last_location_); | 76 GetDockedLayoutManagerAtPoint(last_location_); |
| 91 if (new_dock_layout && new_dock_layout != dock_layout_) { | 77 if (new_dock_layout && new_dock_layout != dock_layout_) { |
| 92 // The window is being dragged to a new display. If the previous | 78 // The window is being dragged to a new display. If the previous |
| 93 // container is the current parent of the window it will be informed of | 79 // container is the current parent of the window it will be informed of |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 : WindowResizer(window_state), | 127 : WindowResizer(window_state), |
| 142 next_window_resizer_(next_window_resizer), | 128 next_window_resizer_(next_window_resizer), |
| 143 dock_layout_(NULL), | 129 dock_layout_(NULL), |
| 144 initial_dock_layout_(NULL), | 130 initial_dock_layout_(NULL), |
| 145 did_move_or_resize_(false), | 131 did_move_or_resize_(false), |
| 146 was_docked_(false), | 132 was_docked_(false), |
| 147 is_docked_(false), | 133 is_docked_(false), |
| 148 was_bounds_changed_by_user_(window_state->bounds_changed_by_user()), | 134 was_bounds_changed_by_user_(window_state->bounds_changed_by_user()), |
| 149 weak_ptr_factory_(this) { | 135 weak_ptr_factory_(this) { |
| 150 DCHECK(details().is_resizable); | 136 DCHECK(details().is_resizable); |
| 151 aura::Window* dock_container = Shell::GetContainer( | 137 wm::WmWindow* dock_container = |
| 152 GetAuraTarget()->GetRootWindow(), kShellWindowId_DockedContainer); | 138 GetTarget()->GetRootWindow()->GetChildByShellWindowId( |
| 153 dock_layout_ = static_cast<DockedWindowLayoutManager*>( | 139 kShellWindowId_DockedContainer); |
| 154 dock_container->layout_manager()); | 140 dock_layout_ = GetDockedLayoutManagerInRoot(GetTarget()->GetRootWindow()); |
| 155 initial_dock_layout_ = dock_layout_; | 141 initial_dock_layout_ = dock_layout_; |
| 156 was_docked_ = GetAuraTarget()->parent() == dock_container; | 142 was_docked_ = GetTarget()->GetParent() == dock_container; |
| 157 is_docked_ = was_docked_; | 143 is_docked_ = was_docked_; |
| 158 } | 144 } |
| 159 | 145 |
| 160 void DockedWindowResizer::MaybeSnapToEdge(const gfx::Rect& bounds, | 146 void DockedWindowResizer::MaybeSnapToEdge(const gfx::Rect& bounds, |
| 161 gfx::Point* offset) { | 147 gfx::Point* offset) { |
| 162 // Windows only snap magnetically when they were previously docked. | 148 // Windows only snap magnetically when they were previously docked. |
| 163 if (!was_docked_) | 149 if (!was_docked_) |
| 164 return; | 150 return; |
| 165 DockedAlignment dock_alignment = dock_layout_->CalculateAlignment(); | 151 DockedAlignment dock_alignment = dock_layout_->CalculateAlignment(); |
| 166 gfx::Rect dock_bounds = ScreenUtil::ConvertRectFromScreen( | 152 gfx::Rect dock_bounds = GetTarget()->GetParent()->ConvertRectFromScreen( |
| 167 GetAuraTarget()->parent(), | |
| 168 dock_layout_->dock_container()->GetBoundsInScreen()); | 153 dock_layout_->dock_container()->GetBoundsInScreen()); |
| 169 | 154 |
| 170 // Short-range magnetism when retaining docked state. Same constant as in | 155 // Short-range magnetism when retaining docked state. Same constant as in |
| 171 // MagnetismMatcher is used for consistency. | 156 // MagnetismMatcher is used for consistency. |
| 172 const int kSnapToDockDistance = MagnetismMatcher::kMagneticDistance; | 157 const int kSnapToDockDistance = MagnetismMatcher::kMagneticDistance; |
| 173 | 158 |
| 174 if (dock_alignment == DOCKED_ALIGNMENT_LEFT || | 159 if (dock_alignment == DOCKED_ALIGNMENT_LEFT || |
| 175 dock_alignment == DOCKED_ALIGNMENT_NONE) { | 160 dock_alignment == DOCKED_ALIGNMENT_NONE) { |
| 176 const int distance = bounds.x() - dock_bounds.x(); | 161 const int distance = bounds.x() - dock_bounds.x(); |
| 177 if (distance < kSnapToDockDistance && distance > 0) { | 162 if (distance < kSnapToDockDistance && distance > 0) { |
| (...skipping 19 matching lines...) Expand all Loading... |
| 197 | 182 |
| 198 // Tell the dock layout manager that we are dragging this window. | 183 // Tell the dock layout manager that we are dragging this window. |
| 199 // At this point we are not yet animating the window as it may not be | 184 // At this point we are not yet animating the window as it may not be |
| 200 // inside the docked area. | 185 // inside the docked area. |
| 201 dock_layout_->StartDragging(GetAuraTarget()); | 186 dock_layout_->StartDragging(GetAuraTarget()); |
| 202 if (!resizer) | 187 if (!resizer) |
| 203 return; | 188 return; |
| 204 // Reparent workspace windows during the drag to elevate them above workspace. | 189 // Reparent workspace windows during the drag to elevate them above workspace. |
| 205 // Other windows for which the DockedWindowResizer is instantiated include | 190 // Other windows for which the DockedWindowResizer is instantiated include |
| 206 // panels and windows that are already docked. Those do not need reparenting. | 191 // panels and windows that are already docked. Those do not need reparenting. |
| 207 if (GetAuraTarget()->type() != ui::wm::WINDOW_TYPE_PANEL && | 192 if (GetTarget()->GetType() != ui::wm::WINDOW_TYPE_PANEL && |
| 208 GetAuraTarget()->parent()->id() == kShellWindowId_DefaultContainer) { | 193 GetTarget()->GetParent()->GetShellWindowId() == |
| 194 kShellWindowId_DefaultContainer) { |
| 209 // Reparent the window into the docked windows container in order to get it | 195 // Reparent the window into the docked windows container in order to get it |
| 210 // on top of other docked windows. | 196 // on top of other docked windows. |
| 211 aura::Window* docked_container = Shell::GetContainer( | 197 wm::WmWindow* docked_container = |
| 212 GetAuraTarget()->GetRootWindow(), kShellWindowId_DockedContainer); | 198 GetTarget()->GetRootWindow()->GetChildByShellWindowId( |
| 213 ReparentChildWithTransientChildren( | 199 kShellWindowId_DockedContainer); |
| 214 ash::wm::WmWindowAura::Get(GetAuraTarget()), | 200 ReparentChildWithTransientChildren(GetTarget(), GetTarget()->GetParent(), |
| 215 ash::wm::WmWindowAura::Get(GetAuraTarget()->parent()), | 201 docked_container); |
| 216 ash::wm::WmWindowAura::Get(docked_container)); | |
| 217 if (!resizer) | 202 if (!resizer) |
| 218 return; | 203 return; |
| 219 } | 204 } |
| 220 if (is_docked_) | 205 if (is_docked_) |
| 221 dock_layout_->DockDraggedWindow(GetAuraTarget()); | 206 dock_layout_->DockDraggedWindow(GetAuraTarget()); |
| 222 } | 207 } |
| 223 | 208 |
| 224 void DockedWindowResizer::FinishedDragging( | 209 void DockedWindowResizer::FinishedDragging( |
| 225 aura::client::WindowMoveResult move_result) { | 210 aura::client::WindowMoveResult move_result) { |
| 226 if (!did_move_or_resize_) | 211 if (!did_move_or_resize_) |
| 227 return; | 212 return; |
| 228 did_move_or_resize_ = false; | 213 did_move_or_resize_ = false; |
| 229 aura::Window* window = GetAuraTarget(); | 214 wm::WmWindow* window = GetTarget(); |
| 230 const bool is_attached_panel = window->type() == ui::wm::WINDOW_TYPE_PANEL && | 215 const bool is_attached_panel = |
| 231 window_state_->panel_attached(); | 216 window->GetType() == ui::wm::WINDOW_TYPE_PANEL && |
| 217 window_state_->panel_attached(); |
| 232 const bool is_resized = | 218 const bool is_resized = |
| 233 (details().bounds_change & WindowResizer::kBoundsChange_Resizes) != 0; | 219 (details().bounds_change & WindowResizer::kBoundsChange_Resizes) != 0; |
| 234 | 220 |
| 235 // Undock the window if it is not in the normal, docked or minimized state | 221 // Undock the window if it is not in the normal, docked or minimized state |
| 236 // type. This happens if a user snaps or maximizes a window using a | 222 // type. This happens if a user snaps or maximizes a window using a |
| 237 // keyboard shortcut while it is being dragged. | 223 // keyboard shortcut while it is being dragged. |
| 238 if (!window_state_->IsMinimized() && !window_state_->IsDocked() && | 224 if (!window_state_->IsMinimized() && !window_state_->IsDocked() && |
| 239 !window_state_->IsNormalStateType()) | 225 !window_state_->IsNormalStateType()) |
| 240 is_docked_ = false; | 226 is_docked_ = false; |
| 241 | 227 |
| 242 // When drag is completed the dragged docked window is resized to the bounds | 228 // When drag is completed the dragged docked window is resized to the bounds |
| 243 // calculated by the layout manager that conform to other docked windows. | 229 // calculated by the layout manager that conform to other docked windows. |
| 244 if (!is_attached_panel && is_docked_ && !is_resized) { | 230 if (!is_attached_panel && is_docked_ && !is_resized) { |
| 245 gfx::Rect bounds = ScreenUtil::ConvertRectFromScreen( | 231 gfx::Rect bounds = window->GetParent()->ConvertRectFromScreen( |
| 246 window->parent(), dock_layout_->dragged_bounds()); | 232 dock_layout_->dragged_bounds()); |
| 247 if (!bounds.IsEmpty() && bounds.width() != window->bounds().width()) { | 233 if (!bounds.IsEmpty() && bounds.width() != window->GetBounds().width()) { |
| 248 window->SetBounds(bounds); | 234 window->SetBounds(bounds); |
| 249 } | 235 } |
| 250 } | 236 } |
| 251 // If a window has restore bounds, update the restore origin but not the size. | 237 // If a window has restore bounds, update the restore origin but not the size. |
| 252 // The size gets restored when a window is undocked. | 238 // The size gets restored when a window is undocked. |
| 253 if (is_resized && is_docked_ && window_state_->HasRestoreBounds()) { | 239 if (is_resized && is_docked_ && window_state_->HasRestoreBounds()) { |
| 254 gfx::Rect restore_bounds = window->GetBoundsInScreen(); | 240 gfx::Rect restore_bounds = window->GetBoundsInScreen(); |
| 255 restore_bounds.set_size(window_state_->GetRestoreBoundsInScreen().size()); | 241 restore_bounds.set_size(window_state_->GetRestoreBoundsInScreen().size()); |
| 256 window_state_->SetRestoreBoundsInScreen(restore_bounds); | 242 window_state_->SetRestoreBoundsInScreen(restore_bounds); |
| 257 } | 243 } |
| (...skipping 12 matching lines...) Expand all Loading... |
| 270 if (initial_dock_layout_ != dock_layout_) | 256 if (initial_dock_layout_ != dock_layout_) |
| 271 initial_dock_layout_->FinishDragging( | 257 initial_dock_layout_->FinishDragging( |
| 272 DOCKED_ACTION_NONE, | 258 DOCKED_ACTION_NONE, |
| 273 details().source == aura::client::WINDOW_MOVE_SOURCE_MOUSE ? | 259 details().source == aura::client::WINDOW_MOVE_SOURCE_MOUSE ? |
| 274 DOCKED_ACTION_SOURCE_MOUSE : DOCKED_ACTION_SOURCE_TOUCH); | 260 DOCKED_ACTION_SOURCE_MOUSE : DOCKED_ACTION_SOURCE_TOUCH); |
| 275 is_docked_ = false; | 261 is_docked_ = false; |
| 276 } | 262 } |
| 277 | 263 |
| 278 DockedAction DockedWindowResizer::MaybeReparentWindowOnDragCompletion( | 264 DockedAction DockedWindowResizer::MaybeReparentWindowOnDragCompletion( |
| 279 bool is_resized, bool is_attached_panel) { | 265 bool is_resized, bool is_attached_panel) { |
| 280 aura::Window* window = GetAuraTarget(); | 266 wm::WmWindow* window = GetTarget(); |
| 281 | 267 |
| 282 // Check if the window needs to be docked or returned to workspace. | 268 // Check if the window needs to be docked or returned to workspace. |
| 283 DockedAction action = DOCKED_ACTION_NONE; | 269 DockedAction action = DOCKED_ACTION_NONE; |
| 284 aura::Window* dock_container = Shell::GetContainer( | 270 wm::WmWindow* dock_container = |
| 285 window->GetRootWindow(), | 271 window->GetRootWindow()->GetChildByShellWindowId( |
| 286 kShellWindowId_DockedContainer); | 272 kShellWindowId_DockedContainer); |
| 287 if ((is_resized || !is_attached_panel) && | 273 if ((is_resized || !is_attached_panel) && |
| 288 is_docked_ != (window->parent() == dock_container)) { | 274 is_docked_ != (window->GetParent() == dock_container)) { |
| 289 if (is_docked_) { | 275 if (is_docked_) { |
| 290 wm::ReparentChildWithTransientChildren( | 276 wm::ReparentChildWithTransientChildren(window, window->GetParent(), |
| 291 wm::WmWindowAura::Get(window), | 277 dock_container); |
| 292 wm::WmWindowAura::Get(window->parent()), | |
| 293 wm::WmWindowAura::Get(dock_container)); | |
| 294 action = DOCKED_ACTION_DOCK; | 278 action = DOCKED_ACTION_DOCK; |
| 295 } else if (window->parent()->id() == kShellWindowId_DockedContainer) { | 279 } else if (window->GetParent()->GetShellWindowId() == |
| 280 kShellWindowId_DockedContainer) { |
| 296 // Reparent the window back to workspace. | 281 // Reparent the window back to workspace. |
| 297 // We need to be careful to give ParentWindowWithContext a location in | 282 // We need to be careful to give ParentWindowWithContext a location in |
| 298 // the right root window (matching the logic in DragWindowResizer) based | 283 // the right root window (matching the logic in DragWindowResizer) based |
| 299 // on which root window a mouse pointer is in. We want to undock into the | 284 // on which root window a mouse pointer is in. We want to undock into the |
| 300 // right screen near the edge of a multiscreen setup (based on where the | 285 // right screen near the edge of a multiscreen setup (based on where the |
| 301 // mouse is). | 286 // mouse is). |
| 302 gfx::Rect near_last_location(last_location_, gfx::Size()); | 287 gfx::Rect near_last_location(last_location_, gfx::Size()); |
| 303 // Reparenting will cause Relayout and possible dock shrinking. | 288 // Reparenting will cause Relayout and possible dock shrinking. |
| 304 aura::Window* previous_parent = window->parent(); | 289 wm::WmWindow* previous_parent = window->GetParent(); |
| 305 aura::client::ParentWindowWithContext(window, window, near_last_location); | 290 window->SetParentUsingContext(window, near_last_location); |
| 306 if (window->parent() != previous_parent) { | 291 if (window->GetParent() != previous_parent) { |
| 307 wm::ReparentTransientChildrenOfChild( | 292 wm::ReparentTransientChildrenOfChild(window, previous_parent, |
| 308 ash::wm::WmWindowAura::Get(window), | 293 window->GetParent()); |
| 309 ash::wm::WmWindowAura::Get(previous_parent), | |
| 310 ash::wm::WmWindowAura::Get(window->parent())); | |
| 311 } | 294 } |
| 312 action = was_docked_ ? DOCKED_ACTION_UNDOCK : DOCKED_ACTION_NONE; | 295 action = was_docked_ ? DOCKED_ACTION_UNDOCK : DOCKED_ACTION_NONE; |
| 313 } | 296 } |
| 314 } else { | 297 } else { |
| 315 // |action| is recorded in UMA and used to maintain |window_state_|. | 298 // |action| is recorded in UMA and used to maintain |window_state_|. |
| 316 if (is_resized && is_docked_ && was_docked_) | 299 if (is_resized && is_docked_ && was_docked_) |
| 317 action = DOCKED_ACTION_RESIZE; | 300 action = DOCKED_ACTION_RESIZE; |
| 318 else if (is_docked_ && was_docked_) | 301 else if (is_docked_ && was_docked_) |
| 319 action = DOCKED_ACTION_REORDER; | 302 action = DOCKED_ACTION_REORDER; |
| 320 else if (is_docked_ && !was_docked_) | 303 else if (is_docked_ && !was_docked_) |
| 321 action = DOCKED_ACTION_DOCK; | 304 action = DOCKED_ACTION_DOCK; |
| 322 else if (!is_docked_ && was_docked_) | 305 else if (!is_docked_ && was_docked_) |
| 323 action = DOCKED_ACTION_UNDOCK; | 306 action = DOCKED_ACTION_UNDOCK; |
| 324 else | 307 else |
| 325 action = DOCKED_ACTION_NONE; | 308 action = DOCKED_ACTION_NONE; |
| 326 } | 309 } |
| 327 // When a window is newly docked it is auto-sized by docked layout adjusting | 310 // When a window is newly docked it is auto-sized by docked layout adjusting |
| 328 // to other windows. If it is just dragged (but not resized) while being | 311 // to other windows. If it is just dragged (but not resized) while being |
| 329 // docked it is auto-sized unless it has been resized while being docked | 312 // docked it is auto-sized unless it has been resized while being docked |
| 330 // before. | 313 // before. |
| 331 if (is_docked_) { | 314 if (is_docked_) { |
| 332 wm::GetWindowState(window)->set_bounds_changed_by_user( | 315 window->GetWindowState()->set_bounds_changed_by_user( |
| 333 was_docked_ && (is_resized || was_bounds_changed_by_user_)); | 316 was_docked_ && (is_resized || was_bounds_changed_by_user_)); |
| 334 } | 317 } |
| 335 | 318 |
| 336 if (action == DOCKED_ACTION_DOCK) { | 319 if (action == DOCKED_ACTION_DOCK) { |
| 337 const wm::WMEvent event(wm::WM_EVENT_DOCK); | 320 const wm::WMEvent event(wm::WM_EVENT_DOCK); |
| 338 window_state_->OnWMEvent(&event); | 321 window_state_->OnWMEvent(&event); |
| 339 } else if (wm::GetWindowState(window)->IsDocked() && | 322 } else if (window->GetWindowState()->IsDocked() && |
| 340 action == DOCKED_ACTION_UNDOCK) { | 323 action == DOCKED_ACTION_UNDOCK) { |
| 341 const wm::WMEvent event(wm::WM_EVENT_NORMAL); | 324 const wm::WMEvent event(wm::WM_EVENT_NORMAL); |
| 342 window_state_->OnWMEvent(&event); | 325 window_state_->OnWMEvent(&event); |
| 343 } | 326 } |
| 344 | 327 |
| 345 return action; | 328 return action; |
| 346 } | 329 } |
| 347 | 330 |
| 348 } // namespace ash | 331 } // namespace ash |
| OLD | NEW |