summaryrefslogtreecommitdiffstats
path: root/base
diff options
context:
space:
mode:
authorsky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-20 20:56:51 +0000
committersky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-20 20:56:51 +0000
commit8d415017601515d178cdae3a26704196072fa4b5 (patch)
tree40fdd11e2d8ca302b6890553be54f71eb23b5c82 /base
parent8e50de7369c44f135a94e779f7b9ff3857a04243 (diff)
downloadchromium_src-8d415017601515d178cdae3a26704196072fa4b5.zip
chromium_src-8d415017601515d178cdae3a26704196072fa4b5.tar.gz
chromium_src-8d415017601515d178cdae3a26704196072fa4b5.tar.bz2
Revert 102005 - aura: Explicitly disable GTK.
Explicitly disable GTK by setting TOOLKIT_USES_GTK. This is the first in a series of changes required to have chrome on aura build and link without GTK. This CL makes base/ build without GTK. Subsequent CLs will do this for other components. BUG=97131 TEST=none Review URL: http://codereview.chromium.org/7904034 TBR=sadrul@chromium.org Review URL: http://codereview.chromium.org/7978007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@102015 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base')
-rw-r--r--base/base.gyp19
-rw-r--r--base/base.gypi23
-rw-r--r--base/message_loop.cc2
-rw-r--r--base/message_pump_glib_unittest.cc19
-rw-r--r--base/message_pump_x.cc92
-rw-r--r--base/message_pump_x.h43
6 files changed, 63 insertions, 135 deletions
diff --git a/base/base.gyp b/base/base.gyp
index a4755e3..8bca61bee 100644
--- a/base/base.gyp
+++ b/base/base.gyp
@@ -144,7 +144,7 @@
'i18n/icu_string_conversions_unittest.cc',
'i18n/number_formatting_unittest.cc',
'i18n/rtl_unittest.cc',
- 'i18n/string_search_unittest.cc',
+ 'i18n/string_search_unittest.cc',
'i18n/time_formatting_unittest.cc',
'json/json_reader_unittest.cc',
'json/json_writer_unittest.cc',
@@ -257,10 +257,13 @@
'module_dir': 'base'
},
'conditions': [
- ['use_glib==1', {
+ ['toolkit_uses_gtk==1', {
'sources!': [
'file_version_info_unittest.cc',
],
+ 'sources': [
+ 'nix/xdg_util_unittest.cc',
+ ],
'conditions': [
[ 'linux_use_tcmalloc==1', {
'dependencies': [
@@ -275,21 +278,13 @@
'-fno-strict-aliasing',
],
}],
- [ 'toolkit_uses_gtk==1', {
- 'sources': [
- 'nix/xdg_util_unittest.cc',
- ],
- 'dependencies': [
- '../build/linux/system.gyp:gtk',
- ]
- }],
],
'dependencies': [
- '../build/linux/system.gyp:glib',
+ '../build/linux/system.gyp:gtk',
'../build/linux/system.gyp:ssl',
'../tools/xdisplaycheck/xdisplaycheck.gyp:xdisplaycheck',
],
- }, { # use_glib!=1
+ }, { # toolkit_uses_gtk!=1
'sources!': [
'message_pump_glib_unittest.cc',
]
diff --git a/base/base.gypi b/base/base.gypi
index 0de2c24..3c23109be 100644
--- a/base/base.gypi
+++ b/base/base.gypi
@@ -381,24 +381,21 @@
'message_pump_x.cc',
],
}],
- [ 'use_glib==0', {
+ [ 'toolkit_uses_gtk==0', {
'sources/': [
['exclude', '^nix/'],
],
'sources!': [
'atomicops_internals_x86_gcc.cc',
'message_pump_glib.cc',
+ 'message_pump_gtk.cc',
'message_pump_x.cc',
],
}],
- [ 'toolkit_uses_gtk==0', {
- 'sources!': [ 'message_pump_gtk.cc', ],
- }],
[ 'touchui==0 and use_aura==0', {
'sources!' : [ 'message_pump_x.cc', ],
}, {
'sources!' : [ 'message_pump_gtk.cc', ],
- 'sources' : [ 'message_pump_x.cc', ],
}],
[ 'OS != "linux"', {
'sources!': [
@@ -477,7 +474,7 @@
],
},
'conditions': [
- [ 'use_glib==1', {
+ [ 'toolkit_uses_gtk==1', {
'conditions': [
[ 'chromeos==1', {
'sources/': [ ['include', '_chromeos\\.cc$'] ]
@@ -494,19 +491,11 @@
},
},
],
- [ 'toolkit_uses_gtk==1', {
- 'dependencies': [
- '../build/linux/system.gyp:gtk',
- ],
- 'export_dependent_settings': [
- '../build/linux/system.gyp:gtk',
- ],
- }],
],
'dependencies': [
'symbolize',
'../build/util/build_util.gyp:lastchange#target',
- '../build/linux/system.gyp:glib',
+ '../build/linux/system.gyp:gtk',
'../build/linux/system.gyp:x11',
'xdg_mime',
],
@@ -517,10 +506,10 @@
'-Wno-write-strings',
],
'export_dependent_settings': [
- '../build/linux/system.gyp:glib',
+ '../build/linux/system.gyp:gtk',
'../build/linux/system.gyp:x11',
],
- }, { # use_glib!=1
+ }, { # toolkit_uses_gtk!=1
'sources/': [
['exclude', '/xdg_user_dirs/'],
['exclude', '_nss\.cc$'],
diff --git a/base/message_loop.cc b/base/message_loop.cc
index d96b57d..4a206e9 100644
--- a/base/message_loop.cc
+++ b/base/message_loop.cc
@@ -29,7 +29,7 @@
#if defined(OS_ANDROID)
#include "base/message_pump_android.h"
#endif
-#if defined(TOOLKIT_USES_GTK)
+#if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_ANDROID)
#include <gdk/gdk.h>
#include <gdk/gdkx.h>
#endif // defined(OS_POSIX) && !defined(OS_MACOSX)
diff --git a/base/message_pump_glib_unittest.cc b/base/message_pump_glib_unittest.cc
index 69fbb95..496fda6 100644
--- a/base/message_pump_glib_unittest.cc
+++ b/base/message_pump_glib_unittest.cc
@@ -4,6 +4,7 @@
#include "base/message_pump_glib.h"
+#include <gtk/gtk.h>
#include <math.h>
#include <algorithm>
@@ -14,10 +15,6 @@
#include "base/threading/thread.h"
#include "testing/gtest/include/gtest/gtest.h"
-#if defined(TOOLKIT_USES_GTK)
-#include <gtk/gtk.h>
-#endif
-
namespace {
// This class injects dummy "events" into the GLib loop. When "handled" these
@@ -398,7 +395,6 @@ TEST_F(MessagePumpGLibTest, TestDrainingGLib) {
namespace {
-#if defined(TOOLKIT_USES_GTK)
void AddEventsAndDrainGtk(EventInjector* injector) {
// Add a couple of dummy events
injector->AddEvent(0, NULL);
@@ -415,11 +411,9 @@ void AddEventsAndDrainGtk(EventInjector* injector) {
gtk_main_iteration();
}
}
-#endif
} // namespace
-#if defined(TOOLKIT_USES_GTK)
TEST_F(MessagePumpGLibTest, TestDrainingGtk) {
// Tests that draining events using Gtk works.
loop()->PostTask(
@@ -428,7 +422,6 @@ TEST_F(MessagePumpGLibTest, TestDrainingGtk) {
EXPECT_EQ(3, injector()->processed_events());
}
-#endif
namespace {
@@ -443,16 +436,10 @@ class GLibLoopRunner : public base::RefCounted<GLibLoopRunner> {
}
}
- void RunLoop() {
-#if defined(TOOLKIT_USES_GTK)
+ void RunGtk() {
while (!quit_) {
gtk_main_iteration();
}
-#else
- while (!quit_) {
- g_main_context_iteration(NULL, TRUE);
- }
-#endif
}
void Quit() {
@@ -526,7 +513,7 @@ void TestGtkLoopInternal(EventInjector* injector) {
FROM_HERE, NewRunnableMethod(runner.get(), &GLibLoopRunner::Quit), 40);
// Run a nested, straight Gtk message loop.
- runner->RunLoop();
+ runner->RunGtk();
ASSERT_EQ(3, task_count);
EXPECT_EQ(4, injector->processed_events());
diff --git a/base/message_pump_x.cc b/base/message_pump_x.cc
index b0be50b..8e098af 100644
--- a/base/message_pump_x.cc
+++ b/base/message_pump_x.cc
@@ -4,15 +4,12 @@
#include "base/message_pump_x.h"
+#include <gdk/gdkx.h>
#include <X11/extensions/XInput2.h>
#include "base/basictypes.h"
#include "base/message_loop.h"
-#if defined(TOOLKIT_USES_GTK)
-#include <gdk/gdkx.h>
-#endif
-
namespace {
gboolean XSourcePrepare(GSource* source, gint* timeout_ms) {
@@ -43,6 +40,10 @@ GSourceFuncs XSourceFuncs = {
NULL
};
+// A flag to disable GTK's message pump. This is intermediate step
+// to remove gtk and will be removed once migration is complete.
+bool use_gtk_message_pump = true;
+
// The opcode used for checking events.
int xiopcode = -1;
@@ -50,17 +51,11 @@ int xiopcode = -1;
// connection to the display and owns it.
Display* g_xdisplay = NULL;
-#if defined(TOOLKIT_USES_GTK)
-// A flag to disable GTK's message pump. This is intermediate step
-// to remove gtk and will be removed once migration is complete.
-bool use_gtk_message_pump = true;
-
gboolean PlaceholderDispatch(GSource* source,
GSourceFunc cb,
gpointer data) {
return TRUE;
}
-#endif // defined(TOOLKIT_USES_GTK)
void InitializeXInput2(void) {
Display* display = base::MessagePumpX::GetDefaultXDisplay();
@@ -88,62 +83,57 @@ void InitializeXInput2(void) {
namespace base {
MessagePumpX::MessagePumpX() : MessagePumpGlib(),
-#if defined(TOOLKIT_USES_GTK)
+ x_source_(NULL),
gdksource_(NULL),
dispatching_event_(false),
capture_x_events_(0),
- capture_gdk_events_(0),
-#endif
- x_source_(NULL) {
- InitializeXInput2();
-#if defined(TOOLKIT_USES_GTK)
+ capture_gdk_events_(0) {
if (use_gtk_message_pump) {
gdk_window_add_filter(NULL, &GdkEventFilter, this);
gdk_event_handler_set(&EventDispatcherX, this, NULL);
} else {
- InitXSource();
+ GPollFD* x_poll = new GPollFD();
+ x_poll->fd = ConnectionNumber(g_xdisplay);
+ x_poll->events = G_IO_IN;
+
+ x_source_ = g_source_new(&XSourceFuncs, sizeof(GSource));
+ g_source_add_poll(x_source_, x_poll);
+ g_source_set_can_recurse(x_source_, FALSE);
+ g_source_attach(x_source_, g_main_context_default());
}
+
+ InitializeXInput2();
if (use_gtk_message_pump)
InitializeEventsToCapture();
-#else
- InitXSource();
-#endif
}
MessagePumpX::~MessagePumpX() {
-#if defined(TOOLKIT_USES_GTK)
if (use_gtk_message_pump) {
gdk_window_remove_filter(NULL, &GdkEventFilter, this);
gdk_event_handler_set(reinterpret_cast<GdkEventFunc>(gtk_main_do_event),
this, NULL);
- return;
+ } else {
+ g_source_destroy(x_source_);
+ g_source_unref(x_source_);
+ XCloseDisplay(g_xdisplay);
+ g_xdisplay = NULL;
}
-#endif
-
- g_source_destroy(x_source_);
- g_source_unref(x_source_);
- XCloseDisplay(g_xdisplay);
- g_xdisplay = NULL;
}
-#if defined(TOOLKIT_USES_GTK)
// static
void MessagePumpX::DisableGtkMessagePump() {
use_gtk_message_pump = false;
+ g_xdisplay = XOpenDisplay(NULL);
}
-#endif
// static
Display* MessagePumpX::GetDefaultXDisplay() {
-#if defined(TOOLKIT_USES_GTK)
if (use_gtk_message_pump) {
static GdkDisplay* display = gdk_display_get_default();
return display ? GDK_DISPLAY_XDISPLAY(display) : NULL;
+ } else {
+ return g_xdisplay;
}
-#endif
- if (!g_xdisplay)
- g_xdisplay = XOpenDisplay(NULL);
- return g_xdisplay;
}
// static
@@ -151,24 +141,9 @@ bool MessagePumpX::HasXInput2() {
return xiopcode != -1;
}
-void MessagePumpX::InitXSource() {
- DCHECK(!x_source_);
- GPollFD* x_poll = new GPollFD();
- x_poll->fd = ConnectionNumber(g_xdisplay);
- x_poll->events = G_IO_IN;
-
- x_source_ = g_source_new(&XSourceFuncs, sizeof(GSource));
- g_source_add_poll(x_source_, x_poll);
- g_source_set_can_recurse(x_source_, FALSE);
- g_source_attach(x_source_, g_main_context_default());
-}
-
bool MessagePumpX::ShouldCaptureXEvent(XEvent* xev) {
- return
-#if defined(TOOLKIT_USES_GTK)
- (!use_gtk_message_pump || capture_x_events_[xev->type]) &&
-#endif
- (xev->type != GenericEvent || xev->xcookie.extension == xiopcode);
+ return (!use_gtk_message_pump || capture_x_events_[xev->type])
+ && (xev->type != GenericEvent || xev->xcookie.extension == xiopcode);
}
bool MessagePumpX::ProcessXEvent(XEvent* xev) {
@@ -212,19 +187,16 @@ bool MessagePumpX::RunOnce(GMainContext* context, bool block) {
XNextEvent(display, &xev);
if (ProcessXEvent(&xev))
return true;
-#if defined(TOOLKIT_USES_GTK)
} else if (use_gtk_message_pump && gdksource_) {
// TODO(sad): A couple of extra events can still sneak in during this.
// Those should be sent back to the X queue from the dispatcher
// EventDispatcherX.
gdksource_->source_funcs->dispatch = gdkdispatcher_;
g_main_context_iteration(context, FALSE);
-#endif
}
}
bool retvalue;
-#if defined(TOOLKIT_USES_GTK)
if (gdksource_ && use_gtk_message_pump) {
// Replace the dispatch callback of the GDK event source temporarily so that
// it doesn't read events from X.
@@ -240,14 +212,10 @@ bool MessagePumpX::RunOnce(GMainContext* context, bool block) {
} else {
retvalue = g_main_context_iteration(context, block);
}
-#else
- retvalue = g_main_context_iteration(context, block);
-#endif
return retvalue;
}
-#if defined(TOOLKIT_USES_GTK)
GdkFilterReturn MessagePumpX::GdkEventFilter(GdkXEvent* gxevent,
GdkEvent* gevent,
gpointer data) {
@@ -311,13 +279,11 @@ void MessagePumpX::InitializeEventsToCapture(void) {
capture_x_events_[GenericEvent] = true;
}
-COMPILE_ASSERT(XLASTEvent >= LASTEvent, XLASTEvent_too_small);
-
-#endif // defined(TOOLKIT_USES_GTK)
-
MessagePumpObserver::EventStatus
MessagePumpObserver::WillProcessXEvent(XEvent* xev) {
return EVENT_CONTINUE;
}
+COMPILE_ASSERT(XLASTEvent >= LASTEvent, XLASTEvent_too_small);
+
} // namespace base
diff --git a/base/message_pump_x.h b/base/message_pump_x.h
index eab6f6b..c13f323 100644
--- a/base/message_pump_x.h
+++ b/base/message_pump_x.h
@@ -11,10 +11,7 @@
#include <bitset>
#include <glib.h>
-
-#if defined(TOOLKIT_USES_GTK)
#include <gtk/gtk.h>
-#endif
typedef union _XEvent XEvent;
typedef struct _XDisplay Display;
@@ -67,14 +64,16 @@ class BASE_EXPORT MessagePumpX : public MessagePumpGlib {
MessagePumpX();
virtual ~MessagePumpX();
+ // Indicates whether a GDK event was injected by chrome (when |true|) or if it
+ // was captured and being processed by GDK (when |false|).
+ bool IsDispatchingEvent(void) { return dispatching_event_; }
+
// Overridden from MessagePumpGlib:
virtual bool RunOnce(GMainContext* context, bool block) OVERRIDE;
-#if defined(TOOLKIT_USES_GTK)
// Disables Gtk/Gdk event pumping. This will be used when
// NativeWidgetX is enabled.
static void DisableGtkMessagePump();
-#endif
// Returns default X Display.
static Display* GetDefaultXDisplay();
@@ -83,8 +82,15 @@ class BASE_EXPORT MessagePumpX : public MessagePumpGlib {
static bool HasXInput2();
private:
- // Initializes the glib event source for X.
- void InitXSource();
+ // Some XEvent's can't be directly read from X event queue and will go
+ // through GDK's dispatching process and may get discarded. This function
+ // sets up a filter to intercept those XEvent's we are interested in
+ // and dispatches them so that they won't get lost.
+ static GdkFilterReturn GdkEventFilter(GdkXEvent* gxevent,
+ GdkEvent* gevent,
+ gpointer data);
+
+ static void EventDispatcherX(GdkEvent* event, gpointer data);
// Decides whether we are interested in processing this XEvent.
bool ShouldCaptureXEvent(XEvent* event);
@@ -97,25 +103,15 @@ class BASE_EXPORT MessagePumpX : public MessagePumpGlib {
// not send the event to any other observers and returns true. Returns false
// if no observer returns true.
bool WillProcessXEvent(XEvent* xevent);
-#if defined(TOOLKIT_USES_GTK)
- // Some XEvent's can't be directly read from X event queue and will go
- // through GDK's dispatching process and may get discarded. This function
- // sets up a filter to intercept those XEvent's we are interested in
- // and dispatches them so that they won't get lost.
- static GdkFilterReturn GdkEventFilter(GdkXEvent* gxevent,
- GdkEvent* gevent,
- gpointer data);
-
- static void EventDispatcherX(GdkEvent* event, gpointer data);
-
- // Indicates whether a GDK event was injected by chrome (when |true|) or if it
- // was captured and being processed by GDK (when |false|).
- bool IsDispatchingEvent(void) { return dispatching_event_; }
// Update the lookup table and flag the events that should be captured and
// processed so that GDK doesn't get to them.
void InitializeEventsToCapture(void);
+ // The event source for X events (used only when GTK event processing is
+ // disabled).
+ GSource* x_source_;
+
// The event source for GDK events.
GSource* gdksource_;
@@ -144,11 +140,6 @@ class BASE_EXPORT MessagePumpX : public MessagePumpGlib {
// it should be passed on to the default GDK handler.
std::bitset<XLASTEvent> capture_x_events_;
std::bitset<GDK_EVENT_LAST> capture_gdk_events_;
-#endif // defined(TOOLKIT_USES_GTK)
-
- // The event source for X events (used only when GTK event processing is
- // disabled).
- GSource* x_source_;
DISALLOW_COPY_AND_ASSIGN(MessagePumpX);
};