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, ...@@ -96,6 +96,7 @@ X11EventSource::X11EventSource(X11EventSourceDelegate* delegate,
XDisplay* display) XDisplay* display)
: delegate_(delegate), : delegate_(delegate),
display_(display), display_(display),
dispatching_event_(nullptr),
dummy_initialized_(false), dummy_initialized_(false),
continue_stream_(true) { continue_stream_(true) {
DCHECK(!instance_); DCHECK(!instance_);
...@@ -183,9 +184,8 @@ Time X11EventSource::GetCurrentServerTime() { ...@@ -183,9 +184,8 @@ Time X11EventSource::GetCurrentServerTime() {
} }
Time X11EventSource::GetTimestamp() { Time X11EventSource::GetTimestamp() {
if (!dispatching_events_.empty()) { if (dispatching_event_) {
DCHECK(dispatching_events_.top()); Time timestamp = ExtractTimeFromXEvent(*dispatching_event_);
Time timestamp = ExtractTimeFromXEvent(*dispatching_events_.top());
if (timestamp != CurrentTime) if (timestamp != CurrentTime)
return timestamp; return timestamp;
} }
...@@ -195,10 +195,10 @@ Time X11EventSource::GetTimestamp() { ...@@ -195,10 +195,10 @@ Time X11EventSource::GetTimestamp() {
base::Optional<gfx::Point> base::Optional<gfx::Point>
X11EventSource::GetRootCursorLocationFromCurrentEvent() const { X11EventSource::GetRootCursorLocationFromCurrentEvent() const {
if (dispatching_events_.empty()) if (!dispatching_event_)
return base::nullopt; return base::nullopt;
XEvent* event = dispatching_events_.top(); XEvent* event = dispatching_event_;
DCHECK(event); DCHECK(event);
bool is_xi2_event = event->type == GenericEvent; bool is_xi2_event = event->type == GenericEvent;
...@@ -239,12 +239,12 @@ void X11EventSource::ExtractCookieDataDispatchEvent(XEvent* xevent) { ...@@ -239,12 +239,12 @@ void X11EventSource::ExtractCookieDataDispatchEvent(XEvent* xevent) {
have_cookie = true; have_cookie = true;
} }
dispatching_events_.push(xevent); dispatching_event_ = xevent;
delegate_->ProcessXEvent(xevent); delegate_->ProcessXEvent(xevent);
PostDispatchEvent(xevent); PostDispatchEvent(xevent);
dispatching_events_.pop(); dispatching_event_ = nullptr;
if (have_cookie) if (have_cookie)
XFreeEventData(xevent->xgeneric.display, &xevent->xcookie); XFreeEventData(xevent->xgeneric.display, &xevent->xcookie);
......
...@@ -8,7 +8,6 @@ ...@@ -8,7 +8,6 @@
#include <stdint.h> #include <stdint.h>
#include <memory> #include <memory>
#include <stack>
#include "base/macros.h" #include "base/macros.h"
#include "base/optional.h" #include "base/optional.h"
...@@ -115,9 +114,8 @@ class EVENTS_EXPORT X11EventSource { ...@@ -115,9 +114,8 @@ class EVENTS_EXPORT X11EventSource {
// The connection to the X11 server used to receive the events. // The connection to the X11 server used to receive the events.
XDisplay* display_; XDisplay* display_;
// Events currently being dispatched. The topmost event in this stack // Event currently being dispatched.
// corresponds to the deepest-nested message loop. XEvent* dispatching_event_;
std::stack<XEvent*> dispatching_events_;
// State necessary for UpdateLastSeenServerTime // State necessary for UpdateLastSeenServerTime
bool dummy_initialized_; 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