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

Side by Side Diff: ash/wm/gestures/system_pinch_handler.cc

Issue 11434004: ash: Refactor some code that snaps windows. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years 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/gestures/system_pinch_handler.h" 5 #include "ash/wm/gestures/system_pinch_handler.h"
6 6
7 #include "ash/launcher/launcher.h" 7 #include "ash/launcher/launcher.h"
8 #include "ash/screen_ash.h" 8 #include "ash/screen_ash.h"
9 #include "ash/shell.h" 9 #include "ash/shell.h"
10 #include "ash/wm/property_util.h" 10 #include "ash/wm/property_util.h"
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 phantom_.Show(bounds, NULL); 76 phantom_.Show(bounds, NULL);
77 break; 77 break;
78 } 78 }
79 79
80 case ui::ET_GESTURE_MULTIFINGER_SWIPE: { 80 case ui::ET_GESTURE_MULTIFINGER_SWIPE: {
81 phantom_.Hide(); 81 phantom_.Hide();
82 pinch_factor_ = 1.0; 82 pinch_factor_ = 1.0;
83 phantom_state_ = PHANTOM_WINDOW_NORMAL; 83 phantom_state_ = PHANTOM_WINDOW_NORMAL;
84 84
85 if (event.details().swipe_left() || event.details().swipe_right()) { 85 if (event.details().swipe_left() || event.details().swipe_right()) {
86 // Snap for left/right swipes. In case the window is 86 // Snap for left/right swipes.
87 // maximized/fullscreen, then restore the window first so that tiling
88 // works correctly.
89 if (wm::IsWindowMaximized(target_) ||
90 wm::IsWindowFullscreen(target_))
91 wm::RestoreWindow(target_);
92
93 ui::ScopedLayerAnimationSettings settings( 87 ui::ScopedLayerAnimationSettings settings(
94 target_->layer()->GetAnimator()); 88 target_->layer()->GetAnimator());
95 SnapSizer sizer(target_, 89 wm::SnapWindow(target_,
96 gfx::Point(),
97 event.details().swipe_left() ? internal::SnapSizer::LEFT_EDGE : 90 event.details().swipe_left() ? internal::SnapSizer::LEFT_EDGE :
98 internal::SnapSizer::RIGHT_EDGE, 91 internal::SnapSizer::RIGHT_EDGE);
99 internal::SnapSizer::OTHER_INPUT);
100 target_->SetBounds(sizer.GetSnapBounds(target_->bounds()));
101 } else if (event.details().swipe_up()) { 92 } else if (event.details().swipe_up()) {
102 if (!wm::IsWindowMaximized(target_) && 93 if (!wm::IsWindowMaximized(target_) &&
103 !wm::IsWindowFullscreen(target_)) 94 !wm::IsWindowFullscreen(target_))
104 wm::MaximizeWindow(target_); 95 wm::MaximizeWindow(target_);
105 } else if (event.details().swipe_down()) { 96 } else if (event.details().swipe_down()) {
106 wm::MinimizeWindow(target_); 97 wm::MinimizeWindow(target_);
107 } else { 98 } else {
108 NOTREACHED() << "Swipe happened without a direction."; 99 NOTREACHED() << "Swipe happened without a direction.";
109 } 100 }
110 break; 101 break;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 phantom_state_ = PHANTOM_WINDOW_MINIMIZED; 137 phantom_state_ = PHANTOM_WINDOW_MINIMIZED;
147 return rect; 138 return rect;
148 } 139 }
149 140
150 phantom_state_ = PHANTOM_WINDOW_NORMAL; 141 phantom_state_ = PHANTOM_WINDOW_NORMAL;
151 return window->bounds(); 142 return window->bounds();
152 } 143 }
153 144
154 } // namespace internal 145 } // namespace internal
155 } // namespace ash 146 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698