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

Unified Diff: ash/wm/gestures/border_gesture_handler.cc

Issue 14195016: Add in gesture for immersive mode (Closed) Base URL: https://codereview.chromium.org/13315002/
Patch Set: 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 side-by-side diff with in-line comments
Download patch
Index: ash/wm/gestures/border_gesture_handler.cc
diff --git a/ash/wm/gestures/border_gesture_handler.cc b/ash/wm/gestures/border_gesture_handler.cc
index 89c591660100748a3369263e21c598475dcfd87f..dc8dc85c26ad1d1c18e33d53a13774dada8f7120 100644
--- a/ash/wm/gestures/border_gesture_handler.cc
+++ b/ash/wm/gestures/border_gesture_handler.cc
@@ -9,9 +9,11 @@
#include "ash/shelf/shelf_types.h"
#include "ash/shelf/shelf_widget.h"
#include "ash/shell.h"
+#include "ash/wm/property_util.h"
#include "base/command_line.h"
#include "base/string_util.h"
#include "base/strings/string_number_conversions.h"
+#include "ui/aura/window.h"
#include "ui/base/events/event.h"
#include "ui/base/ui_base_switches.h"
#include "ui/gfx/screen.h"
@@ -63,6 +65,28 @@ bool BorderGestureHandler::ProcessGestureEvent(aura::Window* target,
return false;
}
+bool BorderGestureHandler::HandleImmersiveControl(
+ aura::Window* target,
+ const ui::GestureEvent& event) {
+ // If not in immersive mode let the gesture pass through
+ if (!GetRootWindowController(target->GetRootWindow())->IsImmersiveMode())
+ return false;
+
+ switch (event.type()) {
+ case ui::ET_GESTURE_SCROLL_BEGIN:
+ return true;
+ case ui::ET_GESTURE_SCROLL_UPDATE:
+ GetRootWindowController(
+ target->GetRootWindow())->SetPendingImmersiveGesture(true);
sadrul 2013/04/19 01:41:20 I think you should do this in SCROLL_BEGIN
rharrison 2013/04/22 18:36:52 I agree, I suspect this is a typo
+ return true;
+ case ui::ET_GESTURE_SCROLL_END:
+ case ui::ET_SCROLL_FLING_START:
+ return true;
+ default:
+ return false;
+ }
+}
+
bool BorderGestureHandler::HandleLauncherControl(
const ui::GestureEvent& event) {
ShelfLayoutManager* shelf =
@@ -77,8 +101,7 @@ bool BorderGestureHandler::HandleLauncherControl(
return shelf_handler_.ProcessGestureEvent(event);
break;
case SHELF_ALIGNMENT_TOP:
- if (start_location_.test(BORDER_LOCATION_TOP))
- return shelf_handler_.ProcessGestureEvent(event);
+ NOTREACHED();
break;
case SHELF_ALIGNMENT_RIGHT:
if (start_location_.test(BORDER_LOCATION_RIGHT))
@@ -98,7 +121,11 @@ bool BorderGestureHandler::HandleBorderGestureStart(
Shell::GetScreen()->GetDisplayNearestWindow(target).bounds();
GestureStartInTargetArea(screen, event);
- if (start_location_.any())
+ if (start_location_.test(BORDER_LOCATION_TOP))
+ return HandleImmersiveControl(target, event);
+ if (start_location_.test(BORDER_LOCATION_BOTTOM) ||
+ start_location_.test(BORDER_LOCATION_LEFT) ||
+ start_location_.test(BORDER_LOCATION_RIGHT))
return HandleLauncherControl(event);
return false;
}
@@ -106,6 +133,8 @@ bool BorderGestureHandler::HandleBorderGestureStart(
bool BorderGestureHandler::HandleBorderGestureUpdate(
aura::Window* target,
const ui::GestureEvent& event) {
+ if (IsGestureInImmersiveOrientation(event))
+ return HandleImmersiveControl(target, event);
if (IsGestureInLauncherOrientation(event))
return HandleLauncherControl(event);
return false;
@@ -114,7 +143,11 @@ bool BorderGestureHandler::HandleBorderGestureUpdate(
bool BorderGestureHandler::HandleBorderGestureEnd(
aura::Window* target,
const ui::GestureEvent& event) {
- bool ret_val = HandleLauncherControl(event);
+ bool ret_val = false;
+ if (IsGestureInImmersiveOrientation(event))
+ ret_val = HandleImmersiveControl(target, event);
+ if (IsGestureInLauncherOrientation(event))
+ ret_val = HandleLauncherControl(event);
start_location_.reset();
return ret_val;
}
@@ -145,13 +178,33 @@ bool BorderGestureHandler::DetermineGestureOrientation(
return true;
}
+bool BorderGestureHandler::IsGestureInImmersiveOrientation(
+ const ui::GestureEvent& event) {
+ if (ui::ET_GESTURE_SCROLL_UPDATE == event.type()) {
+ BorderScrollOrientation new_orientation = abs(event.details().scroll_y()) >
+ abs(event.details().scroll_x()) ?
+ BORDER_SCROLL_ORIENTATION_VERTICAL :
+ BORDER_SCROLL_ORIENTATION_HORIZONTAL;
+ if (new_orientation != orientation_)
+ return false;
+ }
+
+ if (start_location_.test(BORDER_LOCATION_TOP) &&
+ orientation_ == BORDER_SCROLL_ORIENTATION_VERTICAL)
+ return true;
+ return false;
+}
+
bool BorderGestureHandler::IsGestureInLauncherOrientation(
const ui::GestureEvent& event) {
- BorderScrollOrientation new_orientation = abs(event.details().scroll_y()) >
- abs(event.details().scroll_x()) ?
- BORDER_SCROLL_ORIENTATION_VERTICAL : BORDER_SCROLL_ORIENTATION_HORIZONTAL;
- if (new_orientation != orientation_)
- return false;
+ if (ui::ET_GESTURE_SCROLL_UPDATE == event.type()) {
+ BorderScrollOrientation new_orientation = abs(event.details().scroll_y()) >
+ abs(event.details().scroll_x()) ?
+ BORDER_SCROLL_ORIENTATION_VERTICAL :
+ BORDER_SCROLL_ORIENTATION_HORIZONTAL;
+ if (new_orientation != orientation_)
+ return false;
+ }
ShelfLayoutManager* shelf =
Shell::GetPrimaryRootWindowController()->GetShelfLayoutManager();
@@ -165,8 +218,7 @@ bool BorderGestureHandler::IsGestureInLauncherOrientation(
return true;
break;
case SHELF_ALIGNMENT_TOP:
- if (orientation_ == BORDER_SCROLL_ORIENTATION_VERTICAL)
- return true;
+ NOTREACHED();
break;
case SHELF_ALIGNMENT_RIGHT:
if (orientation_ == BORDER_SCROLL_ORIENTATION_HORIZONTAL)

Powered by Google App Engine
This is Rietveld 408576698