gtk: Allow building both the X11 and Gtk message-pumps for gtk.
This patch allows both the X11 and the Gtk message-pumps to be built
in a linux-gtk build. A subsequent patch will use the X11 message-pump
for the GPU process, while continue to use the Gtk message-pump for the
browser process.
BUG=145600
R=ccameron@chromium.org, oshima@chromium.org, piman@chromium.org, thakis@chromium.org
Review URL: https://codereview.chromium.org/23880006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@221873 0039d316-1c4b-4281-b951-d872f2087c98
CrOS-Libchrome-Original-Commit: bb99d70f77e537ffc7ec0921d90c13e3cf689615
diff --git a/base/base.gyp b/base/base.gyp
index 2272d56..94bb2f3 100644
--- a/base/base.gyp
+++ b/base/base.gyp
@@ -257,12 +257,12 @@
'message_loop/message_pump_io_ios.cc',
'message_loop/message_pump_io_ios.h',
'message_loop/message_pump_observer.h',
- 'message_loop/message_pump_aurax11.cc',
- 'message_loop/message_pump_aurax11.h',
'message_loop/message_pump_libevent.cc',
'message_loop/message_pump_libevent.h',
'message_loop/message_pump_mac.h',
'message_loop/message_pump_mac.mm',
+ 'message_loop/message_pump_x11.cc',
+ 'message_loop/message_pump_x11.h',
'metrics/field_trial.cc',
'metrics/field_trial.h',
'posix/file_descriptor_shuffle.cc',
diff --git a/base/base.gypi b/base/base.gypi
index d34b39d..1a0b719 100644
--- a/base/base.gypi
+++ b/base/base.gypi
@@ -690,7 +690,7 @@
'sources!': [
'atomicops_internals_x86_gcc.cc',
'message_loop/message_pump_glib.cc',
- 'message_loop/message_pump_aurax11.cc',
+ 'message_loop/message_pump_x11.cc',
],
}],
['<(toolkit_uses_gtk)==0 or >(nacl_untrusted_build)==1', {
@@ -856,7 +856,7 @@
['<(use_ozone) == 1', {
'sources!': [
'message_loop/message_pump_glib.cc',
- 'message_loop/message_pump_aurax11.cc',
+ 'message_loop/message_pump_x11.cc',
]
}],
['OS == "linux" and >(nacl_untrusted_build)==0', {
diff --git a/base/message_loop/message_loop.h b/base/message_loop/message_loop.h
index de602af..bdad1b2 100644
--- a/base/message_loop/message_loop.h
+++ b/base/message_loop/message_loop.h
@@ -36,7 +36,7 @@
#if !defined(OS_MACOSX) && !defined(OS_ANDROID)
#if defined(USE_AURA) && defined(USE_X11) && !defined(OS_NACL)
-#include "base/message_loop/message_pump_aurax11.h"
+#include "base/message_loop/message_pump_x11.h"
#elif defined(USE_OZONE) && !defined(OS_NACL)
#include "base/message_loop/message_pump_ozone.h"
#else
@@ -600,7 +600,7 @@
protected:
#if defined(USE_AURA) && defined(USE_X11) && !defined(OS_NACL)
- friend class MessagePumpAuraX11;
+ friend class MessagePumpX11;
#endif
#if defined(USE_OZONE) && !defined(OS_NACL)
friend class MessagePumpOzone;
diff --git a/base/message_loop/message_pump_observer.h b/base/message_loop/message_pump_observer.h
index cb46fa3..333a75f 100644
--- a/base/message_loop/message_pump_observer.h
+++ b/base/message_loop/message_pump_observer.h
@@ -19,11 +19,11 @@
// A MessagePumpObserver is an object that receives global
// notifications from the UI MessageLoop with MessagePumpWin or
-// MessagePumpAuraX11.
+// MessagePumpX11.
//
// NOTE: An Observer implementation should be extremely fast!
//
-// For use with MessagePumpAuraX11, please see message_pump_glib.h for more
+// For use with MessagePumpX11, please see message_pump_glib.h for more
// info about how this is invoked in this environment.
class BASE_EXPORT MessagePumpObserver {
public:
diff --git a/base/message_loop/message_pump_aurax11.cc b/base/message_loop/message_pump_x11.cc
similarity index 81%
rename from base/message_loop/message_pump_aurax11.cc
rename to base/message_loop/message_pump_x11.cc
index 54be49f..7e780b2 100644
--- a/base/message_loop/message_pump_aurax11.cc
+++ b/base/message_loop/message_pump_x11.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "base/message_loop/message_pump_aurax11.h"
+#include "base/message_loop/message_pump_x11.h"
#include <glib.h>
#include <X11/X.h>
@@ -17,7 +17,7 @@
namespace {
gboolean XSourcePrepare(GSource* source, gint* timeout_ms) {
- if (XPending(MessagePumpAuraX11::GetDefaultXDisplay()))
+ if (XPending(MessagePumpX11::GetDefaultXDisplay()))
*timeout_ms = 0;
else
*timeout_ms = -1;
@@ -25,13 +25,13 @@
}
gboolean XSourceCheck(GSource* source) {
- return XPending(MessagePumpAuraX11::GetDefaultXDisplay());
+ return XPending(MessagePumpX11::GetDefaultXDisplay());
}
gboolean XSourceDispatch(GSource* source,
GSourceFunc unused_func,
gpointer data) {
- MessagePumpAuraX11* pump = static_cast<MessagePumpAuraX11*>(data);
+ MessagePumpX11* pump = static_cast<MessagePumpX11*>(data);
return pump->DispatchXEvents();
}
@@ -43,18 +43,18 @@
};
// The connection is essentially a global that's accessed through a static
-// method and destroyed whenever ~MessagePumpAuraX11() is called. We do this
+// method and destroyed whenever ~MessagePumpX11() is called. We do this
// for historical reasons so user code can call
// MessagePumpForUI::GetDefaultXDisplay() where MessagePumpForUI is a typedef
// to whatever type in the current build.
//
// TODO(erg): This can be changed to something more sane like
-// MessagePumpAuraX11::Current()->display() once MessagePumpGtk goes away.
+// MessagePumpX11::Current()->display() once MessagePumpGtk goes away.
Display* g_xdisplay = NULL;
int g_xinput_opcode = -1;
bool InitializeXInput2Internal() {
- Display* display = MessagePumpAuraX11::GetDefaultXDisplay();
+ Display* display = MessagePumpX11::GetDefaultXDisplay();
if (!display)
return false;
@@ -103,7 +103,7 @@
}
bool InitializeXkb() {
- Display* display = MessagePumpAuraX11::GetDefaultXDisplay();
+ Display* display = MessagePumpX11::GetDefaultXDisplay();
if (!display)
return false;
@@ -128,7 +128,7 @@
} // namespace
-MessagePumpAuraX11::MessagePumpAuraX11() : MessagePumpGlib(),
+MessagePumpX11::MessagePumpX11() : MessagePumpGlib(),
x_source_(NULL) {
InitializeXInput2();
InitializeXkb();
@@ -139,7 +139,7 @@
x_root_window_ = DefaultRootWindow(g_xdisplay);
}
-MessagePumpAuraX11::~MessagePumpAuraX11() {
+MessagePumpX11::~MessagePumpX11() {
g_source_destroy(x_source_);
g_source_unref(x_source_);
XCloseDisplay(g_xdisplay);
@@ -147,52 +147,54 @@
}
// static
-Display* MessagePumpAuraX11::GetDefaultXDisplay() {
+Display* MessagePumpX11::GetDefaultXDisplay() {
if (!g_xdisplay)
g_xdisplay = XOpenDisplay(NULL);
return g_xdisplay;
}
// static
-bool MessagePumpAuraX11::HasXInput2() {
+bool MessagePumpX11::HasXInput2() {
return InitializeXInput2();
}
+#if !defined(TOOLKIT_GTK)
// static
-MessagePumpAuraX11* MessagePumpAuraX11::Current() {
+MessagePumpX11* MessagePumpX11::Current() {
MessageLoopForUI* loop = MessageLoopForUI::current();
- return static_cast<MessagePumpAuraX11*>(loop->pump_ui());
+ return static_cast<MessagePumpX11*>(loop->pump_ui());
}
+#endif
-void MessagePumpAuraX11::AddDispatcherForWindow(
+void MessagePumpX11::AddDispatcherForWindow(
MessagePumpDispatcher* dispatcher,
unsigned long xid) {
dispatchers_.insert(std::make_pair(xid, dispatcher));
}
-void MessagePumpAuraX11::RemoveDispatcherForWindow(unsigned long xid) {
+void MessagePumpX11::RemoveDispatcherForWindow(unsigned long xid) {
dispatchers_.erase(xid);
}
-void MessagePumpAuraX11::AddDispatcherForRootWindow(
+void MessagePumpX11::AddDispatcherForRootWindow(
MessagePumpDispatcher* dispatcher) {
root_window_dispatchers_.AddObserver(dispatcher);
}
-void MessagePumpAuraX11::RemoveDispatcherForRootWindow(
+void MessagePumpX11::RemoveDispatcherForRootWindow(
MessagePumpDispatcher* dispatcher) {
root_window_dispatchers_.RemoveObserver(dispatcher);
}
-void MessagePumpAuraX11::AddObserver(MessagePumpObserver* observer) {
+void MessagePumpX11::AddObserver(MessagePumpObserver* observer) {
observers_.AddObserver(observer);
}
-void MessagePumpAuraX11::RemoveObserver(MessagePumpObserver* observer) {
+void MessagePumpX11::RemoveObserver(MessagePumpObserver* observer) {
observers_.RemoveObserver(observer);
}
-bool MessagePumpAuraX11::DispatchXEvents() {
+bool MessagePumpX11::DispatchXEvents() {
Display* display = GetDefaultXDisplay();
DCHECK(display);
MessagePumpDispatcher* dispatcher =
@@ -209,7 +211,7 @@
return TRUE;
}
-void MessagePumpAuraX11::BlockUntilWindowMapped(unsigned long xid) {
+void MessagePumpX11::BlockUntilWindowMapped(unsigned long xid) {
XEvent event;
Display* display = GetDefaultXDisplay();
@@ -226,7 +228,7 @@
} while (event.type != MapNotify);
}
-void MessagePumpAuraX11::InitXSource() {
+void MessagePumpX11::InitXSource() {
// CHECKs are to help track down crbug.com/113106.
CHECK(!x_source_);
Display* display = GetDefaultXDisplay();
@@ -243,7 +245,7 @@
g_source_attach(x_source_, g_main_context_default());
}
-bool MessagePumpAuraX11::ProcessXEvent(MessagePumpDispatcher* dispatcher,
+bool MessagePumpX11::ProcessXEvent(MessagePumpDispatcher* dispatcher,
XEvent* xev) {
bool should_quit = false;
@@ -268,7 +270,7 @@
return should_quit;
}
-bool MessagePumpAuraX11::WillProcessXEvent(XEvent* xevent) {
+bool MessagePumpX11::WillProcessXEvent(XEvent* xevent) {
if (!observers().might_have_observers())
return false;
ObserverListBase<MessagePumpObserver>::Iterator it(observers());
@@ -280,18 +282,18 @@
return false;
}
-void MessagePumpAuraX11::DidProcessXEvent(XEvent* xevent) {
+void MessagePumpX11::DidProcessXEvent(XEvent* xevent) {
FOR_EACH_OBSERVER(MessagePumpObserver, observers(), DidProcessEvent(xevent));
}
-MessagePumpDispatcher* MessagePumpAuraX11::GetDispatcherForXEvent(
+MessagePumpDispatcher* MessagePumpX11::GetDispatcherForXEvent(
const NativeEvent& xev) const {
::Window x_window = FindEventTarget(xev);
DispatchersMap::const_iterator it = dispatchers_.find(x_window);
return it != dispatchers_.end() ? it->second : NULL;
}
-bool MessagePumpAuraX11::Dispatch(const NativeEvent& xev) {
+bool MessagePumpX11::Dispatch(const NativeEvent& xev) {
// MappingNotify events (meaning that the keyboard or pointer buttons have
// been remapped) aren't associated with a window; send them to all
// dispatchers.
diff --git a/base/message_loop/message_pump_aurax11.h b/base/message_loop/message_pump_x11.h
similarity index 89%
rename from base/message_loop/message_pump_aurax11.h
rename to base/message_loop/message_pump_x11.h
index 52647c3..6f2c609 100644
--- a/base/message_loop/message_pump_aurax11.h
+++ b/base/message_loop/message_pump_x11.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef BASE_MESSAGE_LOOP_MESSAGE_PUMP_AURAX11_H
-#define BASE_MESSAGE_LOOP_MESSAGE_PUMP_AURAX11_H
+#ifndef BASE_MESSAGE_LOOP_MESSAGE_PUMP_X11_H
+#define BASE_MESSAGE_LOOP_MESSAGE_PUMP_X11_H
#include <bitset>
#include <map>
@@ -31,11 +31,11 @@
// If there's a current dispatcher given through RunWithDispatcher(), that
// dispatcher receives events. Otherwise, we route to messages to dispatchers
// who have subscribed to messages from a specific X11 window.
-class BASE_EXPORT MessagePumpAuraX11 : public MessagePumpGlib,
- public MessagePumpDispatcher {
+class BASE_EXPORT MessagePumpX11 : public MessagePumpGlib,
+ public MessagePumpDispatcher {
public:
- MessagePumpAuraX11();
- virtual ~MessagePumpAuraX11();
+ MessagePumpX11();
+ virtual ~MessagePumpX11();
// Returns default X Display.
static Display* GetDefaultXDisplay();
@@ -43,8 +43,10 @@
// Returns true if the system supports XINPUT2.
static bool HasXInput2();
+#if !defined(TOOLKIT_GTK)
// Returns the UI message pump.
- static MessagePumpAuraX11* Current();
+ static MessagePumpX11* Current();
+#endif
// Adds/Removes |dispatcher| for the |xid|. This will route all messages from
// the window |xid| to |dispatcher.
@@ -122,11 +124,13 @@
unsigned long x_root_window_;
- DISALLOW_COPY_AND_ASSIGN(MessagePumpAuraX11);
+ DISALLOW_COPY_AND_ASSIGN(MessagePumpX11);
};
-typedef MessagePumpAuraX11 MessagePumpForUI;
+#if !defined(TOOLKIT_GTK)
+typedef MessagePumpX11 MessagePumpForUI;
+#endif
} // namespace base
-#endif // BASE_MESSAGE_LOOP_MESSAGE_PUMP_AURAX11_H
+#endif // BASE_MESSAGE_LOOP_MESSAGE_PUMP_X11_H