Commit 00f3cdd8 authored by Ryan Daum's avatar Ryan Daum Committed by Commit Bot

[chromecast] Allow touch action in side swipe margins.

Changes cast system gesture handling so that events which happen on
the side swipe margin are replayed when the finger is lifted before
leaving the margin area, allowing UI elements to be accessed in the
margin.

Note: A refactoring of the side swipe detection into an EventRewriter
was necessary to allow for the redispatching of the stashed
events. The side swipe detection was factored out into a separate
class, leaving the tap/press handling in the EventHandler.

Bug: internal b/111304882
Test: manual and unit tests
Change-Id: If446ed0d97bc9e5f127c311e98f0ed8289071dd3
Reviewed-on: https://chromium-review.googlesource.com/1141060Reviewed-by: default avatarKevin Schoedel <kpschoedel@chromium.org>
Reviewed-by: default avatarAlex Sakhartchouk <alexst@chromium.org>
Commit-Queue: Ryan Daum <rdaum@chromium.org>
Cr-Commit-Position: refs/heads/master@{#576150}
parent 26723c8e
......@@ -17,15 +17,18 @@ class Window;
namespace gfx {
class Point;
class Rect;
} // namespace gfx
namespace chromecast {
// An event handler for detecting system-wide gestures performed on the screen.
// Recognizes swipe gestures that originate from the top, left, bottom, and
// right of the root window.
class CastSystemGestureEventHandler : public ui::EventHandler {
class SideSwipeDetector;
// Looks for root window cast system gestures, such as tap events and edge
// swipes, and dispatches them to interested observers. Installs an event
// rewriter to examine touch events for side swipe gestures. Also installs
// itself as an event handler for observing gesture tap/press events.
class CastSystemGestureEventHandler : public ui::EventHandler,
public CastGestureHandler {
public:
explicit CastSystemGestureEventHandler(aura::Window* root_window);
......@@ -37,23 +40,24 @@ class CastSystemGestureEventHandler : public ui::EventHandler {
// Remove the registration of a gesture handler.
void RemoveGestureHandler(CastGestureHandler* handler);
CastSideSwipeOrigin GetDragPosition(const gfx::Point& point,
const gfx::Rect& screen_bounds) const;
void ProcessPressedEvent(ui::GestureEvent* event);
void OnTouchEvent(ui::TouchEvent* event) override;
// ui::EventHandler implementation.
void OnGestureEvent(ui::GestureEvent* event) override;
// Implementation of CastGestureHandler methods which fan out to our gesture
// handlers.
bool CanHandleSwipe(CastSideSwipeOrigin swipe_origin) override;
void HandleSideSwipeBegin(CastSideSwipeOrigin swipe_origin,
const gfx::Point& touch_location) override;
void HandleSideSwipeContinue(CastSideSwipeOrigin swipe_origin,
const gfx::Point& touch_location) override;
void HandleSideSwipeEnd(CastSideSwipeOrigin swipe_origin,
const gfx::Point& touch_location) override;
private:
const int gesture_start_width_;
const int gesture_start_height_;
const int bottom_gesture_start_height_;
void ProcessPressedEvent(ui::GestureEvent* event);
aura::Window* root_window_;
CastSideSwipeOrigin current_swipe_;
base::ElapsedTimer current_swipe_time_;
std::unique_ptr<SideSwipeDetector> side_swipe_detector_;
base::flat_set<CastGestureHandler*> gesture_handlers_;
DISALLOW_COPY_AND_ASSIGN(CastSystemGestureEventHandler);
......
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