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

Side by Side Diff: ash/wm/toplevel_window_event_handler.cc

Issue 11280290: events: Change gesture-event handler in EventHandler to not return any values. (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
« no previous file with comments | « ash/wm/toplevel_window_event_handler.h ('k') | ash/wm/user_activity_detector.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/toplevel_window_event_handler.h" 5 #include "ash/wm/toplevel_window_event_handler.h"
6 6
7 #include "ash/shell.h" 7 #include "ash/shell.h"
8 #include "ash/wm/property_util.h" 8 #include "ash/wm/property_util.h"
9 #include "ash/wm/resize_shadow_controller.h" 9 #include "ash/wm/resize_shadow_controller.h"
10 #include "ash/wm/window_resizer.h" 10 #include "ash/wm/window_resizer.h"
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 case ui::ET_MOUSE_MOVED: 149 case ui::ET_MOUSE_MOVED:
150 return HandleMouseMoved(target, event); 150 return HandleMouseMoved(target, event);
151 case ui::ET_MOUSE_EXITED: 151 case ui::ET_MOUSE_EXITED:
152 return HandleMouseExited(target, event); 152 return HandleMouseExited(target, event);
153 default: 153 default:
154 break; 154 break;
155 } 155 }
156 return ui::ER_UNHANDLED; 156 return ui::ER_UNHANDLED;
157 } 157 }
158 158
159 ui::EventResult ToplevelWindowEventHandler::OnGestureEvent( 159 void ToplevelWindowEventHandler::OnGestureEvent(ui::GestureEvent* event) {
160 ui::GestureEvent* event) {
161 aura::Window* target = static_cast<aura::Window*>(event->target()); 160 aura::Window* target = static_cast<aura::Window*>(event->target());
162 if (!target->delegate()) 161 if (!target->delegate())
163 return ui::ER_UNHANDLED; 162 return;
164 163
165 switch (event->type()) { 164 switch (event->type()) {
166 case ui::ET_GESTURE_SCROLL_BEGIN: { 165 case ui::ET_GESTURE_SCROLL_BEGIN: {
167 int component = 166 int component =
168 target->delegate()->GetNonClientComponent(event->location()); 167 target->delegate()->GetNonClientComponent(event->location());
169 if (WindowResizer::GetBoundsChangeForWindowComponent(component) == 0) { 168 if (WindowResizer::GetBoundsChangeForWindowComponent(component) == 0) {
170 window_resizer_.reset(); 169 window_resizer_.reset();
171 return ui::ER_UNHANDLED; 170 return;
172 } 171 }
173 in_gesture_drag_ = true; 172 in_gesture_drag_ = true;
174 gfx::Point location_in_parent( 173 gfx::Point location_in_parent(
175 ConvertPointToParent(target, event->location())); 174 ConvertPointToParent(target, event->location()));
176 CreateScopedWindowResizer(target, location_in_parent, component); 175 CreateScopedWindowResizer(target, location_in_parent, component);
177 break; 176 break;
178 } 177 }
179 case ui::ET_GESTURE_SCROLL_UPDATE: { 178 case ui::ET_GESTURE_SCROLL_UPDATE: {
180 if (!in_gesture_drag_) 179 if (!in_gesture_drag_)
181 return ui::ER_UNHANDLED; 180 return;
182 HandleDrag(target, event); 181 HandleDrag(target, event);
183 break; 182 break;
184 } 183 }
185 case ui::ET_GESTURE_SCROLL_END: 184 case ui::ET_GESTURE_SCROLL_END:
186 case ui::ET_SCROLL_FLING_START: { 185 case ui::ET_SCROLL_FLING_START: {
187 if (!in_gesture_drag_) 186 if (!in_gesture_drag_)
188 return ui::ER_UNHANDLED; 187 return;
189 188
190 CompleteDrag(DRAG_COMPLETE, event->flags()); 189 CompleteDrag(DRAG_COMPLETE, event->flags());
191 if (in_move_loop_) { 190 if (in_move_loop_) {
192 quit_closure_.Run(); 191 quit_closure_.Run();
193 in_move_loop_ = false; 192 in_move_loop_ = false;
194 } 193 }
195 in_gesture_drag_ = false; 194 in_gesture_drag_ = false;
196 195
197 if (event->type() == ui::ET_GESTURE_SCROLL_END) 196 if (event->type() == ui::ET_GESTURE_SCROLL_END) {
198 return ui::ER_CONSUMED; 197 event->StopPropagation();
198 return;
199 }
199 200
200 int component = 201 int component =
201 target->delegate()->GetNonClientComponent(event->location()); 202 target->delegate()->GetNonClientComponent(event->location());
202 if (WindowResizer::GetBoundsChangeForWindowComponent(component) == 0) 203 if (WindowResizer::GetBoundsChangeForWindowComponent(component) == 0)
203 return ui::ER_UNHANDLED; 204 return;
204 if (!wm::IsWindowNormal(target)) 205 if (!wm::IsWindowNormal(target))
205 return ui::ER_UNHANDLED; 206 return;
206 207
207 if (fabs(event->details().velocity_y()) > 208 if (fabs(event->details().velocity_y()) >
208 kMinVertVelocityForWindowMinimize) { 209 kMinVertVelocityForWindowMinimize) {
209 // Minimize/maximize. 210 // Minimize/maximize.
210 if (event->details().velocity_y() > 0) 211 if (event->details().velocity_y() > 0)
211 wm::MinimizeWindow(target); 212 wm::MinimizeWindow(target);
212 else if (wm::CanMaximizeWindow(target)) 213 else if (wm::CanMaximizeWindow(target))
213 wm::MaximizeWindow(target); 214 wm::MaximizeWindow(target);
214 } else if (fabs(event->details().velocity_x()) > 215 } else if (fabs(event->details().velocity_x()) >
215 kMinHorizVelocityForWindowSwipe) { 216 kMinHorizVelocityForWindowSwipe) {
216 // Snap left/right. 217 // Snap left/right.
217 ui::ScopedLayerAnimationSettings scoped_setter( 218 ui::ScopedLayerAnimationSettings scoped_setter(
218 target->layer()->GetAnimator()); 219 target->layer()->GetAnimator());
219 scoped_setter.SetPreemptionStrategy( 220 scoped_setter.SetPreemptionStrategy(
220 ui::LayerAnimator::REPLACE_QUEUED_ANIMATIONS); 221 ui::LayerAnimator::REPLACE_QUEUED_ANIMATIONS);
221 internal::SnapSizer::SnapWindow(target, 222 internal::SnapSizer::SnapWindow(target,
222 event->details().velocity_x() < 0 ? 223 event->details().velocity_x() < 0 ?
223 internal::SnapSizer::LEFT_EDGE : internal::SnapSizer::RIGHT_EDGE); 224 internal::SnapSizer::LEFT_EDGE : internal::SnapSizer::RIGHT_EDGE);
224 } 225 }
225 break; 226 break;
226 } 227 }
227 default: 228 default:
228 return ui::ER_UNHANDLED; 229 return;
229 } 230 }
230 231
231 return ui::ER_CONSUMED; 232 event->StopPropagation();
232 } 233 }
233 234
234 aura::client::WindowMoveResult ToplevelWindowEventHandler::RunMoveLoop( 235 aura::client::WindowMoveResult ToplevelWindowEventHandler::RunMoveLoop(
235 aura::Window* source, 236 aura::Window* source,
236 const gfx::Vector2d& drag_offset) { 237 const gfx::Vector2d& drag_offset) {
237 DCHECK(!in_move_loop_); // Can only handle one nested loop at a time. 238 DCHECK(!in_move_loop_); // Can only handle one nested loop at a time.
238 in_move_loop_ = true; 239 in_move_loop_ = true;
239 move_cancelled_ = false; 240 move_cancelled_ = false;
240 aura::RootWindow* root_window = source->GetRootWindow(); 241 aura::RootWindow* root_window = source->GetRootWindow();
241 DCHECK(root_window); 242 DCHECK(root_window);
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
430 void ToplevelWindowEventHandler::ResizerWindowDestroyed() { 431 void ToplevelWindowEventHandler::ResizerWindowDestroyed() {
431 // We explicitly don't invoke RevertDrag() since that may do things to window. 432 // We explicitly don't invoke RevertDrag() since that may do things to window.
432 // Instead we destroy the resizer. 433 // Instead we destroy the resizer.
433 window_resizer_.reset(); 434 window_resizer_.reset();
434 435
435 // End the move loop. This does nothing if we're not in a move loop. 436 // End the move loop. This does nothing if we're not in a move loop.
436 EndMoveLoop(); 437 EndMoveLoop();
437 } 438 }
438 439
439 } // namespace ash 440 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/toplevel_window_event_handler.h ('k') | ash/wm/user_activity_detector.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698