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

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

Issue 1892483005: SelectionOwner: add support for TIMESTAMP target (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nogncheck Created 4 years, 8 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
« ui/base/x/selection_owner.cc ('K') | « ui/events/platform/x11/x11_event_source.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 e1bc15ecc3176812a5d161a07b252fb666514853..f577b3df406044bafbbecc5d0a556cdedb56ea57 100644
--- a/ui/events/platform/x11/x11_event_source.cc
+++ b/ui/events/platform/x11/x11_event_source.cc
@@ -46,7 +46,10 @@ X11EventSource* X11EventSource::instance_ = nullptr;
X11EventSource::X11EventSource(X11EventSourceDelegate* delegate,
XDisplay* display)
- : delegate_(delegate), display_(display), continue_stream_(true) {
+ : delegate_(delegate),
+ display_(display),
+ last_seen_server_time_(CurrentTime),
+ continue_stream_(true) {
DCHECK(!instance_);
instance_ = this;
@@ -102,6 +105,9 @@ void X11EventSource::ExtractCookieDataDispatchEvent(XEvent* xevent) {
XGetEventData(xevent->xgeneric.display, &xevent->xcookie)) {
have_cookie = true;
}
+ Time event_time = ExtractTimeFromXEvent(*xevent);
+ if (event_time != CurrentTime)
+ last_seen_server_time_ = event_time;
delegate_->ProcessXEvent(xevent);
PostDispatchEvent(xevent);
if (have_cookie)
@@ -126,6 +132,33 @@ void X11EventSource::PostDispatchEvent(XEvent* xevent) {
}
}
+Time X11EventSource::ExtractTimeFromXEvent(const XEvent& xevent) {
sadrul 2016/04/20 17:58:43 This can go in a standalone function in anon names
dcheng 2016/04/20 18:55:43 Done.
+ switch (xevent.type) {
+ case KeyPress:
+ case KeyRelease:
+ return xevent.xkey.time;
+ case ButtonPress:
+ case ButtonRelease:
+ return xevent.xbutton.time;
+ case MotionNotify:
+ return xevent.xmotion.time;
+ case EnterNotify:
+ case LeaveNotify:
+ return xevent.xcrossing.time;
+ case PropertyNotify:
+ return xevent.xproperty.time;
+ case SelectionClear:
+ return xevent.xselectionclear.time;
+ case SelectionRequest:
+ return xevent.xselectionrequest.time;
+ case SelectionNotify:
+ return xevent.xselection.time;
+ case GenericEvent:
+ return static_cast<XIDeviceEvent*>(xevent.xcookie.data)->time;
sadrul 2016/04/20 18:01:08 Also, you should check DeviceDataManagerX11::IsXID
dcheng 2016/04/20 18:55:43 Done. But as mentioned earlier, other code often d
+ }
+ return CurrentTime;
+}
+
void X11EventSource::StopCurrentEventStream() {
continue_stream_ = false;
}
« ui/base/x/selection_owner.cc ('K') | « ui/events/platform/x11/x11_event_source.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698