| 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 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 415 (window()->type() != aura::client::WINDOW_TYPE_PANEL || | 415 (window()->type() != aura::client::WINDOW_TYPE_PANEL || |
| 416 !window()->GetProperty(kPanelAttachedKey)) && | 416 !window()->GetProperty(kPanelAttachedKey)) && |
| 417 (snap_type_ == SNAP_LEFT_EDGE || snap_type_ == SNAP_RIGHT_EDGE)) { | 417 (snap_type_ == SNAP_LEFT_EDGE || snap_type_ == SNAP_RIGHT_EDGE)) { |
| 418 if (!GetRestoreBoundsInScreen(window())) { | 418 if (!GetRestoreBoundsInScreen(window())) { |
| 419 gfx::Rect initial_bounds = ScreenAsh::ConvertRectToScreen( | 419 gfx::Rect initial_bounds = ScreenAsh::ConvertRectToScreen( |
| 420 window()->parent(), details_.initial_bounds_in_parent); | 420 window()->parent(), details_.initial_bounds_in_parent); |
| 421 SetRestoreBoundsInScreen(window(), details_.restore_bounds.IsEmpty() ? | 421 SetRestoreBoundsInScreen(window(), details_.restore_bounds.IsEmpty() ? |
| 422 initial_bounds : | 422 initial_bounds : |
| 423 details_.restore_bounds); | 423 details_.restore_bounds); |
| 424 } | 424 } |
| 425 window()->SetBounds(snap_sizer_->target_bounds()); | 425 snap_sizer_->Snap(); |
| 426 return; | |
| 427 } | 426 } |
| 428 } | 427 } |
| 429 | 428 |
| 430 void WorkspaceWindowResizer::RevertDrag() { | 429 void WorkspaceWindowResizer::RevertDrag() { |
| 431 snap_phantom_window_controller_.reset(); | 430 snap_phantom_window_controller_.reset(); |
| 432 | 431 |
| 433 if (!did_move_or_resize_) | 432 if (!did_move_or_resize_) |
| 434 return; | 433 return; |
| 435 | 434 |
| 436 window()->SetBounds(details_.initial_bounds_in_parent); | 435 window()->SetBounds(details_.initial_bounds_in_parent); |
| (...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 848 NOTREACHED(); | 847 NOTREACHED(); |
| 849 } | 848 } |
| 850 return 0; | 849 return 0; |
| 851 } | 850 } |
| 852 | 851 |
| 853 void WorkspaceWindowResizer::UpdateSnapPhantomWindow(const gfx::Point& location, | 852 void WorkspaceWindowResizer::UpdateSnapPhantomWindow(const gfx::Point& location, |
| 854 const gfx::Rect& bounds) { | 853 const gfx::Rect& bounds) { |
| 855 if (!did_move_or_resize_ || details_.window_component != HTCAPTION) | 854 if (!did_move_or_resize_ || details_.window_component != HTCAPTION) |
| 856 return; | 855 return; |
| 857 | 856 |
| 858 if (!wm::CanSnapWindow(window())) | 857 if (!SnapSizer::CanSnapWindow(window())) |
| 859 return; | 858 return; |
| 860 | 859 |
| 861 if (window()->type() == aura::client::WINDOW_TYPE_PANEL && | 860 if (window()->type() == aura::client::WINDOW_TYPE_PANEL && |
| 862 window()->GetProperty(kPanelAttachedKey)) { | 861 window()->GetProperty(kPanelAttachedKey)) { |
| 863 return; | 862 return; |
| 864 } | 863 } |
| 865 | 864 |
| 866 SnapType last_type = snap_type_; | 865 SnapType last_type = snap_type_; |
| 867 snap_type_ = GetSnapType(location); | 866 snap_type_ = GetSnapType(location); |
| 868 if (snap_type_ == SNAP_NONE || snap_type_ != last_type) { | 867 if (snap_type_ == SNAP_NONE || snap_type_ != last_type) { |
| 869 snap_phantom_window_controller_.reset(); | 868 snap_phantom_window_controller_.reset(); |
| 870 snap_sizer_.reset(); | 869 snap_sizer_.reset(); |
| 871 if (snap_type_ == SNAP_NONE) | 870 if (snap_type_ == SNAP_NONE) |
| 872 return; | 871 return; |
| 873 } | 872 } |
| 874 if (!snap_sizer_) { | 873 if (!snap_sizer_) { |
| 875 SnapSizer::Edge edge = (snap_type_ == SNAP_LEFT_EDGE) ? | 874 SnapSizer::Edge edge = (snap_type_ == SNAP_LEFT_EDGE) ? |
| 876 SnapSizer::LEFT_EDGE : SnapSizer::RIGHT_EDGE; | 875 SnapSizer::LEFT_EDGE : SnapSizer::RIGHT_EDGE; |
| 877 snap_sizer_.reset(new SnapSizer(window(), | 876 snap_sizer_.reset(new SnapSizer(window(), |
| 878 location, | 877 location, |
| 879 edge, | 878 edge, |
| 880 internal::SnapSizer::OTHER_INPUT)); | 879 SnapSizer::STEP_YES)); |
| 881 } else { | 880 } else { |
| 882 snap_sizer_->Update(location); | 881 snap_sizer_->Update(location); |
| 883 } | 882 } |
| 884 if (!snap_phantom_window_controller_) { | 883 if (!snap_phantom_window_controller_) { |
| 885 snap_phantom_window_controller_.reset( | 884 snap_phantom_window_controller_.reset( |
| 886 new PhantomWindowController(window())); | 885 new PhantomWindowController(window())); |
| 887 } | 886 } |
| 888 snap_phantom_window_controller_->Show(ScreenAsh::ConvertRectToScreen( | 887 snap_phantom_window_controller_->Show(ScreenAsh::ConvertRectToScreen( |
| 889 window()->parent(), snap_sizer_->target_bounds())); | 888 window()->parent(), snap_sizer_->target_bounds())); |
| 890 } | 889 } |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 927 gfx::Rect area(ScreenAsh::GetDisplayBoundsInParent(window())); | 926 gfx::Rect area(ScreenAsh::GetDisplayBoundsInParent(window())); |
| 928 if (location.x() <= area.x()) | 927 if (location.x() <= area.x()) |
| 929 return SNAP_LEFT_EDGE; | 928 return SNAP_LEFT_EDGE; |
| 930 if (location.x() >= area.right() - 1) | 929 if (location.x() >= area.right() - 1) |
| 931 return SNAP_RIGHT_EDGE; | 930 return SNAP_RIGHT_EDGE; |
| 932 return SNAP_NONE; | 931 return SNAP_NONE; |
| 933 } | 932 } |
| 934 | 933 |
| 935 } // namespace internal | 934 } // namespace internal |
| 936 } // namespace ash | 935 } // namespace ash |
| OLD | NEW |