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

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

Issue 2398343002: X11: Avoid round-tripping to get the cursor position (Closed)
Patch Set: Add DCHECK Created 4 years, 2 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
« no previous file with comments | « ui/events/platform/x11/x11_event_source.h ('k') | ui/views/widget/desktop_aura/desktop_screen_x11.cc » ('j') | 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 a49cda90a74ed351b5a6c367e8120fa359dbf70c..1a9aa94b6a1954ecaccfb8626ff6dd24c4a9027c 100644
--- a/ui/events/platform/x11/x11_event_source.cc
+++ b/ui/events/platform/x11/x11_event_source.cc
@@ -96,7 +96,6 @@ X11EventSource::X11EventSource(X11EventSourceDelegate* delegate,
XDisplay* display)
: delegate_(delegate),
display_(display),
- event_timestamp_(CurrentTime),
dummy_initialized_(false),
continue_stream_(true) {
DCHECK(!instance_);
@@ -184,13 +183,43 @@ Time X11EventSource::GetCurrentServerTime() {
}
Time X11EventSource::GetTimestamp() {
- if (event_timestamp_ != CurrentTime) {
- return event_timestamp_;
+ if (!dispatching_events_.empty()) {
+ DCHECK(dispatching_events_.top());
+ Time timestamp = ExtractTimeFromXEvent(*dispatching_events_.top());
+ if (timestamp != CurrentTime)
+ return timestamp;
}
DVLOG(1) << "Making a round trip to get a recent server timestamp.";
return GetCurrentServerTime();
}
+base::Optional<gfx::Point>
+X11EventSource::GetRootCursorLocationFromCurrentEvent() const {
+ if (dispatching_events_.empty())
+ return base::nullopt;
+
+ XEvent* event = dispatching_events_.top();
+ DCHECK(event);
+ bool is_valid_event = false;
+ switch (event->type) {
+ case ButtonPress:
+ case ButtonRelease:
+ case MotionNotify:
+ case EnterNotify:
+ case LeaveNotify:
+ is_valid_event = true;
+ break;
+ case GenericEvent:
+ if (!ui::TouchFactory::GetInstance()->ShouldProcessXI2Event(event))
+ break;
+ is_valid_event = true;
+ }
+
+ if (is_valid_event)
+ return ui::EventSystemLocationFromNative(event);
+ return base::nullopt;
+}
+
////////////////////////////////////////////////////////////////////////////////
// X11EventSource, protected
@@ -201,12 +230,12 @@ void X11EventSource::ExtractCookieDataDispatchEvent(XEvent* xevent) {
have_cookie = true;
}
- event_timestamp_ = ExtractTimeFromXEvent(*xevent);
+ dispatching_events_.push(xevent);
delegate_->ProcessXEvent(xevent);
PostDispatchEvent(xevent);
- event_timestamp_ = CurrentTime;
+ dispatching_events_.pop();
if (have_cookie)
XFreeEventData(xevent->xgeneric.display, &xevent->xcookie);
« no previous file with comments | « ui/events/platform/x11/x11_event_source.h ('k') | ui/views/widget/desktop_aura/desktop_screen_x11.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698