diff options
author | leandrogracia@chromium.org <leandrogracia@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-07-22 15:24:04 +0000 |
---|---|---|
committer | leandrogracia@chromium.org <leandrogracia@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-07-22 15:24:04 +0000 |
commit | bdab20fe8a247e0a3d825507ba4849331c26dfdc (patch) | |
tree | bca0a220edd9ac95ef666e4148144d71064c6b7e /base | |
parent | 6490abc1d558d262e1a4ab2125967a5afd0eb430 (diff) | |
download | chromium_src-bdab20fe8a247e0a3d825507ba4849331c26dfdc.zip chromium_src-bdab20fe8a247e0a3d825507ba4849331c26dfdc.tar.gz chromium_src-bdab20fe8a247e0a3d825507ba4849331c26dfdc.tar.bz2 |
Revert 93629 - Linux build failure: http://build.chromium.org/p/chromium/builders/Linux%20Builder%20%28dbg%29%28shared%29/builds/4098/steps/compile/logs/stdio#error1
Consolidate access to X Display
Change ui::GetXDisplay to use the MessagePumpForUI class
to get Display. This allows us to have two different
implementation for x and gtk.
Remove MessageLoop::GetDisplay from message loop API.
Client should use ui::GetXDisplay instead. This
will also be removed in near future, and client should get
display from window it is dealing with.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/7484006
TBR=oshima@google.com
Review URL: http://codereview.chromium.org/7493014
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@93633 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base')
-rw-r--r-- | base/message_loop.cc | 9 | ||||
-rw-r--r-- | base/message_loop.h | 13 | ||||
-rw-r--r-- | base/message_pump_gtk.cc | 8 | ||||
-rw-r--r-- | base/message_pump_gtk.h | 4 | ||||
-rw-r--r-- | base/message_pump_x.cc | 11 | ||||
-rw-r--r-- | base/message_pump_x.h | 4 |
6 files changed, 25 insertions, 24 deletions
diff --git a/base/message_loop.cc b/base/message_loop.cc index 08985a4..7f1971c 100644 --- a/base/message_loop.cc +++ b/base/message_loop.cc @@ -819,6 +819,15 @@ void MessageLoopForUI::DidProcessMessage(const MSG& message) { } #endif // defined(OS_WIN) +#if defined(USE_X11) +Display* MessageLoopForUI::GetDisplay() { + GdkDisplay* display = gdk_display_get_default(); + if (!display) + return NULL; + return GDK_DISPLAY_XDISPLAY(display); +} +#endif // defined(USE_X11) + #if !defined(OS_MACOSX) && !defined(OS_NACL) void MessageLoopForUI::AddObserver(Observer* observer) { pump_ui()->AddObserver(observer); diff --git a/base/message_loop.h b/base/message_loop.h index 9d500d7..8fd9cbc 100644 --- a/base/message_loop.h +++ b/base/message_loop.h @@ -32,6 +32,7 @@ #else #include "base/message_pump_gtk.h" #endif +typedef struct _XDisplay Display; #endif #endif @@ -583,6 +584,18 @@ class BASE_API MessageLoopForUI : public MessageLoop { void DidProcessMessage(const MSG& message); #endif // defined(OS_WIN) +#if defined(USE_X11) + // Returns the Xlib Display that backs the MessagePump for this MessageLoop. + // + // This allows for raw access to the X11 server in situations where our + // abstractions do not provide enough power. + // + // Be careful how this is used. The MessagePump in general expects + // exclusive access to the Display. Calling things like XNextEvent() will + // likely break things in subtle, hard to detect, ways. + Display* GetDisplay(); +#endif // defined(OS_X11) + #if !defined(OS_MACOSX) // Please see message_pump_win/message_pump_glib for definitions of these // methods. diff --git a/base/message_pump_gtk.cc b/base/message_pump_gtk.cc index e1cb7f6..f5ed042 100644 --- a/base/message_pump_gtk.cc +++ b/base/message_pump_gtk.cc @@ -5,7 +5,6 @@ #include "base/message_pump_gtk.h" #include <gtk/gtk.h> -#include <gdk/gdkx.h> namespace base { @@ -30,12 +29,6 @@ void MessagePumpGtk::DispatchEvents(GdkEvent* event) { DidProcessEvent(event); } -// static -Display* MessagePumpGtk::GetDefaultXDisplay() { - static GdkDisplay* display = gdk_display_get_default(); - return display ? GDK_DISPLAY_XDISPLAY(display) : NULL; -} - bool MessagePumpGtk::RunOnce(GMainContext* context, bool block) { // g_main_context_iteration returns true if events have been dispatched. return g_main_context_iteration(context, block); @@ -56,3 +49,4 @@ void MessagePumpGtk::EventDispatcher(GdkEvent* event, gpointer data) { } } // namespace base + diff --git a/base/message_pump_gtk.h b/base/message_pump_gtk.h index 7e5cf04..72eaafa 100644 --- a/base/message_pump_gtk.h +++ b/base/message_pump_gtk.h @@ -9,7 +9,6 @@ #include "base/message_pump_glib.h" typedef union _GdkEvent GdkEvent; -typedef struct _XDisplay Display; namespace base { @@ -50,9 +49,6 @@ class MessagePumpGtk : public MessagePumpGlib { // some task before/after calling the default handler (EventDispatcher). void DispatchEvents(GdkEvent* event); - // Returns default X Display. - static Display* GetDefaultXDisplay(); - private: // Overridden from MessagePumpGlib virtual bool RunOnce(GMainContext* context, bool block) OVERRIDE; diff --git a/base/message_pump_x.cc b/base/message_pump_x.cc index 1174e4b..20c8b0e 100644 --- a/base/message_pump_x.cc +++ b/base/message_pump_x.cc @@ -51,13 +51,6 @@ void MessagePumpX::DisableGtkMessagePump() { use_gtk_message_pump = false; } -// static -Display* MessagePumpX::GetDefaultXDisplay() { - static GdkDisplay* display = gdk_display_get_default(); - return display ? GDK_DISPLAY_XDISPLAY(display) : NULL; -} - - bool MessagePumpX::ShouldCaptureXEvent(XEvent* xev) { return (!use_gtk_message_pump || capture_x_events_[xev->type]) && (xev->type != GenericEvent || xev->xcookie.extension == xiopcode_) @@ -93,7 +86,7 @@ bool MessagePumpX::ProcessXEvent(XEvent* xev) { } bool MessagePumpX::RunOnce(GMainContext* context, bool block) { - Display* display = GetDefaultXDisplay(); + Display* display = MessageLoopForUI::current()->GetDisplay(); if (!display || !GetDispatcher()) return g_main_context_iteration(context, block); @@ -199,7 +192,7 @@ void MessagePumpX::InitializeEventsToCapture(void) { } void MessagePumpX::InitializeXInput2(void) { - Display* display = GetDefaultXDisplay(); + Display* display = MessageLoopForUI::current()->GetDisplay(); if (!display) return; diff --git a/base/message_pump_x.h b/base/message_pump_x.h index 8ac9921..ecadc1f 100644 --- a/base/message_pump_x.h +++ b/base/message_pump_x.h @@ -14,7 +14,6 @@ #include <gtk/gtk.h> typedef union _XEvent XEvent; -typedef struct _XDisplay Display; namespace base { @@ -75,9 +74,6 @@ class MessagePumpX : public MessagePumpGlib { // NativeWidgetX is enabled. static void DisableGtkMessagePump(); - // Returns default X Display. - static Display* GetDefaultXDisplay(); - private: // 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 |