Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(38)

Side by Side Diff: ash/wm/workspace/workspace_window_resizer.cc

Issue 23471004: Only support left/right maximizing at 50% width when the --ash-enable-alternate-caption-button (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Patch is now friendlier to pending docking changes Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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
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()))
859 return;
860
861 if (window()->type() == aura::client::WINDOW_TYPE_PANEL && 857 if (window()->type() == aura::client::WINDOW_TYPE_PANEL &&
862 window()->GetProperty(kPanelAttachedKey)) { 858 window()->GetProperty(kPanelAttachedKey)) {
863 return; 859 return;
864 } 860 }
865 861
866 SnapType last_type = snap_type_; 862 SnapType last_type = snap_type_;
867 snap_type_ = GetSnapType(location); 863 snap_type_ = GetSnapType(location);
868 if (snap_type_ == SNAP_NONE || snap_type_ != last_type) { 864 using internal::SnapSizer;
865 SnapSizer::Edge edge = (snap_type_ == SNAP_LEFT_EDGE) ?
866 SnapSizer::LEFT_EDGE : SnapSizer::RIGHT_EDGE;
867 if (snap_type_ == SNAP_NONE ||
868 !SnapSizer::CanSnapWindow(window(), edge)) {
869 snap_type_ = SNAP_NONE;
869 snap_phantom_window_controller_.reset(); 870 snap_phantom_window_controller_.reset();
870 snap_sizer_.reset(); 871 snap_sizer_.reset();
871 if (snap_type_ == SNAP_NONE) 872 return;
872 return;
873 } 873 }
874 if (!snap_sizer_) { 874
875 SnapSizer::Edge edge = (snap_type_ == SNAP_LEFT_EDGE) ? 875 if (snap_type_ != last_type ||
varkha 2013/08/30 17:13:25 Will the animations be smoother if we don't re-cre
pkotwicz 2013/08/30 21:10:57 I believe that you always transition through SNAP_
876 SnapSizer::LEFT_EDGE : SnapSizer::RIGHT_EDGE; 876 !snap_sizer_ ||
877 snap_sizer_.reset(new SnapSizer(window(), 877 !snap_phantom_window_controller_) {
878 location, 878 snap_sizer_.reset(
879 edge, 879 new SnapSizer(window(), location, edge, SnapSizer::STEP_YES));
880 internal::SnapSizer::OTHER_INPUT)); 880 snap_phantom_window_controller_.reset(
881 new PhantomWindowController(window()));
881 } else { 882 } else {
882 snap_sizer_->Update(location); 883 snap_sizer_->Update(location);
883 } 884 }
884 if (!snap_phantom_window_controller_) {
885 snap_phantom_window_controller_.reset(
886 new PhantomWindowController(window()));
887 }
888 snap_phantom_window_controller_->Show(ScreenAsh::ConvertRectToScreen( 885 snap_phantom_window_controller_->Show(ScreenAsh::ConvertRectToScreen(
889 window()->parent(), snap_sizer_->target_bounds())); 886 window()->parent(), snap_sizer_->target_bounds()));
890 } 887 }
891 888
892 void WorkspaceWindowResizer::RestackWindows() { 889 void WorkspaceWindowResizer::RestackWindows() {
893 if (attached_windows_.empty()) 890 if (attached_windows_.empty())
894 return; 891 return;
895 // Build a map from index in children to window, returning if there is a 892 // Build a map from index in children to window, returning if there is a
896 // window with a different parent. 893 // window with a different parent.
897 typedef std::map<size_t, aura::Window*> IndexToWindowMap; 894 typedef std::map<size_t, aura::Window*> IndexToWindowMap;
(...skipping 29 matching lines...) Expand all
927 gfx::Rect area(ScreenAsh::GetDisplayBoundsInParent(window())); 924 gfx::Rect area(ScreenAsh::GetDisplayBoundsInParent(window()));
928 if (location.x() <= area.x()) 925 if (location.x() <= area.x())
929 return SNAP_LEFT_EDGE; 926 return SNAP_LEFT_EDGE;
930 if (location.x() >= area.right() - 1) 927 if (location.x() >= area.right() - 1)
931 return SNAP_RIGHT_EDGE; 928 return SNAP_RIGHT_EDGE;
932 return SNAP_NONE; 929 return SNAP_NONE;
933 } 930 }
934 931
935 } // namespace internal 932 } // namespace internal
936 } // namespace ash 933 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698