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

Unified Diff: chrome/common/x11_util.cc

Issue 100145: WIP: X clipboard stuff (Closed)
Patch Set: Created 11 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 | « chrome/browser/renderer_host/resource_message_filter_gtk.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/common/x11_util.cc
diff --git a/chrome/common/x11_util.cc b/chrome/common/x11_util.cc
index 537157356ccdaa2571ead3152beaf6f5903b9b7e..6abcb4ea55d01ad4d5c447bce5729aab4f75a050 100644
--- a/chrome/common/x11_util.cc
+++ b/chrome/common/x11_util.cc
@@ -6,6 +6,8 @@
// ported from XCB since we can't use XCB on Ubuntu while its 32-bit support
// remains woefully incomplete.
+#include "base/message_loop.h"
+#include "base/message_pump_libevent.h"
#include "base/thread.h"
#include "chrome/common/x11_util.h"
#include "chrome/common/x11_util_internal.h"
@@ -228,12 +230,55 @@ void FreePixmap(Display* display, XID pixmap) {
XFreePixmap(display, pixmap);
}
+// This class gets callbacks when the X file descriptor is ready for reading.
+class XEventHandler : public base::MessagePumpLibevent::Watcher {
+ public:
+ XEventHandler(Display* display, int x_fd)
+ : display_(display),
+ x_fd_(x_fd) {
+ }
+
+ void OnFileCanReadWithoutBlocking(int fd) {
+ DCHECK_EQ(fd, x_fd_);
+
+ while (true) {
+ XEvent event;
+ if (!XCheckMaskEvent(
+ display_, 0x8fffffff /* all ones, but still positive in 32-bits */,
+ &event)) {
+ return;
+ }
+
+ LOG(INFO) << "Got X event";
+ }
+ }
+
+ void OnFileCanWriteWithoutBlocking(int fd) {
+ CHECK(false);
+ }
+
+ private:
+ Display* const display_;
+ const int x_fd_;
+};
+
// Called on BACKGROUND_X11 thread.
Display* GetSecondaryDisplay() {
static Display* display = NULL;
+ static base::MessagePumpLibevent::FileDescriptorWatcher* watcher = NULL;
+ static XEventHandler* x_event_handler = NULL;
+
if (!display) {
display = XOpenDisplay(NULL);
CHECK(display);
+
+ watcher = new base::MessagePumpLibevent::FileDescriptorWatcher;
+ const int x_fd = XConnectionNumber(display);
+ x_event_handler = new XEventHandler(display, x_fd);
+
+ MessageLoopForIO::current()->WatchFileDescriptor(
+ x_fd, true, MessageLoopForIO::WATCH_READ, watcher,
+ x_event_handler);
}
return display;
« no previous file with comments | « chrome/browser/renderer_host/resource_message_filter_gtk.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698