Chromium Code Reviews| 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 0319da91b56843494f6c487d3876f316098142fd..f4fc4c61f105188e50fd49f283d102daa209eaee 100644 |
| --- a/ui/events/platform/x11/x11_event_source.cc |
| +++ b/ui/events/platform/x11/x11_event_source.cc |
| @@ -4,10 +4,12 @@ |
| #include "ui/events/platform/x11/x11_event_source.h" |
| +#include <X11/Xatom.h> |
| #include <X11/XKBlib.h> |
| #include <X11/Xlib.h> |
| #include "base/logging.h" |
| +#include "base/metrics/histogram_macros.h" |
| #include "ui/events/devices/x11/device_data_manager_x11.h" |
| #include "ui/events/event_utils.h" |
| #include "ui/events/platform/platform_event_dispatcher.h" |
| @@ -126,6 +128,43 @@ void X11EventSource::BlockUntilWindowMapped(XID window) { |
| } while (event.type != MapNotify); |
| } |
| +static Bool is_property_notify_for_timestamp(Display* display, |
|
sky
2016/05/07 16:58:34
Move into anonymous namespace above, and no static
Tom (Use chromium acct)
2016/05/09 17:49:59
Done.
|
| + XEvent* event, |
| + XPointer arg) { |
| + return event->type == PropertyNotify && |
| + event->xproperty.window == DefaultRootWindow(display) && |
| + event->xproperty.atom == *(Atom*)arg; |
| +} |
| + |
| +Time X11EventSource::UpdateServerTime() { |
|
sky
2016/05/07 16:58:34
UpdateLastSeenServerTime?
Tom (Use chromium acct)
2016/05/09 17:50:00
Done.
|
| + base::TimeTicks start = base::TimeTicks::Now(); |
| + |
| + const char kAtomStr[] = "X11_EVENT_SOURCE_UPDATE_SERVER_TIME_DUMMY_ATOM"; |
| + |
| + DCHECK(display_); |
| + Window window = DefaultRootWindow(display_); |
| + const unsigned char dummyData = 0; |
|
sky
2016/05/07 16:58:34
dummy_data and dummy_atom. Also, please add commen
Tom (Use chromium acct)
2016/05/09 17:49:59
Done.
|
| + Atom dummyAtom = XInternAtom(display_, kAtomStr, False); |
| + |
| + XSelectInput(display_, window, PropertyChangeMask); |
| + |
| + XChangeProperty(display_, window, dummyAtom, XA_INTEGER, 8, PropModeReplace, |
| + &dummyData, 1); |
| + |
| + XEvent event; |
| + XIfEvent(display_, &event, is_property_notify_for_timestamp, |
| + (XPointer)&dummyAtom); |
| + |
| + XDeleteProperty(display_, window, dummyAtom); |
| + XFlush(display_); |
| + |
| + last_seen_server_time_ = event.xproperty.time; |
| + |
| + UMA_HISTOGRAM_TIMES("Event.Latency.X11EventSource.UpdateServerTime", |
| + base::TimeTicks::Now() - start); |
| + return last_seen_server_time_; |
| +} |
| + |
| //////////////////////////////////////////////////////////////////////////////// |
| // X11EventSource, protected |