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

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

Issue 2943383002: Android double/triple click (Closed)
Patch Set: move incrememnt outside if 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..b4011631617a9eed2566a28a08047350c1cfba0b 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,9 @@ namespace content {
namespace {
static const char kAsyncReadBackString[] = "Compositing.CopyFromSurfaceTime";
+static const base::TimeDelta kClickCountInterval =
+ base::TimeDelta::FromSecondsD(0.5);
+static const float kClickCountRadiusDIP = 5;
class PendingReadbackLock;
@@ -1801,11 +1804,33 @@ void RenderWidgetHostViewAndroid::SendMouseEvent(
blink::WebInputEvent::Type webMouseEventType =
ui::ToWebMouseEventType(motion_event.GetAction());
+ const base::TimeTicks current_time = base::TimeTicks::Now();
+ if (webMouseEventType == blink::WebInputEvent::kMouseDown) {
+ if (action_button == ui::MotionEventAndroid::BUTTON_PRIMARY) {
+ gfx::Point mousedown_point(motion_event.GetX(0), motion_event.GetY(0));
+ const base::TimeDelta time_delay =
+ current_time - prev_mousedown_timestamp_;
+ const float distance = (mousedown_point - prev_mousedown_point_).Length();
aelias_OOO_until_Jul13 2017/06/21 01:13:12 Although this doesn't happen on mousemove I still
amaralp 2017/06/21 19:34:21 Done.
+ if (click_count_ > 2 || time_delay > kClickCountInterval ||
+ distance > kClickCountRadiusDIP) {
+ click_count_ = 0;
+ }
+ prev_mousedown_timestamp_ = current_time;
+ prev_mousedown_point_ = mousedown_point;
+ } else {
+ // Reset state if left button isn't pressed.
aelias_OOO_until_Jul13 2017/06/21 01:13:12 "if middle or right button was pressed"
amaralp 2017/06/21 19:34:21 Done.
+ click_count_ = 0;
+ prev_mousedown_timestamp_ = base::TimeTicks();
+ prev_mousedown_point_ = gfx::Point();
aelias_OOO_until_Jul13 2017/06/21 01:13:12 gfx::Point(0, 0) can be a legal offset or close to
amaralp 2017/06/21 19:34:22 Done.
+ }
+ click_count_++;
+ }
+
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 */,
+ motion_event.GetButtonState() ? click_count_ : 0 /* click count */,
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