Commit 12871d4b authored by thomasanderson's avatar thomasanderson Committed by Commit bot

X11: Reset dispatching event when nested message loop ends

BUG=672763

Review-Url: https://codereview.chromium.org/2568233003
Cr-Commit-Position: refs/heads/master@{#438203}
parent d2233a75
......@@ -96,6 +96,7 @@ X11EventSource::X11EventSource(X11EventSourceDelegate* delegate,
XDisplay* display)
: delegate_(delegate),
display_(display),
dispatching_event_(nullptr),
dummy_initialized_(false),
continue_stream_(true) {
DCHECK(!instance_);
......@@ -183,9 +184,8 @@ Time X11EventSource::GetCurrentServerTime() {
}
Time X11EventSource::GetTimestamp() {
if (!dispatching_events_.empty()) {
DCHECK(dispatching_events_.top());
Time timestamp = ExtractTimeFromXEvent(*dispatching_events_.top());
if (dispatching_event_) {
Time timestamp = ExtractTimeFromXEvent(*dispatching_event_);
if (timestamp != CurrentTime)
return timestamp;
}
......@@ -195,10 +195,10 @@ Time X11EventSource::GetTimestamp() {
base::Optional<gfx::Point>
X11EventSource::GetRootCursorLocationFromCurrentEvent() const {
if (dispatching_events_.empty())
if (!dispatching_event_)
return base::nullopt;
XEvent* event = dispatching_events_.top();
XEvent* event = dispatching_event_;
DCHECK(event);
bool is_xi2_event = event->type == GenericEvent;
......@@ -239,12 +239,12 @@ void X11EventSource::ExtractCookieDataDispatchEvent(XEvent* xevent) {
have_cookie = true;
}
dispatching_events_.push(xevent);
dispatching_event_ = xevent;
delegate_->ProcessXEvent(xevent);
PostDispatchEvent(xevent);
dispatching_events_.pop();
dispatching_event_ = nullptr;
if (have_cookie)
XFreeEventData(xevent->xgeneric.display, &xevent->xcookie);
......
......@@ -8,7 +8,6 @@
#include <stdint.h>
#include <memory>
#include <stack>
#include "base/macros.h"
#include "base/optional.h"
......@@ -115,9 +114,8 @@ class EVENTS_EXPORT X11EventSource {
// The connection to the X11 server used to receive the events.
XDisplay* display_;
// Events currently being dispatched. The topmost event in this stack
// corresponds to the deepest-nested message loop.
std::stack<XEvent*> dispatching_events_;
// Event currently being dispatched.
XEvent* dispatching_event_;
// State necessary for UpdateLastSeenServerTime
bool dummy_initialized_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment