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

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

Issue 2775973002: Promotes more accessors from WmShell to Shell (Closed)
Patch Set: feedback Created 3 years, 9 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/overview_gesture_handler.h" 5 #include "ash/wm/gestures/overview_gesture_handler.h"
6 6
7 #include "ash/common/wm/overview/window_selector_controller.h" 7 #include "ash/common/wm/overview/window_selector_controller.h"
8 #include "ash/common/wm_shell.h" 8 #include "ash/common/wm_shell.h"
9 #include "ash/shell.h"
9 #include "ui/events/event.h" 10 #include "ui/events/event.h"
10 #include "ui/events/event_constants.h" 11 #include "ui/events/event_constants.h"
11 12
12 namespace ash { 13 namespace ash {
13 14
14 // The threshold before engaging overview with a touchpad three-finger scroll. 15 // The threshold before engaging overview with a touchpad three-finger scroll.
15 const float OverviewGestureHandler::vertical_threshold_pixels_ = 300; 16 const float OverviewGestureHandler::vertical_threshold_pixels_ = 300;
16 17
17 // The threshold before moving selector horizontally when using a touchpad 18 // The threshold before moving selector horizontally when using a touchpad
18 // three-finger scroll. 19 // three-finger scroll.
19 const float OverviewGestureHandler::horizontal_threshold_pixels_ = 330; 20 const float OverviewGestureHandler::horizontal_threshold_pixels_ = 330;
20 21
21 OverviewGestureHandler::OverviewGestureHandler() : scroll_x_(0), scroll_y_(0) {} 22 OverviewGestureHandler::OverviewGestureHandler() : scroll_x_(0), scroll_y_(0) {}
22 23
23 OverviewGestureHandler::~OverviewGestureHandler() {} 24 OverviewGestureHandler::~OverviewGestureHandler() {}
24 25
25 bool OverviewGestureHandler::ProcessScrollEvent(const ui::ScrollEvent& event) { 26 bool OverviewGestureHandler::ProcessScrollEvent(const ui::ScrollEvent& event) {
26 if (event.type() == ui::ET_SCROLL_FLING_START || 27 if (event.type() == ui::ET_SCROLL_FLING_START ||
27 event.type() == ui::ET_SCROLL_FLING_CANCEL || event.finger_count() != 3) { 28 event.type() == ui::ET_SCROLL_FLING_CANCEL || event.finger_count() != 3) {
28 scroll_x_ = scroll_y_ = 0; 29 scroll_x_ = scroll_y_ = 0;
29 return false; 30 return false;
30 } 31 }
31 32
32 scroll_x_ += event.x_offset(); 33 scroll_x_ += event.x_offset();
33 scroll_y_ += event.y_offset(); 34 scroll_y_ += event.y_offset();
34 35
35 WindowSelectorController* window_selector_controller = 36 WindowSelectorController* window_selector_controller =
36 WmShell::Get()->window_selector_controller(); 37 Shell::Get()->window_selector_controller();
37 38
38 // Horizontal 3-finger scroll moves selection when already in overview mode. 39 // Horizontal 3-finger scroll moves selection when already in overview mode.
39 if (std::fabs(scroll_x_) >= std::fabs(scroll_y_)) { 40 if (std::fabs(scroll_x_) >= std::fabs(scroll_y_)) {
40 if (!window_selector_controller->IsSelecting()) { 41 if (!window_selector_controller->IsSelecting()) {
41 scroll_x_ = scroll_y_ = 0; 42 scroll_x_ = scroll_y_ = 0;
42 return false; 43 return false;
43 } 44 }
44 if (std::fabs(scroll_x_) < horizontal_threshold_pixels_) 45 if (std::fabs(scroll_x_) < horizontal_threshold_pixels_)
45 return false; 46 return false;
46 47
(...skipping 21 matching lines...) Expand all
68 WmShell::Get()->RecordUserMetricsAction(UMA_TOUCHPAD_GESTURE_OVERVIEW); 69 WmShell::Get()->RecordUserMetricsAction(UMA_TOUCHPAD_GESTURE_OVERVIEW);
69 if (window_selector_controller->IsSelecting() && 70 if (window_selector_controller->IsSelecting() &&
70 window_selector_controller->AcceptSelection()) { 71 window_selector_controller->AcceptSelection()) {
71 return true; 72 return true;
72 } 73 }
73 window_selector_controller->ToggleOverview(); 74 window_selector_controller->ToggleOverview();
74 return true; 75 return true;
75 } 76 }
76 77
77 } // namespace ash 78 } // namespace ash
OLDNEW
« no previous file with comments | « ash/virtual_keyboard_controller_unittest.cc ('k') | ash/wm/gestures/overview_gesture_handler_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698