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

Unified Diff: ui/events/platform/x11/x11_event_source.cc

Issue 2165083002: Linux: Refactor X11DesktopHandler (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix tests Created 4 years, 4 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: ui/events/platform/x11/x11_event_source.cc
diff --git a/ui/events/platform/x11/x11_event_source.cc b/ui/events/platform/x11/x11_event_source.cc
index ea5638d34ec9fc54873db958277a390feb370098..ac6111ad93d5653887e8b42f2c60195e14b020c5 100644
--- a/ui/events/platform/x11/x11_event_source.cc
+++ b/ui/events/platform/x11/x11_event_source.cc
@@ -180,6 +180,18 @@ Time X11EventSource::UpdateLastSeenServerTime() {
return last_seen_server_time_;
}
+void X11EventSource::SetLastSeenServerTime(Time time) {
+ if (time != CurrentTime) {
+ int64_t event_time_64 = time;
+ int64_t time_difference = last_seen_server_time_ - event_time_64;
+ // Ignore timestamps that go backwards. However, X server time is a 32-bit
+ // millisecond counter, so if the time goes backwards by more than half the
+ // range of the 32-bit counter, treat it as a rollover.
+ if (time_difference < 0 || time_difference > (UINT32_MAX >> 1))
+ last_seen_server_time_ = time;
+ }
+}
+
////////////////////////////////////////////////////////////////////////////////
// X11EventSource, protected
@@ -189,16 +201,7 @@ void X11EventSource::ExtractCookieDataDispatchEvent(XEvent* xevent) {
XGetEventData(xevent->xgeneric.display, &xevent->xcookie)) {
have_cookie = true;
}
- Time event_time = ExtractTimeFromXEvent(*xevent);
- if (event_time != CurrentTime) {
- int64_t event_time_64 = event_time;
- int64_t time_difference = last_seen_server_time_ - event_time_64;
- // Ignore timestamps that go backwards. However, X server time is a 32-bit
- // millisecond counter, so if the time goes backwards by more than half the
- // range of the 32-bit counter, treat it as a rollover.
- if (time_difference < 0 || time_difference > (UINT32_MAX >> 1))
- last_seen_server_time_ = event_time;
- }
+ SetLastSeenServerTime(ExtractTimeFromXEvent(*xevent));
delegate_->ProcessXEvent(xevent);
PostDispatchEvent(xevent);
if (have_cookie)

Powered by Google App Engine
This is Rietveld 408576698