OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/workspace/workspace_window_resizer.h" | 5 #include "ash/wm/workspace/workspace_window_resizer.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cmath> | 8 #include <cmath> |
9 #include <utility> | 9 #include <utility> |
10 #include <vector> | 10 #include <vector> |
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
424 UpdateSnapPhantomWindow(location_in_parent, bounds); | 424 UpdateSnapPhantomWindow(location_in_parent, bounds); |
425 } else { | 425 } else { |
426 snap_type_ = SNAP_NONE; | 426 snap_type_ = SNAP_NONE; |
427 snap_phantom_window_controller_.reset(); | 427 snap_phantom_window_controller_.reset(); |
428 snap_sizer_.reset(); | 428 snap_sizer_.reset(); |
429 SetDraggedWindowDocked(false); | 429 SetDraggedWindowDocked(false); |
430 } | 430 } |
431 } | 431 } |
432 | 432 |
433 void WorkspaceWindowResizer::CompleteDrag(int event_flags) { | 433 void WorkspaceWindowResizer::CompleteDrag(int event_flags) { |
434 window_state()->set_bounds_changed_by_user(true); | 434 window_state()->SetBoundsChangedByUser(true); |
435 snap_phantom_window_controller_.reset(); | 435 snap_phantom_window_controller_.reset(); |
436 if (!did_move_or_resize_ || details_.window_component != HTCAPTION) | 436 if (!did_move_or_resize_ || details_.window_component != HTCAPTION) |
437 return; | 437 return; |
438 | 438 |
439 // When the window is not in the normal show state, we do not snap the window. | 439 // When the window is not in the normal show state, we do not snap the window. |
440 // This happens when the user minimizes or maximizes the window by keyboard | 440 // This happens when the user minimizes or maximizes the window by keyboard |
441 // shortcut while dragging it. If the window is the result of dragging a tab | 441 // shortcut while dragging it. If the window is the result of dragging a tab |
442 // out of a maximized window, it's already in the normal show state when this | 442 // out of a maximized window, it's already in the normal show state when this |
443 // is called, so it does not matter. | 443 // is called, so it does not matter. |
444 if (window_state()->IsNormalShowState() && | 444 if (window_state()->IsNormalShowState() && |
(...skipping 11 matching lines...) Expand all Loading... |
456 } | 456 } |
457 DCHECK(snap_sizer_); | 457 DCHECK(snap_sizer_); |
458 if (window_state()->CanResize() && | 458 if (window_state()->CanResize() && |
459 !dock_layout_->is_dragged_window_docked()) { | 459 !dock_layout_->is_dragged_window_docked()) { |
460 snap_sizer_->SnapWindowToTargetBounds(); | 460 snap_sizer_->SnapWindowToTargetBounds(); |
461 } | 461 } |
462 } | 462 } |
463 } | 463 } |
464 | 464 |
465 void WorkspaceWindowResizer::RevertDrag() { | 465 void WorkspaceWindowResizer::RevertDrag() { |
466 window_state()->set_bounds_changed_by_user(initial_bounds_changed_by_user_); | 466 window_state()->SetBoundsChangedByUser(initial_bounds_changed_by_user_); |
467 snap_phantom_window_controller_.reset(); | 467 snap_phantom_window_controller_.reset(); |
468 | 468 |
469 if (!did_move_or_resize_) | 469 if (!did_move_or_resize_) |
470 return; | 470 return; |
471 | 471 |
472 window()->SetBounds(details_.initial_bounds_in_parent); | 472 window()->SetBounds(details_.initial_bounds_in_parent); |
473 if (!details_.restore_bounds.IsEmpty()) { | 473 if (!details_.restore_bounds.IsEmpty()) { |
474 window_state()->SetRestoreBoundsInScreen(details_.restore_bounds); | 474 window_state()->SetRestoreBoundsInScreen(details_.restore_bounds); |
475 } | 475 } |
476 | 476 |
(...skipping 548 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1025 return SNAP_LEFT; | 1025 return SNAP_LEFT; |
1026 if (location.x() >= area.right() - 1) | 1026 if (location.x() >= area.right() - 1) |
1027 return SNAP_RIGHT; | 1027 return SNAP_RIGHT; |
1028 return SNAP_NONE; | 1028 return SNAP_NONE; |
1029 } | 1029 } |
1030 | 1030 |
1031 void WorkspaceWindowResizer::SetDraggedWindowDocked(bool should_dock) { | 1031 void WorkspaceWindowResizer::SetDraggedWindowDocked(bool should_dock) { |
1032 if (should_dock && | 1032 if (should_dock && |
1033 dock_layout_->GetAlignmentOfWindow(window()) != DOCKED_ALIGNMENT_NONE) { | 1033 dock_layout_->GetAlignmentOfWindow(window()) != DOCKED_ALIGNMENT_NONE) { |
1034 if (!dock_layout_->is_dragged_window_docked()) { | 1034 if (!dock_layout_->is_dragged_window_docked()) { |
1035 window_state()->set_bounds_changed_by_user(false); | 1035 window_state()->SetBoundsChangedByUser(false); |
1036 dock_layout_->DockDraggedWindow(window()); | 1036 dock_layout_->DockDraggedWindow(window()); |
1037 } | 1037 } |
1038 } else { | 1038 } else { |
1039 if (dock_layout_->is_dragged_window_docked()) { | 1039 if (dock_layout_->is_dragged_window_docked()) { |
1040 dock_layout_->UndockDraggedWindow(); | 1040 dock_layout_->UndockDraggedWindow(); |
1041 window_state()->set_bounds_changed_by_user(true); | 1041 window_state()->SetBoundsChangedByUser(true); |
1042 } | 1042 } |
1043 } | 1043 } |
1044 } | 1044 } |
1045 | 1045 |
1046 } // namespace internal | 1046 } // namespace internal |
1047 } // namespace ash | 1047 } // namespace ash |
OLD | NEW |