summaryrefslogtreecommitdiff
path: root/chromium/ui/events/gesture_detection
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2020-07-16 11:45:35 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2020-07-17 08:59:23 +0000
commit552906b0f222c5d5dd11b9fd73829d510980461a (patch)
tree3a11e6ed0538a81dd83b20cf3a4783e297f26d91 /chromium/ui/events/gesture_detection
parent1b05827804eaf047779b597718c03e7d38344261 (diff)
downloadqtwebengine-chromium-552906b0f222c5d5dd11b9fd73829d510980461a.tar.gz
BASELINE: Update Chromium to 83.0.4103.122
Change-Id: Ie3a82f5bb0076eec2a7c6a6162326b4301ee291e Reviewed-by: Michael BrĂ¼ning <michael.bruning@qt.io>
Diffstat (limited to 'chromium/ui/events/gesture_detection')
-rw-r--r--chromium/ui/events/gesture_detection/gesture_detector.cc28
-rw-r--r--chromium/ui/events/gesture_detection/gesture_detector.h6
-rw-r--r--chromium/ui/events/gesture_detection/gesture_event_data.h2
-rw-r--r--chromium/ui/events/gesture_detection/gesture_provider.cc1
-rw-r--r--chromium/ui/events/gesture_detection/gesture_provider_unittest.cc38
-rw-r--r--chromium/ui/events/gesture_detection/touch_disposition_gesture_filter.h2
6 files changed, 75 insertions, 2 deletions
diff --git a/chromium/ui/events/gesture_detection/gesture_detector.cc b/chromium/ui/events/gesture_detection/gesture_detector.cc
index 7523ad0e655..5ee0e7c894d 100644
--- a/chromium/ui/events/gesture_detection/gesture_detector.cc
+++ b/chromium/ui/events/gesture_detection/gesture_detector.cc
@@ -11,6 +11,7 @@
#include "base/numerics/ranges.h"
#include "base/timer/timer.h"
#include "build/build_config.h"
+#include "ui/events/event_constants.h"
#include "ui/events/gesture_detection/gesture_listeners.h"
#include "ui/events/gesture_detection/motion_event.h"
#include "ui/gfx/geometry/angle_conversions.h"
@@ -51,6 +52,11 @@ GestureDetector::Config::Config()
two_finger_tap_max_separation(300),
two_finger_tap_timeout(base::TimeDelta::FromMilliseconds(700)),
single_tap_repeat_interval(1),
+#if defined(OS_CHROMEOS)
+ stylus_button_accelerated_longpress_enabled(true),
+#else
+ stylus_button_accelerated_longpress_enabled(false),
+#endif
velocity_tracker_strategy(VelocityTracker::Strategy::STRATEGY_DEFAULT) {
}
@@ -135,6 +141,7 @@ GestureDetector::GestureDetector(
last_focus_y_(0),
down_focus_x_(0),
down_focus_y_(0),
+ stylus_button_accelerated_longpress_enabled_(false),
longpress_enabled_(true),
showpress_enabled_(true),
swipe_enabled_(false),
@@ -333,6 +340,11 @@ bool GestureDetector::OnTouchEvent(const MotionEvent& ev,
last_focus_y_ = focus_y;
}
+ if (stylus_button_accelerated_longpress_enabled_ &&
+ (ev.GetFlags() & ui::EF_LEFT_MOUSE_BUTTON)) {
+ OnStylusButtonPress(ev);
+ }
+
if (!two_finger_tap_allowed_for_gesture_)
break;
@@ -458,6 +470,8 @@ void GestureDetector::Init(const Config& config) {
DCHECK_GE(config.single_tap_repeat_interval, 1);
single_tap_repeat_interval_ = config.single_tap_repeat_interval;
+ stylus_button_accelerated_longpress_enabled_ =
+ config.stylus_button_accelerated_longpress_enabled;
}
void GestureDetector::OnShowPressTimeout() {
@@ -481,6 +495,20 @@ void GestureDetector::OnTapTimeout() {
}
}
+void GestureDetector::OnStylusButtonPress(const MotionEvent& ev) {
+ if (!timeout_handler_->HasTimeout(LONG_PRESS))
+ return;
+ timeout_handler_->StopTimeout(TAP);
+ timeout_handler_->StopTimeout(SHOW_PRESS);
+ timeout_handler_->StopTimeout(LONG_PRESS);
+ defer_confirm_single_tap_ = false;
+ // This will generate a ET_GESTURE_LONG_PRESS event with EF_LEFT_MOUSE_BUTTON,
+ // which is consumed by MetalayerMode if that feature is enabled, because
+ // MetalayerMode is also activated by a stylus button press and has precedence
+ // over this press acceleration feature.
+ listener_->OnLongPress(ev);
+}
+
void GestureDetector::Cancel() {
// Stop waiting for a second tap and send a GESTURE_TAP_CANCEL to keep the
// gesture stream valid.
diff --git a/chromium/ui/events/gesture_detection/gesture_detector.h b/chromium/ui/events/gesture_detection/gesture_detector.h
index 761bc5a0b02..e525277bdd3 100644
--- a/chromium/ui/events/gesture_detection/gesture_detector.h
+++ b/chromium/ui/events/gesture_detection/gesture_detector.h
@@ -77,6 +77,10 @@ class GESTURE_DETECTION_EXPORT GestureDetector {
// count will always be 1.
int single_tap_repeat_interval;
+ // Whether a longpress should be generated immediately when a stylus button
+ // is pressed, given that the longpress timeout is still active.
+ bool stylus_button_accelerated_longpress_enabled;
+
VelocityTracker::Strategy velocity_tracker_strategy;
};
@@ -112,6 +116,7 @@ class GESTURE_DETECTION_EXPORT GestureDetector {
void OnShowPressTimeout();
void OnLongPressTimeout();
void OnTapTimeout();
+ void OnStylusButtonPress(const MotionEvent& ev);
void Cancel();
void CancelTaps();
bool IsRepeatedTap(const MotionEvent& first_down,
@@ -172,6 +177,7 @@ class GESTURE_DETECTION_EXPORT GestureDetector {
float down_focus_x_;
float down_focus_y_;
+ bool stylus_button_accelerated_longpress_enabled_;
bool longpress_enabled_;
bool showpress_enabled_;
bool swipe_enabled_;
diff --git a/chromium/ui/events/gesture_detection/gesture_event_data.h b/chromium/ui/events/gesture_detection/gesture_event_data.h
index eea08a7f37b..f805e5880db 100644
--- a/chromium/ui/events/gesture_detection/gesture_event_data.h
+++ b/chromium/ui/events/gesture_detection/gesture_event_data.h
@@ -8,10 +8,10 @@
#include <stddef.h>
#include "base/time/time.h"
-#include "ui/events/event_constants.h"
#include "ui/events/gesture_detection/gesture_detection_export.h"
#include "ui/events/gesture_detection/motion_event.h"
#include "ui/events/gesture_event_details.h"
+#include "ui/events/types/event_type.h"
namespace ui {
diff --git a/chromium/ui/events/gesture_detection/gesture_provider.cc b/chromium/ui/events/gesture_detection/gesture_provider.cc
index eadc4cd6f85..87c7324d18b 100644
--- a/chromium/ui/events/gesture_detection/gesture_provider.cc
+++ b/chromium/ui/events/gesture_detection/gesture_provider.cc
@@ -18,6 +18,7 @@
#include "ui/events/gesture_detection/motion_event.h"
#include "ui/events/gesture_detection/motion_event_generic.h"
#include "ui/events/gesture_detection/scale_gesture_listeners.h"
+#include "ui/events/types/event_type.h"
#include "ui/gfx/geometry/point_f.h"
#include "ui/gfx/geometry/vector2d_f.h"
diff --git a/chromium/ui/events/gesture_detection/gesture_provider_unittest.cc b/chromium/ui/events/gesture_detection/gesture_provider_unittest.cc
index e773cc966cd..9c0b37bb253 100644
--- a/chromium/ui/events/gesture_detection/gesture_provider_unittest.cc
+++ b/chromium/ui/events/gesture_detection/gesture_provider_unittest.cc
@@ -21,6 +21,7 @@
#include "ui/events/gesture_detection/gesture_event_data.h"
#include "ui/events/gesture_detection/motion_event.h"
#include "ui/events/test/motion_event_test_utils.h"
+#include "ui/events/types/event_type.h"
#include "ui/gfx/geometry/point_f.h"
using base::TimeDelta;
@@ -297,6 +298,13 @@ class GestureProviderTest : public testing::Test, public GestureProviderClient {
SetUpWithConfig(config);
}
+ void SetStylusButtonAcceleratedLongPress(bool enabled) {
+ GestureProvider::Config config = GetDefaultConfig();
+ config.gesture_detector_config.stylus_button_accelerated_longpress_enabled =
+ enabled;
+ SetUpWithConfig(config);
+ }
+
bool HasDownEvent() const { return gesture_provider_->current_down_event(); }
protected:
@@ -1248,6 +1256,36 @@ TEST_F(GestureProviderTest, GestureLongPressDoesNotPreventScrolling) {
EXPECT_FALSE(HasReceivedGesture(ET_GESTURE_LONG_TAP));
}
+TEST_F(GestureProviderTest, StylusButtonCausesLongPress) {
+ SetStylusButtonAcceleratedLongPress(true);
+ base::TimeTicks event_time = base::TimeTicks::Now();
+
+ MockMotionEvent event =
+ ObtainMotionEvent(event_time, MotionEvent::Action::DOWN);
+ EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
+
+ event = ObtainMotionEvent(event_time + kOneMicrosecond,
+ MotionEvent::Action::MOVE);
+ event.set_flags(EF_LEFT_MOUSE_BUTTON);
+ EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
+ EXPECT_EQ(ET_GESTURE_LONG_PRESS, GetMostRecentGestureEventType());
+}
+
+TEST_F(GestureProviderTest, DisabledStylusButtonDoesNotCauseLongPress) {
+ SetStylusButtonAcceleratedLongPress(false);
+ base::TimeTicks event_time = base::TimeTicks::Now();
+
+ MockMotionEvent event =
+ ObtainMotionEvent(event_time, MotionEvent::Action::DOWN);
+ EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
+
+ event = ObtainMotionEvent(event_time + kOneMicrosecond,
+ MotionEvent::Action::MOVE);
+ event.set_flags(EF_LEFT_MOUSE_BUTTON);
+ EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
+ EXPECT_NE(ET_GESTURE_LONG_PRESS, GetMostRecentGestureEventType());
+}
+
TEST_F(GestureProviderTest, NoGestureLongPressDuringDoubleTap) {
base::TimeTicks event_time = base::TimeTicks::Now();
int motion_event_id = 6;
diff --git a/chromium/ui/events/gesture_detection/touch_disposition_gesture_filter.h b/chromium/ui/events/gesture_detection/touch_disposition_gesture_filter.h
index 8c63fdeb77f..fd9fa50509f 100644
--- a/chromium/ui/events/gesture_detection/touch_disposition_gesture_filter.h
+++ b/chromium/ui/events/gesture_detection/touch_disposition_gesture_filter.h
@@ -9,10 +9,10 @@
#include "base/containers/queue.h"
#include "base/macros.h"
-#include "ui/events/event_constants.h"
#include "ui/events/gesture_detection/bitset_32.h"
#include "ui/events/gesture_detection/gesture_detection_export.h"
#include "ui/events/gesture_detection/gesture_event_data_packet.h"
+#include "ui/events/types/event_type.h"
namespace ui {