Commit eff124f7 authored by Ryan Daum's avatar Ryan Daum Committed by Commit Bot

Change interface for cast system gesture handling.

New interface (with default stub implementations) with the following:

  * Pass the event location rather than the underlying event (so that
    touch events or other data sources can be used instead of gesture events)
  * Method to query the handler whether it can handle a given event origin
    so we can avoid detecting (or blocking) margin events unnecessarily.
  * Adds a method for continuation/drag events.

Bug: internal b/78462154
Bug: internal b/78461207
Change-Id: I1bba715e98b6458bf079cacd71b4ef3403ae7260
Tested: manual test
Reviewed-on: https://chromium-review.googlesource.com/1028656
Commit-Queue: Ryan Daum <rdaum@chromium.org>
Reviewed-by: default avatarSadrul Chowdhury <sadrul@chromium.org>
Reviewed-by: default avatarAlex Sakhartchouk <alexst@chromium.org>
Cr-Commit-Position: refs/heads/master@{#553767}
parent 722b9687
......@@ -138,5 +138,18 @@ void CastContentWindowAura::OnSideSwipeEnd(CastSideSwipeOrigin swipe_origin,
}
}
bool CastContentWindowAura::CanHandleSwipe(CastSideSwipeOrigin swipe_origin) {
return swipe_origin == CastSideSwipeOrigin::LEFT &&
delegate_->CanHandleGesture(GestureType::GO_BACK);
}
void CastContentWindowAura::HandleSideSwipeBegin(
CastSideSwipeOrigin swipe_origin,
const gfx::Point& touch_location) {
if (swipe_origin == CastSideSwipeOrigin::LEFT) {
delegate_->ConsumeGesture(GestureType::GO_BACK);
}
}
} // namespace shell
} // namespace chromecast
......@@ -40,6 +40,10 @@ class CastContentWindowAura : public CastContentWindow,
void OnSideSwipeEnd(CastSideSwipeOrigin swipe_origin,
ui::GestureEvent* gesture_event) override;
bool CanHandleSwipe(CastSideSwipeOrigin swipe_origin) override;
void HandleSideSwipeBegin(CastSideSwipeOrigin swipe_origin,
const gfx::Point& touch_location) override;
private:
friend class CastContentWindow;
......
......@@ -20,6 +20,7 @@ cast_source_set("graphics") {
sources += [
"cast_focus_client_aura.cc",
"cast_focus_client_aura.h",
"cast_side_swipe_gesture_handler.cc",
"cast_side_swipe_gesture_handler.h",
"cast_system_gesture_event_handler.cc",
"cast_system_gesture_event_handler.h",
......
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chromecast/graphics/cast_side_swipe_gesture_handler.h"
namespace chromecast {
bool CastSideSwipeGestureHandlerInterface::CanHandleSwipe(
CastSideSwipeOrigin swipe_origin) {
return false;
}
} // namespace chromecast
......@@ -11,6 +11,10 @@ namespace ui {
class GestureEvent;
} // namespace ui
namespace gfx {
class Point;
} // namespace gfx
namespace chromecast {
enum class CastSideSwipeOrigin { TOP, BOTTOM, LEFT, RIGHT, NONE };
......@@ -22,15 +26,33 @@ class CastSideSwipeGestureHandlerInterface {
CastSideSwipeGestureHandlerInterface() = default;
virtual ~CastSideSwipeGestureHandlerInterface() = default;
// Return true if this handler can handle swipes from the given origin.
virtual bool CanHandleSwipe(CastSideSwipeOrigin swipe_origin);
// Triggered on the beginning of a swipe from edge.
virtual void HandleSideSwipeBegin(CastSideSwipeOrigin swipe_origin,
const gfx::Point& touch_location) {}
// Triggered on the continuance (finger drag) of a swipe from edge.
virtual void HandleSideSwipeContinue(CastSideSwipeOrigin swipe_origin,
const gfx::Point& touch_location) {}
// Triggered on the completion (finger up) of a swipe from edge.
virtual void HandleSideSwipeEnd(CastSideSwipeOrigin swipe_origin,
const gfx::Point& touch_location) {}
// TODO(rdaum): DEPRECATED below, delete after all downstream users are
// migrated to the new implementations above.
// Triggered on the beginning of a swipe.
// Note: Consumers of the event should call SetHandled on it to prevent its
// further propagation.
virtual void OnSideSwipeBegin(CastSideSwipeOrigin swipe_origin,
ui::GestureEvent* gesture_event) = 0;
ui::GestureEvent* gesture_event) {}
// Triggered on the completion (finger up) of a swipe.
virtual void OnSideSwipeEnd(CastSideSwipeOrigin swipe_origin,
ui::GestureEvent* gesture_event) = 0;
ui::GestureEvent* gesture_event) {}
private:
DISALLOW_COPY_AND_ASSIGN(CastSideSwipeGestureHandlerInterface);
......
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