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 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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()->set_bounds_changed_by_user(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 bool is_snapped = false; |
439 // When the window is not in the normal show state, we do not snap the window. | 440 // 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 | 441 // 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 | 442 // 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 | 443 // out of a maximized window, it's already in the normal show state when this |
443 // is called, so it does not matter. | 444 // is called, so it does not matter. |
444 if (window_state()->IsNormalShowState() && | 445 if (window_state()->IsNormalShowState() && |
445 (window()->type() != aura::client::WINDOW_TYPE_PANEL || | 446 (window()->type() != aura::client::WINDOW_TYPE_PANEL || |
446 !window_state()->panel_attached() || | 447 !window_state()->panel_attached() || |
447 dock_layout_->is_dragged_window_docked()) && | 448 dock_layout_->is_dragged_window_docked()) && |
448 (snap_type_ == SNAP_LEFT || snap_type_ == SNAP_RIGHT)) { | 449 (snap_type_ == SNAP_LEFT || snap_type_ == SNAP_RIGHT)) { |
449 if (!window_state()->HasRestoreBounds()) { | 450 if (!window_state()->HasRestoreBounds()) { |
450 gfx::Rect initial_bounds = ScreenAsh::ConvertRectToScreen( | 451 gfx::Rect initial_bounds = ScreenAsh::ConvertRectToScreen( |
451 window()->parent(), details_.initial_bounds_in_parent); | 452 window()->parent(), details_.initial_bounds_in_parent); |
452 window_state()->SetRestoreBoundsInScreen( | 453 window_state()->SetRestoreBoundsInScreen( |
453 details_.restore_bounds.IsEmpty() ? | 454 details_.restore_bounds.IsEmpty() ? |
454 initial_bounds : | 455 initial_bounds : |
455 details_.restore_bounds); | 456 details_.restore_bounds); |
456 } | 457 } |
457 DCHECK(snap_sizer_); | 458 DCHECK(snap_sizer_); |
458 if (window_state()->CanResize() && | 459 if (window_state()->CanResize() && |
459 !dock_layout_->is_dragged_window_docked()) { | 460 !dock_layout_->is_dragged_window_docked()) { |
460 snap_sizer_->SnapWindowToTargetBounds(); | 461 snap_sizer_->SnapWindowToTargetBounds(); |
| 462 is_snapped = true; |
461 } | 463 } |
462 } | 464 } |
| 465 if (window_state()->IsSnapped() && !is_snapped) |
| 466 window_state()->Restore(); |
463 } | 467 } |
464 | 468 |
465 void WorkspaceWindowResizer::RevertDrag() { | 469 void WorkspaceWindowResizer::RevertDrag() { |
466 window_state()->set_bounds_changed_by_user(initial_bounds_changed_by_user_); | 470 window_state()->set_bounds_changed_by_user(initial_bounds_changed_by_user_); |
467 snap_phantom_window_controller_.reset(); | 471 snap_phantom_window_controller_.reset(); |
468 | 472 |
469 if (!did_move_or_resize_) | 473 if (!did_move_or_resize_) |
470 return; | 474 return; |
471 | 475 |
472 window()->SetBounds(details_.initial_bounds_in_parent); | 476 window()->SetBounds(details_.initial_bounds_in_parent); |
(...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1038 } else { | 1042 } else { |
1039 if (dock_layout_->is_dragged_window_docked()) { | 1043 if (dock_layout_->is_dragged_window_docked()) { |
1040 dock_layout_->UndockDraggedWindow(); | 1044 dock_layout_->UndockDraggedWindow(); |
1041 window_state()->set_bounds_changed_by_user(true); | 1045 window_state()->set_bounds_changed_by_user(true); |
1042 } | 1046 } |
1043 } | 1047 } |
1044 } | 1048 } |
1045 | 1049 |
1046 } // namespace internal | 1050 } // namespace internal |
1047 } // namespace ash | 1051 } // namespace ash |
OLD | NEW |