mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-08 19:04:45 +00:00
Bug 1348310 - Use CLOCK_MONOTONIC as a base for nsWindow::GetEventTimeStamp() on Wayland, r=karlt
We assume CLOCK_MONOTONIC as timebase for events on Wayland and use that to translates GDK event times to gecko timestamps. MozReview-Commit-ID: LWd2KWTQeha --HG-- extra : rebase_source : 1839d35989b9c29c60dd33d445db79afc75af9ab
This commit is contained in:
parent
f2055ece85
commit
79aef7f85b
@ -422,9 +422,11 @@ public:
|
||||
* False on Windows 7
|
||||
* Android's event time uses CLOCK_MONOTONIC via SystemClock.uptimeMilles.
|
||||
* So it is same value of TimeStamp posix implementation.
|
||||
* Wayland/GTK event time also uses CLOCK_MONOTONIC on Weston/Mutter
|
||||
* compositors.
|
||||
* UNTESTED ON OTHER PLATFORMS
|
||||
*/
|
||||
#if defined(XP_DARWIN) || defined(MOZ_WIDGET_ANDROID)
|
||||
#if defined(XP_DARWIN) || defined(MOZ_WIDGET_ANDROID) || defined(MOZ_WIDGET_GTK)
|
||||
static TimeStamp FromSystemTime(int64_t aSystemTime)
|
||||
{
|
||||
static_assert(sizeof(aSystemTime) == sizeof(TimeStampValue),
|
||||
|
@ -2994,11 +2994,26 @@ nsWindow::GetEventTimeStamp(guint32 aEventTime)
|
||||
// In this case too, just return the current timestamp.
|
||||
return TimeStamp::Now();
|
||||
}
|
||||
CurrentX11TimeGetter* getCurrentTime = GetCurrentTimeGetter();
|
||||
MOZ_ASSERT(getCurrentTime,
|
||||
"Null current time getter despite having a window");
|
||||
return TimeConverter().GetTimeStampFromSystemTime(aEventTime,
|
||||
*getCurrentTime);
|
||||
|
||||
TimeStamp eventTimeStamp;
|
||||
|
||||
if (!mIsX11Display) {
|
||||
// Wayland compositors use monotonic time to set timestamps.
|
||||
int64_t timestampTime = g_get_monotonic_time() / 1000;
|
||||
guint32 refTimeTruncated = guint32(timestampTime);
|
||||
|
||||
timestampTime -= refTimeTruncated - aEventTime;
|
||||
int64_t tick =
|
||||
BaseTimeDurationPlatformUtils::TicksFromMilliseconds(timestampTime);
|
||||
eventTimeStamp = TimeStamp::FromSystemTime(tick);
|
||||
} else {
|
||||
CurrentX11TimeGetter* getCurrentTime = GetCurrentTimeGetter();
|
||||
MOZ_ASSERT(getCurrentTime,
|
||||
"Null current time getter despite having a window");
|
||||
eventTimeStamp = TimeConverter().GetTimeStampFromSystemTime(aEventTime,
|
||||
*getCurrentTime);
|
||||
}
|
||||
return eventTimeStamp;
|
||||
}
|
||||
|
||||
mozilla::CurrentX11TimeGetter*
|
||||
|
Loading…
Reference in New Issue
Block a user