Index: ui/events/platform/x11/x11_event_source_libevent.cc |
diff --git a/ui/events/platform/x11/x11_event_source_libevent.cc b/ui/events/platform/x11/x11_event_source_libevent.cc |
index ff01d2e13c5580c41cd871edf1a905fb9df30e44..c38cba400ff2072ad3fbb96a98dd3aff45326863 100644 |
--- a/ui/events/platform/x11/x11_event_source_libevent.cc |
+++ b/ui/events/platform/x11/x11_event_source_libevent.cc |
@@ -14,6 +14,7 @@ namespace ui { |
namespace { |
class X11EventSourceLibevent : public X11EventSource, |
+ public base::MessagePumpLibevent::EventSource, |
public base::MessagePumpLibevent::Watcher { |
public: |
explicit X11EventSourceLibevent(XDisplay* display) |
@@ -23,6 +24,8 @@ class X11EventSourceLibevent : public X11EventSource, |
} |
~X11EventSourceLibevent() override { |
+ if (initialized_) |
+ base::MessageLoopForUI::current()->ClearEventSource(); |
} |
private: |
@@ -33,15 +36,18 @@ class X11EventSourceLibevent : public X11EventSource, |
return; |
int fd = ConnectionNumber(display()); |
- base::MessageLoopForUI::current()->WatchFileDescriptor(fd, true, |
- base::MessagePumpLibevent::WATCH_READ, &watcher_controller_, this); |
+ base::MessageLoopForUI::current()->WatchFileDescriptor( |
+ fd, true, base::MessagePumpLibevent::WATCH_READ, &watcher_controller_, |
+ this); |
+ base::MessageLoopForUI::current()->SetEventSource(this); |
initialized_ = true; |
} |
// PlatformEventSource: |
- void OnDispatcherListChanged() override { |
- AddEventWatcher(); |
- } |
+ void OnDispatcherListChanged() override { AddEventWatcher(); } |
+ |
+ // base::MessagePumpLibEvent::EventSource: |
+ bool Poll() override { return DispatchXEvents(); } |
// base::MessagePumpLibevent::Watcher: |
void OnFileCanReadWithoutBlocking(int fd) override { |