Commit 9b81f34f authored by Ryan Daum's avatar Ryan Daum Committed by Commit Bot

Fix accidental reversion of configurable swipe gesture.

https://chromium-review.googlesource.com/976333 was accidentally
reverted by my other changes in
https://chromium-review.googlesource.com/978653

Bug: b/75978731
Test: manual test
Change-Id: I506c83d1d9f44434d41b70536e7d39ef1100eede
Reviewed-on: https://chromium-review.googlesource.com/1007097Reviewed-by: default avatarSergey Volk <servolk@chromium.org>
Commit-Queue: Ryan Daum <rdaum@chromium.org>
Cr-Commit-Position: refs/heads/master@{#549895}
parent 366e5a56
......@@ -4,6 +4,7 @@
#include "chromecast/graphics/cast_system_gesture_event_handler.h"
#include "chromecast/base/chromecast_switches.h"
#include "ui/aura/window.h"
#include "ui/display/display.h"
#include "ui/display/screen.h"
......@@ -18,17 +19,22 @@ namespace {
// The number of pixels from the very left or right of the screen to consider as
// a valid origin for the left or right swipe gesture.
constexpr int kSideGestureStartWidth = 35;
constexpr int kDefaultSideGestureStartWidth = 10;
// The number of pixels from the very top or bottom of the screen to consider as
// a valid origin for the top or bottom swipe gesture.
constexpr int kSideGestureStartHeight = 35;
constexpr int kDefaultSideGestureStartHeight = 10;
} // namespace
CastSystemGestureEventHandler::CastSystemGestureEventHandler(
aura::Window* root_window)
: EventHandler(),
gesture_start_width_(GetSwitchValueInt(switches::kSystemGestureStartWidth,
kDefaultSideGestureStartWidth)),
gesture_start_height_(
GetSwitchValueInt(switches::kSystemGestureStartHeight,
kDefaultSideGestureStartHeight)),
root_window_(root_window),
current_swipe_(CastSideSwipeOrigin::NONE) {
DCHECK(root_window);
......@@ -43,18 +49,18 @@ CastSystemGestureEventHandler::~CastSystemGestureEventHandler() {
CastSideSwipeOrigin CastSystemGestureEventHandler::GetDragPosition(
const gfx::Point& point,
const gfx::Rect& screen_bounds) const {
if (point.y() < (screen_bounds.y() + kSideGestureStartHeight)) {
if (point.y() < (screen_bounds.y() + gesture_start_height_)) {
return CastSideSwipeOrigin::TOP;
}
if (point.x() < (screen_bounds.x() + kSideGestureStartWidth)) {
if (point.x() < (screen_bounds.x() + gesture_start_width_)) {
return CastSideSwipeOrigin::LEFT;
}
if (point.x() >
(screen_bounds.x() + screen_bounds.width() - kSideGestureStartWidth)) {
(screen_bounds.x() + screen_bounds.width() - gesture_start_width_)) {
return CastSideSwipeOrigin::RIGHT;
}
if (point.y() >
(screen_bounds.y() + screen_bounds.height() - kSideGestureStartHeight)) {
(screen_bounds.y() + screen_bounds.height() - gesture_start_height_)) {
return CastSideSwipeOrigin::BOTTOM;
}
return CastSideSwipeOrigin::NONE;
......
......@@ -44,6 +44,9 @@ class CastSystemGestureEventHandler : public ui::EventHandler {
void OnEvent(ui::Event* event) override;
private:
const int gesture_start_width_;
const int gesture_start_height_;
aura::Window* root_window_;
CastSideSwipeOrigin current_swipe_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment