From 214641ff29d7ebec18adf8430750e3fa0ed7a903 Mon Sep 17 00:00:00 2001 From: Robert Ancell Date: Fri, 24 Apr 2020 13:30:34 +1200 Subject: [PATCH] Fix units used in Linux shell timestamps. (flutter/engine#17912) GTK uses timestamps in milliseconds, Flutter wants them in microseconds. --- .../shell/platform/linux/fl_engine_private.h | 2 +- engine/src/flutter/shell/platform/linux/fl_view.cc | 13 +++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/engine/src/flutter/shell/platform/linux/fl_engine_private.h b/engine/src/flutter/shell/platform/linux/fl_engine_private.h index 32e4cc61ef..f4d49572e5 100644 --- a/engine/src/flutter/shell/platform/linux/fl_engine_private.h +++ b/engine/src/flutter/shell/platform/linux/fl_engine_private.h @@ -66,7 +66,7 @@ void fl_engine_send_window_metrics_event(FlEngine* engine, * fl_engine_send_mouse_pointer_event: * @engine: a #FlEngine * @phase: mouse phase. - * @timestamp: time when event occurred in nanoseconds. + * @timestamp: time when event occurred in microseconds. * @x: x location of mouse cursor. * @y: y location of mouse cursor. * @buttons: buttons that are pressed. diff --git a/engine/src/flutter/shell/platform/linux/fl_view.cc b/engine/src/flutter/shell/platform/linux/fl_view.cc index 07a1f9f7be..c5855e9d4c 100644 --- a/engine/src/flutter/shell/platform/linux/fl_view.cc +++ b/engine/src/flutter/shell/platform/linux/fl_view.cc @@ -10,7 +10,7 @@ #include -#define NSEC_PER_MSEC 1000000 +static constexpr int kMicrosecondsPerMillisecond = 1000; struct _FlView { GtkWidget parent_instance; @@ -63,8 +63,8 @@ static gboolean fl_view_send_pointer_button_event(FlView* self, return FALSE; fl_engine_send_mouse_pointer_event(self->engine, phase, - event->time * NSEC_PER_MSEC, event->x, - event->y, self->button_state); + event->time * kMicrosecondsPerMillisecond, + event->x, event->y, self->button_state); return TRUE; } @@ -188,9 +188,10 @@ static gboolean fl_view_motion_notify_event(GtkWidget* widget, if (self->engine == nullptr) return FALSE; - fl_engine_send_mouse_pointer_event( - self->engine, self->button_state != 0 ? kMove : kHover, - event->time * NSEC_PER_MSEC, event->x, event->y, self->button_state); + fl_engine_send_mouse_pointer_event(self->engine, + self->button_state != 0 ? kMove : kHover, + event->time * kMicrosecondsPerMillisecond, + event->x, event->y, self->button_state); return TRUE; }