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 a49cda90a74ed351b5a6c367e8120fa359dbf70c..4f1f8c79b6b8cb4f586579de7202234e027e027f 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()) { |
| + 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(); |
| + bool is_valid_event = false; |
| + if (event) { |
|
sadrul
2016/10/12 00:17:17
Should this be a DCHECK()? This should never be nu
Tom (Use chromium acct)
2016/10/12 01:03:27
Done.
|
| + 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); |