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() && |
|
varkha
2014/09/29 18:59:28
Can you comment why this change is necessary?
dtapuska
2014/09/29 20:59:57
Previously docked windows were normal state type w
| |
| 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 } |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 308 action = DOCKED_ACTION_NONE; | 310 action = DOCKED_ACTION_NONE; |
| 309 } | 311 } |
| 310 // When a window is newly docked it is auto-sized by docked layout adjusting | 312 // When a window is newly docked it is auto-sized by docked layout adjusting |
| 311 // to other windows. If it is just dragged (but not resized) while being | 313 // to other windows. If it is just dragged (but not resized) while being |
| 312 // docked it is auto-sized unless it has been resized while being docked | 314 // docked it is auto-sized unless it has been resized while being docked |
| 313 // before. | 315 // before. |
| 314 if (is_docked_) { | 316 if (is_docked_) { |
| 315 wm::GetWindowState(window)->set_bounds_changed_by_user( | 317 wm::GetWindowState(window)->set_bounds_changed_by_user( |
| 316 was_docked_ && (is_resized || was_bounds_changed_by_user_)); | 318 was_docked_ && (is_resized || was_bounds_changed_by_user_)); |
| 317 } | 319 } |
| 320 | |
| 321 if (action == DOCKED_ACTION_DOCK) { | |
| 322 const wm::WMEvent event(wm::WM_EVENT_DOCK); | |
| 323 window_state_->OnWMEvent(&event); | |
| 324 } else if (wm::GetWindowState(window)->IsDocked() && | |
| 325 action == DOCKED_ACTION_UNDOCK) { | |
| 326 const wm::WMEvent event(wm::WM_EVENT_NORMAL); | |
| 327 window_state_->OnWMEvent(&event); | |
| 328 } | |
| 329 | |
| 318 return action; | 330 return action; |
| 319 } | 331 } |
| 320 | 332 |
| 321 } // namespace ash | 333 } // namespace ash |
| OLD | NEW |