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

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

Issue 13315002: Add in gesture for immersive mode (Closed) Base URL: https://codereview.chromium.org/12529026/
Patch Set: Rebasing Created 7 years, 8 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
« no previous file with comments | « ash/wm/gestures/edge_gesture_handler.h ('k') | ash/wm/window_properties.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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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/edge_gesture_handler.h" 5 #include "ash/wm/gestures/edge_gesture_handler.h"
6 6
7 #include "ash/root_window_controller.h" 7 #include "ash/root_window_controller.h"
8 #include "ash/shelf/shelf_layout_manager.h" 8 #include "ash/shelf/shelf_layout_manager.h"
9 #include "ash/shelf/shelf_types.h" 9 #include "ash/shelf/shelf_types.h"
10 #include "ash/shelf/shelf_widget.h" 10 #include "ash/shelf/shelf_widget.h"
11 #include "ash/shell.h" 11 #include "ash/shell.h"
12 #include "ash/wm/property_util.h"
13 #include "ui/aura/window.h"
12 #include "ui/base/events/event.h" 14 #include "ui/base/events/event.h"
13 #include "ui/gfx/screen.h" 15 #include "ui/gfx/screen.h"
14 16
15 namespace { 17 namespace {
16 const int kBottomEdgeGestureThreshold = 10; 18 const int kBottomEdgeGestureThreshold = 10;
17 const int kLeftEdgeGestureThreshold = 10; 19 const int kLeftEdgeGestureThreshold = 10;
18 const int kRightEdgeGestureThreshold = 10; 20 const int kRightEdgeGestureThreshold = 10;
19 const int kTopEdgeGestureThreshold = 10; 21 const int kTopEdgeGestureThreshold = 10;
20 22
21 // Bit positions of edge start flags 23 // Bit positions of edge start flags
(...skipping 24 matching lines...) Expand all
46 48
47 bool EdgeGestureHandler::ProcessGestureEvent(aura::Window* target, 49 bool EdgeGestureHandler::ProcessGestureEvent(aura::Window* target,
48 const ui::GestureEvent& event) { 50 const ui::GestureEvent& event) {
49 // TODO(crbug.com/222746): Rewrite this code to ignore events that are for 51 // TODO(crbug.com/222746): Rewrite this code to ignore events that are for
50 // edges that a bezel is present for instead of hardcoding the layout of edge 52 // edges that a bezel is present for instead of hardcoding the layout of edge
51 // v bezel. 53 // v bezel.
52 switch (event.type()) { 54 switch (event.type()) {
53 case ui::ET_GESTURE_SCROLL_BEGIN: 55 case ui::ET_GESTURE_SCROLL_BEGIN:
54 return HandleEdgeGestureStart(target, event); 56 return HandleEdgeGestureStart(target, event);
55 case ui::ET_GESTURE_SCROLL_UPDATE: 57 case ui::ET_GESTURE_SCROLL_UPDATE:
56 if (ANY_FLAGS_SET(start_location_)) { 58 if (ANY_FLAGS_SET(start_location_))
57 if (DetermineGestureOrientation(event)) { 59 if (DetermineGestureOrientation(event))
58 return HandleEdgeGestureUpdate(target, event); 60 return HandleEdgeGestureUpdate(target, event);
59 }
60 }
61 break; 61 break;
62 case ui::ET_GESTURE_SCROLL_END: 62 case ui::ET_GESTURE_SCROLL_END:
63 case ui::ET_SCROLL_FLING_START: 63 case ui::ET_SCROLL_FLING_START:
64 return HandleEdgeGestureEnd(target, event); 64 return HandleEdgeGestureEnd(target, event);
65 default: 65 default:
66 break; 66 break;
67 } 67 }
68 return false; 68 return false;
69 } 69 }
70 70
(...skipping 17 matching lines...) Expand all
88 // screen and there are no implemented gestures for the top edge at the 88 // screen and there are no implemented gestures for the top edge at the
89 // moment. 89 // moment.
90 case SHELF_ALIGNMENT_BOTTOM: 90 case SHELF_ALIGNMENT_BOTTOM:
91 case SHELF_ALIGNMENT_TOP: 91 case SHELF_ALIGNMENT_TOP:
92 default: 92 default:
93 break; 93 break;
94 } 94 }
95 return false; 95 return false;
96 } 96 }
97 97
98 bool EdgeGestureHandler::HandleImmersiveControl(aura::Window* target,
99 const ui::GestureEvent& event) {
100 // If not in immersive mode let the gesture pass through
101 if (!GetRootWindowController(target->GetRootWindow())->IsImmersiveMode())
102 return false;
103
104 switch (event.type()) {
105 case ui::ET_GESTURE_SCROLL_BEGIN:
106 return true;
107 case ui::ET_GESTURE_SCROLL_UPDATE:
108 GetRootWindowController(
109 target->GetRootWindow())->SetPendingImmersiveGesture(true);
110 break;
111 case ui::ET_GESTURE_SCROLL_END:
112 case ui::ET_SCROLL_FLING_START:
113 return true;
114 break;
115 default:
116 break;
117 }
118 return false;
119 }
120
98 bool EdgeGestureHandler::HandleEdgeGestureStart( 121 bool EdgeGestureHandler::HandleEdgeGestureStart(
99 aura::Window* target, 122 aura::Window* target,
100 const ui::GestureEvent& event) { 123 const ui::GestureEvent& event) {
101 gfx::Rect screen = 124 gfx::Rect screen =
102 Shell::GetScreen()->GetDisplayNearestWindow(target).bounds(); 125 Shell::GetScreen()->GetDisplayNearestWindow(target).bounds();
103 126
104 orientation_ = EDGE_SCROLL_ORIENTATION_UNSET; 127 orientation_ = EDGE_SCROLL_ORIENTATION_UNSET;
105 if (GestureStartInEdgeArea(screen, event)) 128 if (GestureStartInEdgeArea(screen, event)) {
106 return HandleLauncherControl(event); 129 if (IS_FLAG_SET(start_location_, EDGE_START_TOP))
130 return HandleImmersiveControl(target, event);
131 else
132 return HandleLauncherControl(event);
133 }
107 return false; 134 return false;
108 } 135 }
109 136
110 bool EdgeGestureHandler::DetermineGestureOrientation( 137 bool EdgeGestureHandler::DetermineGestureOrientation(
111 const ui::GestureEvent& event) { 138 const ui::GestureEvent& event) {
112 if (orientation_ == EDGE_SCROLL_ORIENTATION_UNSET) { 139 if (orientation_ == EDGE_SCROLL_ORIENTATION_UNSET) {
113 if (!event.details().scroll_x() && !event.details().scroll_y()) 140 if (!event.details().scroll_x() && !event.details().scroll_y())
114 return false; 141 return false;
115 orientation_ = abs(event.details().scroll_y()) > 142 orientation_ = abs(event.details().scroll_y()) >
116 abs(event.details().scroll_x()) ? 143 abs(event.details().scroll_x()) ?
117 EDGE_SCROLL_ORIENTATION_VERTICAL : EDGE_SCROLL_ORIENTATION_HORIZONTAL; 144 EDGE_SCROLL_ORIENTATION_VERTICAL : EDGE_SCROLL_ORIENTATION_HORIZONTAL;
118 } 145 }
119 return true; 146 return true;
120 } 147 }
121 148
122 bool EdgeGestureHandler::HandleEdgeGestureUpdate( 149 bool EdgeGestureHandler::HandleEdgeGestureUpdate(
123 aura::Window* target, 150 aura::Window* target,
124 const ui::GestureEvent& event) { 151 const ui::GestureEvent& event) {
152 if (IsGestureInImmersiveOrientation(event))
153 return HandleImmersiveControl(target, event);
154
125 if (IsGestureInLauncherOrientation(event)) 155 if (IsGestureInLauncherOrientation(event))
126 return HandleLauncherControl(event); 156 return HandleLauncherControl(event);
127 return false; 157 return false;
128 } 158 }
129 159
130 bool EdgeGestureHandler::HandleEdgeGestureEnd(aura::Window* target, 160 bool EdgeGestureHandler::HandleEdgeGestureEnd(aura::Window* target,
131 const ui::GestureEvent& event) { 161 const ui::GestureEvent& event) {
132 bool ret_val = HandleLauncherControl(event); 162 bool ret_val = HandleLauncherControl(event);
133 CLEAR_FLAGS(start_location_); 163 CLEAR_FLAGS(start_location_);
134 return ret_val; 164 return ret_val;
(...skipping 24 matching lines...) Expand all
159 EdgeScrollOrientation new_orientation = abs(event.details().scroll_y()) > 189 EdgeScrollOrientation new_orientation = abs(event.details().scroll_y()) >
160 abs(event.details().scroll_x()) ? 190 abs(event.details().scroll_x()) ?
161 EDGE_SCROLL_ORIENTATION_VERTICAL : EDGE_SCROLL_ORIENTATION_HORIZONTAL; 191 EDGE_SCROLL_ORIENTATION_VERTICAL : EDGE_SCROLL_ORIENTATION_HORIZONTAL;
162 192
163 if (new_orientation != orientation_) 193 if (new_orientation != orientation_)
164 return false; 194 return false;
165 195
166 ShelfLayoutManager* shelf = 196 ShelfLayoutManager* shelf =
167 Shell::GetPrimaryRootWindowController()->GetShelfLayoutManager(); 197 Shell::GetPrimaryRootWindowController()->GetShelfLayoutManager();
168 switch (shelf->GetAlignment()) { 198 switch (shelf->GetAlignment()) {
169 case SHELF_ALIGNMENT_BOTTOM:
170 if (orientation_ == EDGE_SCROLL_ORIENTATION_VERTICAL)
171 return true;
172 break;
173 case SHELF_ALIGNMENT_LEFT: 199 case SHELF_ALIGNMENT_LEFT:
174 if (orientation_ == EDGE_SCROLL_ORIENTATION_HORIZONTAL) 200 if (orientation_ == EDGE_SCROLL_ORIENTATION_HORIZONTAL)
175 return true; 201 return true;
176 break; 202 break;
177 case SHELF_ALIGNMENT_RIGHT: 203 case SHELF_ALIGNMENT_RIGHT:
178 if (orientation_ == EDGE_SCROLL_ORIENTATION_HORIZONTAL) 204 if (orientation_ == EDGE_SCROLL_ORIENTATION_HORIZONTAL)
179 return true; 205 return true;
180 break; 206 break;
181 case SHELF_ALIGNMENT_TOP:
182 if (orientation_ == EDGE_SCROLL_ORIENTATION_VERTICAL)
183 return true;
184 break;
185 default: 207 default:
186 break; 208 break;
187 } 209 }
188 return false; 210 return false;
189 } 211 }
190 212
213 bool EdgeGestureHandler::IsGestureInImmersiveOrientation(
214 const ui::GestureEvent& event) {
215 if (IS_FLAG_SET(start_location_, EDGE_START_TOP) &&
216 (orientation_ == EDGE_SCROLL_ORIENTATION_VERTICAL))
217 return true;
218 return false;
219 }
220
191 } // namespace internal 221 } // namespace internal
192 } // namespace ash 222 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/gestures/edge_gesture_handler.h ('k') | ash/wm/window_properties.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698