Chromium Code Reviews| 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_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/dock/docked_window_layout_manager.h" | 15 #include "ash/wm/dock/docked_window_layout_manager.h" |
| 16 #include "ash/wm/window_state.h" | 16 #include "ash/wm/window_state.h" |
| 17 #include "ash/wm/window_util.h" | 17 #include "ash/wm/window_util.h" |
| 18 #include "ash/wm/wm_event.h" | |
| 18 #include "ash/wm/workspace/magnetism_matcher.h" | 19 #include "ash/wm/workspace/magnetism_matcher.h" |
| 19 #include "ash/wm/workspace/workspace_window_resizer.h" | 20 #include "ash/wm/workspace/workspace_window_resizer.h" |
| 20 #include "base/command_line.h" | 21 #include "base/command_line.h" |
| 21 #include "base/memory/weak_ptr.h" | 22 #include "base/memory/weak_ptr.h" |
| 22 #include "ui/aura/client/aura_constants.h" | 23 #include "ui/aura/client/aura_constants.h" |
| 23 #include "ui/aura/client/window_tree_client.h" | 24 #include "ui/aura/client/window_tree_client.h" |
| 24 #include "ui/aura/env.h" | 25 #include "ui/aura/env.h" |
| 25 #include "ui/aura/window.h" | 26 #include "ui/aura/window.h" |
| 26 #include "ui/aura/window_delegate.h" | 27 #include "ui/aura/window_delegate.h" |
| 27 #include "ui/aura/window_event_dispatcher.h" | 28 #include "ui/aura/window_event_dispatcher.h" |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 215 did_move_or_resize_ = false; | 216 did_move_or_resize_ = false; |
| 216 aura::Window* window = GetTarget(); | 217 aura::Window* window = GetTarget(); |
| 217 const bool is_attached_panel = window->type() == ui::wm::WINDOW_TYPE_PANEL && | 218 const bool is_attached_panel = window->type() == ui::wm::WINDOW_TYPE_PANEL && |
| 218 window_state_->panel_attached(); | 219 window_state_->panel_attached(); |
| 219 const bool is_resized = | 220 const bool is_resized = |
| 220 (details().bounds_change & WindowResizer::kBoundsChange_Resizes) != 0; | 221 (details().bounds_change & WindowResizer::kBoundsChange_Resizes) != 0; |
| 221 | 222 |
| 222 // Undock the window if it is not in the normal or minimized state type. This | 223 // Undock the window if it is not in the normal or minimized state type. This |
| 223 // happens if a user snaps or maximizes a window using a keyboard shortcut | 224 // happens if a user snaps or maximizes a window using a keyboard shortcut |
| 224 // while it is being dragged. | 225 // while it is being dragged. |
| 225 if (!window_state_->IsMinimized() && !window_state_->IsNormalStateType()) | 226 if (!window_state_->IsMinimized() && !window_state_->IsDocked() && |
| 227 !window_state_->IsNormalStateType()) | |
| 226 is_docked_ = false; | 228 is_docked_ = false; |
| 227 | 229 |
| 228 // When drag is completed the dragged docked window is resized to the bounds | 230 // When drag is completed the dragged docked window is resized to the bounds |
| 229 // calculated by the layout manager that conform to other docked windows. | 231 // calculated by the layout manager that conform to other docked windows. |
| 230 if (!is_attached_panel && is_docked_ && !is_resized) { | 232 if (!is_attached_panel && is_docked_ && !is_resized) { |
| 231 gfx::Rect bounds = ScreenUtil::ConvertRectFromScreen( | 233 gfx::Rect bounds = ScreenUtil::ConvertRectFromScreen( |
| 232 window->parent(), dock_layout_->dragged_bounds()); | 234 window->parent(), dock_layout_->dragged_bounds()); |
| 233 if (!bounds.IsEmpty() && bounds.width() != window->bounds().width()) { | 235 if (!bounds.IsEmpty() && bounds.width() != window->bounds().width()) { |
| 234 window->SetBounds(bounds); | 236 window->SetBounds(bounds); |
| 235 } | 237 } |
| 236 } | 238 } |
| 237 // If a window has restore bounds, update the restore origin and width but not | 239 // If a window has restore bounds, update the restore origin and width but not |
| 238 // the height (since the height is auto-calculated for the docked windows). | 240 // the height (since the height is auto-calculated for the docked windows). |
| 239 if (is_resized && is_docked_ && window_state_->HasRestoreBounds()) { | 241 if (is_resized && is_docked_ && window_state_->HasRestoreBounds()) { |
| 240 gfx::Rect restore_bounds = window->GetBoundsInScreen(); | 242 gfx::Rect restore_bounds = window->GetBoundsInScreen(); |
| 241 restore_bounds.set_height( | 243 restore_bounds.set_height( |
| 242 window_state_->GetRestoreBoundsInScreen().height()); | 244 window_state_->GetRestoreBoundsInScreen().height()); |
| 243 window_state_->SetRestoreBoundsInScreen(restore_bounds); | 245 window_state_->SetRestoreBoundsInScreen(restore_bounds); |
| 244 } | 246 } |
| 245 | 247 |
| 248 if (move_result != aura::client::MOVE_CANCELED && is_docked_ != was_docked_) { | |
| 249 if (is_docked_) { | |
| 250 const wm::WMEvent event(wm::WM_EVENT_DOCK); | |
| 251 window_state_->OnWMEvent(&event); | |
| 252 } else if (window_state_->IsDocked()) { | |
| 253 const wm::WMEvent event(wm::WM_EVENT_NORMAL); | |
| 254 window_state_->OnWMEvent(&event); | |
| 255 } | |
| 256 } | |
| 257 | |
| 246 // Check if the window needs to be docked or returned to workspace. | 258 // Check if the window needs to be docked or returned to workspace. |
| 247 DockedAction action = MaybeReparentWindowOnDragCompletion(is_resized, | 259 DockedAction action = MaybeReparentWindowOnDragCompletion(is_resized, |
| 248 is_attached_panel); | 260 is_attached_panel); |
|
varkha
2014/09/25 22:09:28
There is still an outstanding comment here about M
dtapuska
2014/09/26 14:17:07
I moved the code around; so the event sending is i
| |
| 249 dock_layout_->FinishDragging( | 261 dock_layout_->FinishDragging( |
| 250 move_result == aura::client::MOVE_CANCELED ? DOCKED_ACTION_NONE : action, | 262 move_result == aura::client::MOVE_CANCELED ? DOCKED_ACTION_NONE : action, |
| 251 details().source == aura::client::WINDOW_MOVE_SOURCE_MOUSE ? | 263 details().source == aura::client::WINDOW_MOVE_SOURCE_MOUSE ? |
| 252 DOCKED_ACTION_SOURCE_MOUSE : DOCKED_ACTION_SOURCE_TOUCH); | 264 DOCKED_ACTION_SOURCE_MOUSE : DOCKED_ACTION_SOURCE_TOUCH); |
| 253 | 265 |
| 254 // If we started the drag in one root window and moved into another root | 266 // If we started the drag in one root window and moved into another root |
| 255 // but then canceled the drag we may need to inform the original layout | 267 // but then canceled the drag we may need to inform the original layout |
| 256 // manager that the drag is finished. | 268 // manager that the drag is finished. |
| 257 if (initial_dock_layout_ != dock_layout_) | 269 if (initial_dock_layout_ != dock_layout_) |
| 258 initial_dock_layout_->FinishDragging( | 270 initial_dock_layout_->FinishDragging( |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 312 // docked it is auto-sized unless it has been resized while being docked | 324 // docked it is auto-sized unless it has been resized while being docked |
| 313 // before. | 325 // before. |
| 314 if (is_docked_) { | 326 if (is_docked_) { |
| 315 wm::GetWindowState(window)->set_bounds_changed_by_user( | 327 wm::GetWindowState(window)->set_bounds_changed_by_user( |
| 316 was_docked_ && (is_resized || was_bounds_changed_by_user_)); | 328 was_docked_ && (is_resized || was_bounds_changed_by_user_)); |
| 317 } | 329 } |
| 318 return action; | 330 return action; |
| 319 } | 331 } |
| 320 | 332 |
| 321 } // namespace ash | 333 } // namespace ash |
| OLD | NEW |