| 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 a3ff7a50f94486676686ff6308f08c8938b7335a..fac41d80a8da24ccb2a495986be712cfcc89e683 100644
|
| --- a/ui/events/platform/x11/x11_event_source_libevent.cc
|
| +++ b/ui/events/platform/x11/x11_event_source_libevent.cc
|
| @@ -2,64 +2,43 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| -#include "ui/events/platform/x11/x11_event_source.h"
|
| +#include "ui/events/platform/x11/x11_event_source_libevent.h"
|
|
|
| #include <X11/Xlib.h>
|
|
|
| -#include "base/macros.h"
|
| -#include "base/message_loop/message_loop.h"
|
| -#include "base/message_loop/message_pump_libevent.h"
|
| -
|
| namespace ui {
|
|
|
| -namespace {
|
| -
|
| -class X11EventSourceLibevent : public X11EventSource,
|
| - public base::MessagePumpLibevent::Watcher {
|
| - public:
|
| - explicit X11EventSourceLibevent(XDisplay* display)
|
| - : X11EventSource(display),
|
| - initialized_(false) {
|
| - AddEventWatcher();
|
| - }
|
| -
|
| - ~X11EventSourceLibevent() override {
|
| - }
|
| -
|
| - private:
|
| - void AddEventWatcher() {
|
| - if (initialized_)
|
| - return;
|
| - if (!base::MessageLoop::current())
|
| - return;
|
| -
|
| - int fd = ConnectionNumber(display());
|
| - base::MessageLoopForUI::current()->WatchFileDescriptor(fd, true,
|
| - base::MessagePumpLibevent::WATCH_READ, &watcher_controller_, this);
|
| - initialized_ = true;
|
| - }
|
| +X11EventSourceLibevent::X11EventSourceLibevent(XDisplay* display)
|
| + : X11EventSource(display), initialized_(false) {
|
| + AddEventWatcher();
|
| +}
|
|
|
| - // PlatformEventSource:
|
| - void OnDispatcherListChanged() override {
|
| - AddEventWatcher();
|
| - }
|
| +X11EventSourceLibevent::~X11EventSourceLibevent() {}
|
|
|
| - // base::MessagePumpLibevent::Watcher:
|
| - void OnFileCanReadWithoutBlocking(int fd) override {
|
| - DispatchXEvents();
|
| - }
|
| +void X11EventSourceLibevent::AddEventWatcher() {
|
| + if (initialized_)
|
| + return;
|
| + if (!base::MessageLoop::current())
|
| + return;
|
|
|
| - void OnFileCanWriteWithoutBlocking(int fd) override {
|
| - NOTREACHED();
|
| - }
|
| + int fd = ConnectionNumber(display());
|
| + base::MessageLoopForUI::current()->WatchFileDescriptor(
|
| + fd, true, base::MessagePumpLibevent::WATCH_READ, &watcher_controller_,
|
| + this);
|
| + initialized_ = true;
|
| +}
|
|
|
| - base::MessagePumpLibevent::FileDescriptorWatcher watcher_controller_;
|
| - bool initialized_;
|
| +void X11EventSourceLibevent::OnDispatcherListChanged() {
|
| + AddEventWatcher();
|
| +}
|
|
|
| - DISALLOW_COPY_AND_ASSIGN(X11EventSourceLibevent);
|
| -};
|
| +void X11EventSourceLibevent::OnFileCanReadWithoutBlocking(int fd) {
|
| + DispatchXEvents();
|
| +}
|
|
|
| -} // namespace
|
| +void X11EventSourceLibevent::OnFileCanWriteWithoutBlocking(int fd) {
|
| + NOTREACHED();
|
| +}
|
|
|
| scoped_ptr<PlatformEventSource> PlatformEventSource::CreateDefault() {
|
| return make_scoped_ptr(new X11EventSourceLibevent(gfx::GetXDisplay()));
|
|
|