Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(364)

Unified Diff: ui/events/platform/x11/x11_event_source_libevent.cc

Issue 244093002: x11: Make the event-source work with both glib and libevent message-pumps. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/events/platform/x11/x11_event_source_glib.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
new file mode 100644
index 0000000000000000000000000000000000000000..0f27e69f69fda1642e251795ebe5bb9d1679cc72
--- /dev/null
+++ b/ui/events/platform/x11/x11_event_source_libevent.cc
@@ -0,0 +1,51 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// 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 <X11/Xlib.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) {
+ int fd = ConnectionNumber(display);
+ base::MessageLoopForUI::current()->WatchFileDescriptor(fd, true,
+ base::MessagePumpLibevent::WATCH_READ, &watcher_controller_, this);
+ }
+
+ virtual ~X11EventSourceLibevent() {
+ }
+
+ private:
+ // base::MessagePumpLibevent::Watcher:
+ virtual void OnFileCanReadWithoutBlocking(int fd) OVERRIDE {
+ DispatchXEvents();
+ }
+
+ virtual void OnFileCanWriteWithoutBlocking(int fd) OVERRIDE {
+ NOTREACHED();
+ }
+
+ base::MessagePumpLibevent::FileDescriptorWatcher watcher_controller_;
+
+ DISALLOW_COPY_AND_ASSIGN(X11EventSourceLibevent);
+};
+
+} // namespace
+
+scoped_ptr<PlatformEventSource> PlatformEventSource::CreateDefault() {
+ return scoped_ptr<PlatformEventSource>(
+ new X11EventSourceLibevent(gfx::GetXDisplay()));
+}
+
+} // namespace ui
« no previous file with comments | « ui/events/platform/x11/x11_event_source_glib.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698