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

Unified Diff: content/browser/renderer_host/render_widget_host_view_android.cc

Issue 2943383002: Android double/triple click (Closed)
Patch Set: fixing DIP Created 3 years, 6 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: content/browser/renderer_host/render_widget_host_view_android.cc
diff --git a/content/browser/renderer_host/render_widget_host_view_android.cc b/content/browser/renderer_host/render_widget_host_view_android.cc
index e1437b451ef82a6ccbdaa7bcdb0cfded5a8c3592..037074399612ae46d33710ebb9024a96c266409c 100644
--- a/content/browser/renderer_host/render_widget_host_view_android.cc
+++ b/content/browser/renderer_host/render_widget_host_view_android.cc
@@ -102,6 +102,8 @@ namespace content {
namespace {
static const char kAsyncReadBackString[] = "Compositing.CopyFromSurfaceTime";
+static const double kMaxClickDelay = 0.5;
aelias_OOO_until_Jul13 2017/06/20 18:57:52 Would prefer names "kClickCountInterval", "kClickC
amaralp 2017/06/21 00:33:40 Done.
+static const float kMaxClickDistance = 5;
class PendingReadbackLock;
@@ -1801,11 +1803,26 @@ void RenderWidgetHostViewAndroid::SendMouseEvent(
blink::WebInputEvent::Type webMouseEventType =
ui::ToWebMouseEventType(motion_event.GetAction());
+ const double event_time =
+ ui::EventTimeStampToSeconds(motion_event.GetEventTime());
+ if (webMouseEventType == blink::WebInputEvent::kMouseDown) {
aelias_OOO_until_Jul13 2017/06/20 18:57:52 This also should take into account which button wa
amaralp 2017/06/21 00:33:40 Made only count left-clicks.
+ gfx::Point mousedown_point(motion_event.GetX(0), motion_event.GetY(0));
+ const double time_delay = event_time - prev_mousedown_timestamp_;
+ const float distance = (mousedown_point - prev_mousedown_point_).Length();
+ if (click_count_ > 2 || time_delay > kMaxClickDelay ||
+ distance > kMaxClickDistance) {
+ click_count_ = 1;
aelias_OOO_until_Jul13 2017/06/20 18:57:52 1-based counting system feels weird. I'd prefer:
amaralp 2017/06/21 00:33:40 Done.
+ } else {
+ click_count_++;
+ }
+ prev_mousedown_timestamp_ = event_time;
+ prev_mousedown_point_ = mousedown_point;
+ }
+
blink::WebMouseEvent mouse_event = WebMouseEventBuilder::Build(
- webMouseEventType,
- ui::EventTimeStampToSeconds(motion_event.GetEventTime()),
- motion_event.GetX(0), motion_event.GetY(0), motion_event.GetFlags(),
- motion_event.GetButtonState() ? 1 : 0 /* click count */,
+ webMouseEventType, event_time, motion_event.GetX(0), motion_event.GetY(0),
+ motion_event.GetFlags(),
+ motion_event.GetButtonState() ? click_count_ : 0 /* click count */,
aelias_OOO_until_Jul13 2017/06/20 18:57:52 I suggest integrating this condition in the core c
amaralp 2017/06/21 00:33:40 The problem is that I don't want to set click_coun
motion_event.GetPointerId(0), motion_event.GetPressure(0),
motion_event.GetOrientation(0), motion_event.GetTiltX(0),
motion_event.GetTiltY(0), action_button, motion_event.GetToolType(0));

Powered by Google App Engine
This is Rietveld 408576698