summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-04-14 21:13:20 +0000
committersadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-04-14 21:13:20 +0000
commitc8ef1d0bc63aa014ba0fb94049671b371c0d5d18 (patch)
treef3f7a66331dde62271d9f9aeac0618cb9a07946b
parent4b05a7bb244c80ffd75fd67cbb8d55f6735a5e04 (diff)
downloadchromium_src-c8ef1d0bc63aa014ba0fb94049671b371c0d5d18.zip
chromium_src-c8ef1d0bc63aa014ba0fb94049671b371c0d5d18.tar.gz
chromium_src-c8ef1d0bc63aa014ba0fb94049671b371c0d5d18.tar.bz2
x11: Remove X11 message-pump.
The remaining use of the X11 mesage-pump was opening the connection to the X11 server. This patch moves that out of the message-pump, into gfx. This allows us to remove the X11 message-pump, and just use the base Glib-based message-pump on Linux and ChromeOS. BUG=354062 R=darin@chromium.org, sky@chromium.org Review URL: https://codereview.chromium.org/235043005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@263726 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--ash/shell.cc2
-rw-r--r--ash/test/ash_test_base.cc4
-rw-r--r--ash/wm/ash_native_cursor_manager_interactive_uitest.cc4
-rw-r--r--base/BUILD.gn2
-rw-r--r--base/base.gyp2
-rw-r--r--base/base.gypi6
-rw-r--r--base/message_loop/message_loop.h23
-rw-r--r--base/message_loop/message_pump_glib.h2
-rw-r--r--base/message_loop/message_pump_x11.cc63
-rw-r--r--base/message_loop/message_pump_x11.h42
-rw-r--r--chrome/browser/ui/libgtk2ui/gtk2_event_loop.cc4
-rw-r--r--chrome/browser/ui/libgtk2ui/x11_input_method_context_impl_gtk2.cc4
-rw-r--r--content/browser/browser_main_loop.cc4
-rw-r--r--content/browser/power_save_blocker_x11.cc3
-rw-r--r--content/common/gpu/media/rendering_helper.cc8
-rw-r--r--content/content_tests.gypi1
-rw-r--r--gpu/config/gpu_info_collector_x11.cc3
-rw-r--r--ui/aura/aura.gyp14
-rw-r--r--ui/aura/bench/bench_main.cc7
-rw-r--r--ui/aura/demo/demo_main.cc8
-rw-r--r--ui/base/x/selection_requestor.cc2
-rw-r--r--ui/base/x/x11_util.cc4
-rw-r--r--ui/display/chromeos/x11/touchscreen_delegate_x11.cc4
-rw-r--r--ui/display/x11/DEPS3
-rw-r--r--ui/display/x11/edid_parser_x11.cc8
-rw-r--r--ui/events/x/events_x.cc1
-rw-r--r--ui/gfx/gfx.gyp2
-rw-r--r--ui/gfx/x/x11_connection.cc17
-rw-r--r--ui/gfx/x/x11_connection.h18
-rw-r--r--ui/gfx/x/x11_types.cc5
-rw-r--r--ui/gl/gl_image_glx.cc3
-rw-r--r--ui/gl/gl_surface_glx.cc19
-rw-r--r--ui/gl/gl_surface_x11.cc7
-rw-r--r--ui/views/examples/examples_main.cc11
-rw-r--r--ui/views/test/ui_controls_factory_desktop_aurax11.cc6
-rw-r--r--ui/views/widget/desktop_aura/desktop_screen_x11.cc4
-rw-r--r--ui/views/widget/desktop_aura/desktop_window_tree_host_x11.cc1
-rw-r--r--ui/views/widget/desktop_aura/x11_desktop_window_move_client.cc1
-rw-r--r--ui/views/widget/desktop_aura/x11_whole_screen_move_loop.cc1
39 files changed, 118 insertions, 205 deletions
diff --git a/ash/shell.cc b/ash/shell.cc
index 98f7346..6891419 100644
--- a/ash/shell.cc
+++ b/ash/shell.cc
@@ -114,7 +114,7 @@
#if defined(USE_X11)
#include "ash/accelerators/magnifier_key_scroller.h"
#include "ash/accelerators/spoken_feedback_toggler.h"
-#include "base/message_loop/message_pump_x11.h"
+#include "ui/gfx/x/x11_types.h"
#endif // defined(USE_X11)
#include "ash/ash_constants.h"
#include "ash/display/display_change_observer_chromeos.h"
diff --git a/ash/test/ash_test_base.cc b/ash/test/ash_test_base.cc
index 49f1d08..61fa218 100644
--- a/ash/test/ash_test_base.cc
+++ b/ash/test/ash_test_base.cc
@@ -49,7 +49,7 @@
#endif
#if defined(USE_X11)
-#include <X11/Xlib.h>
+#include "ui/gfx/x/x11_connection.h"
#endif
namespace ash {
@@ -98,7 +98,7 @@ AshTestBase::AshTestBase()
// This is needed for tests which use this base class but are run in browser
// test binaries so don't get the default initialization in the unit test
// suite.
- XInitThreads();
+ gfx::InitializeThreadedX11();
#endif
thread_bundle_.reset(new content::TestBrowserThreadBundle);
diff --git a/ash/wm/ash_native_cursor_manager_interactive_uitest.cc b/ash/wm/ash_native_cursor_manager_interactive_uitest.cc
index 5084e7c..5eee024 100644
--- a/ash/wm/ash_native_cursor_manager_interactive_uitest.cc
+++ b/ash/wm/ash_native_cursor_manager_interactive_uitest.cc
@@ -20,7 +20,7 @@
#if defined(USE_X11)
#include <X11/Xlib.h>
-#include "base/message_loop/message_pump_x11.h"
+#include "ui/gfx/x/x11_types.h"
#endif
namespace ash {
@@ -59,7 +59,7 @@ DisplayInfo CreateDisplayInfo(int64 id,
void MoveMouseSync(aura::Window* window, int x, int y) {
#if defined(USE_X11)
- XWarpPointer(base::MessagePumpX11::GetDefaultXDisplay(),
+ XWarpPointer(gfx::GetXDisplay(),
None,
window->GetHost()->GetAcceleratedWidget(),
0, 0, 0, 0,
diff --git a/base/BUILD.gn b/base/BUILD.gn
index 4da113c..feff58b 100644
--- a/base/BUILD.gn
+++ b/base/BUILD.gn
@@ -330,8 +330,6 @@ component("base") {
"message_loop/message_pump_observer.h",
"message_loop/message_pump_win.cc",
"message_loop/message_pump_win.h",
- "message_loop/message_pump_x11.cc",
- "message_loop/message_pump_x11.h",
"metrics/field_trial.cc",
"metrics/field_trial.h",
"metrics/sample_map.cc",
diff --git a/base/base.gyp b/base/base.gyp
index 1e9ae28..12d2a5f 100644
--- a/base/base.gyp
+++ b/base/base.gyp
@@ -245,8 +245,6 @@
'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 645ef66..92ecf6e 100644
--- a/base/base.gypi
+++ b/base/base.gypi
@@ -733,11 +733,6 @@
'message_loop/message_pump_glib.cc',
],
}],
- ['<(use_x11)==0 or >(nacl_untrusted_build)==1', {
- 'sources!': [
- 'message_loop/message_pump_x11.cc',
- ],
- }],
['<(toolkit_uses_gtk)==0 or >(nacl_untrusted_build)==1', {
'sources!': ['message_loop/message_pump_gtk.cc'],
}],
@@ -891,7 +886,6 @@
['<(use_ozone) == 1', {
'sources!': [
'message_loop/message_pump_glib.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 6539c65..07f9105 100644
--- a/base/message_loop/message_loop.h
+++ b/base/message_loop/message_loop.h
@@ -34,14 +34,10 @@
#include "base/message_loop/message_pump_libevent.h"
#if !defined(OS_MACOSX) && !defined(OS_ANDROID)
-#if defined(USE_AURA) && defined(USE_X11) && !defined(OS_NACL)
-#include "base/message_loop/message_pump_x11.h"
+#if defined(USE_GLIB) && !defined(OS_NACL)
+#include "base/message_loop/message_pump_glib.h"
#elif !defined(OS_ANDROID_HOST)
-#define USE_GTK_MESSAGE_PUMP
-#include "base/message_loop/message_pump_gtk.h"
-#if defined(TOOLKIT_GTK)
-#include "base/message_loop/message_pump_x11.h"
-#endif
+#include "base/message_loop/message_pump_glib.h"
#endif
#endif
@@ -95,8 +91,6 @@ class BASE_EXPORT MessageLoop : public MessagePump::Delegate {
public:
#if defined(OS_WIN)
typedef MessagePumpObserver Observer;
-#elif defined(USE_GTK_MESSAGE_PUMP)
- typedef MessagePumpGdkObserver Observer;
#endif
// A MessageLoop has a particular type, which indicates the set of
@@ -413,13 +407,6 @@ class BASE_EXPORT MessageLoop : public MessagePump::Delegate {
MessagePumpLibevent* pump_libevent() {
return static_cast<MessagePumpLibevent*>(pump_.get());
}
-#if defined(TOOLKIT_GTK)
- friend class MessagePumpX11;
- MessagePumpX11* pump_gpu() {
- DCHECK_EQ(TYPE_GPU, type());
- return static_cast<MessagePumpX11*>(pump_.get());
- }
-#endif
#endif
scoped_ptr<MessagePump> pump_;
@@ -593,10 +580,6 @@ class BASE_EXPORT MessageLoopForUI : public MessageLoop {
#endif
protected:
-#if defined(USE_X11)
- friend class MessagePumpX11;
-#endif
-
#if !defined(OS_MACOSX) && !defined(OS_ANDROID)
// TODO(rvargas): Make this platform independent.
MessagePumpForUI* pump_ui() {
diff --git a/base/message_loop/message_pump_glib.h b/base/message_loop/message_pump_glib.h
index 0211b0f..9acc472 100644
--- a/base/message_loop/message_pump_glib.h
+++ b/base/message_loop/message_pump_glib.h
@@ -94,6 +94,8 @@ class BASE_EXPORT MessagePumpGlib : public MessagePump {
DISALLOW_COPY_AND_ASSIGN(MessagePumpGlib);
};
+typedef MessagePumpGlib MessagePumpForUI;
+
} // namespace base
#endif // BASE_MESSAGE_LOOP_MESSAGE_PUMP_GLIB_H_
diff --git a/base/message_loop/message_pump_x11.cc b/base/message_loop/message_pump_x11.cc
deleted file mode 100644
index fb40b1d..0000000
--- a/base/message_loop/message_pump_x11.cc
+++ /dev/null
@@ -1,63 +0,0 @@
-// Copyright (c) 2012 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 "base/message_loop/message_pump_x11.h"
-
-#include <glib.h>
-#include <X11/X.h>
-#include <X11/extensions/XInput2.h>
-#include <X11/XKBlib.h>
-
-#include "base/basictypes.h"
-#include "base/message_loop/message_loop.h"
-
-namespace base {
-
-namespace {
-
-// The connection is essentially a global that's accessed through a static
-// 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
-// MessagePumpX11::Current()->display() once MessagePumpGtk goes away.
-Display* g_xdisplay = NULL;
-
-} // namespace
-
-MessagePumpX11::MessagePumpX11() : MessagePumpGlib() {
- GetDefaultXDisplay();
-}
-
-MessagePumpX11::~MessagePumpX11() {
- if (g_xdisplay) {
- XCloseDisplay(g_xdisplay);
- g_xdisplay = NULL;
- }
-}
-
-// static
-Display* MessagePumpX11::GetDefaultXDisplay() {
- if (!g_xdisplay)
- g_xdisplay = XOpenDisplay(NULL);
- return g_xdisplay;
-}
-
-#if defined(TOOLKIT_GTK)
-// static
-MessagePumpX11* MessagePumpX11::Current() {
- MessageLoop* loop = MessageLoop::current();
- return static_cast<MessagePumpX11*>(loop->pump_gpu());
-}
-#else
-// static
-MessagePumpX11* MessagePumpX11::Current() {
- MessageLoopForUI* loop = MessageLoopForUI::current();
- return static_cast<MessagePumpX11*>(loop->pump_ui());
-}
-#endif
-
-} // namespace base
diff --git a/base/message_loop/message_pump_x11.h b/base/message_loop/message_pump_x11.h
deleted file mode 100644
index 5fdfeea..0000000
--- a/base/message_loop/message_pump_x11.h
+++ /dev/null
@@ -1,42 +0,0 @@
-// Copyright (c) 2012 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.
-
-#ifndef BASE_MESSAGE_LOOP_MESSAGE_PUMP_X11_H
-#define BASE_MESSAGE_LOOP_MESSAGE_PUMP_X11_H
-
-#include <bitset>
-#include <map>
-
-#include "base/memory/scoped_ptr.h"
-#include "base/message_loop/message_pump.h"
-#include "base/message_loop/message_pump_glib.h"
-#include "base/observer_list.h"
-
-typedef struct _XDisplay Display;
-
-namespace base {
-
-// This class implements a message-pump for dispatching X events.
-class BASE_EXPORT MessagePumpX11 : public MessagePumpGlib {
- public:
- MessagePumpX11();
- virtual ~MessagePumpX11();
-
- // Returns default X Display.
- static Display* GetDefaultXDisplay();
-
- // Returns the UI or GPU message pump.
- static MessagePumpX11* Current();
-
- private:
- DISALLOW_COPY_AND_ASSIGN(MessagePumpX11);
-};
-
-#if !defined(TOOLKIT_GTK)
-typedef MessagePumpX11 MessagePumpForUI;
-#endif
-
-} // namespace base
-
-#endif // BASE_MESSAGE_LOOP_MESSAGE_PUMP_X11_H
diff --git a/chrome/browser/ui/libgtk2ui/gtk2_event_loop.cc b/chrome/browser/ui/libgtk2ui/gtk2_event_loop.cc
index fe32abd..9f71177 100644
--- a/chrome/browser/ui/libgtk2ui/gtk2_event_loop.cc
+++ b/chrome/browser/ui/libgtk2ui/gtk2_event_loop.cc
@@ -10,7 +10,7 @@
#include <X11/X.h>
#include "base/memory/singleton.h"
-#include "base/message_loop/message_pump_x11.h"
+#include "ui/gfx/x/x11_types.h"
namespace libgtk2ui {
@@ -66,7 +66,7 @@ void Gtk2EventLoop::ProcessGdkEventKey(const GdkEventKey& gdk_event_key) {
x_event.xkey.type =
gdk_event_key.type == GDK_KEY_PRESS ? KeyPress : KeyRelease;
x_event.xkey.send_event = gdk_event_key.send_event;
- x_event.xkey.display = base::MessagePumpX11::GetDefaultXDisplay();
+ x_event.xkey.display = gfx::GetXDisplay();
x_event.xkey.window = GDK_WINDOW_XID(gdk_event_key.window);
x_event.xkey.root = DefaultRootWindow(x_event.xkey.display);
x_event.xkey.time = gdk_event_key.time;
diff --git a/chrome/browser/ui/libgtk2ui/x11_input_method_context_impl_gtk2.cc b/chrome/browser/ui/libgtk2ui/x11_input_method_context_impl_gtk2.cc
index 618d750..948314e 100644
--- a/chrome/browser/ui/libgtk2ui/x11_input_method_context_impl_gtk2.cc
+++ b/chrome/browser/ui/libgtk2ui/x11_input_method_context_impl_gtk2.cc
@@ -20,6 +20,7 @@
#include "ui/base/ime/composition_text_util_pango.h"
#include "ui/base/ime/text_input_client.h"
#include "ui/events/event.h"
+#include "ui/gfx/x/x11_types.h"
namespace {
@@ -103,8 +104,7 @@ X11InputMethodContextImplGtk2::X11InputMethodContextImplGtk2(
CHECK(delegate_);
{
- XModifierKeymap* keymap = XGetModifierMapping(
- base::MessagePumpForUI::GetDefaultXDisplay());
+ XModifierKeymap* keymap = XGetModifierMapping(gfx::GetXDisplay());
for (int i = 0; i < 8 * keymap->max_keypermod; ++i) {
if (keymap->modifiermap[i])
modifier_keycodes_.insert(keymap->modifiermap[i]);
diff --git a/content/browser/browser_main_loop.cc b/content/browser/browser_main_loop.cc
index 70f0812..0229944 100644
--- a/content/browser/browser_main_loop.cc
+++ b/content/browser/browser_main_loop.cc
@@ -111,7 +111,7 @@
#endif
#if defined(USE_X11)
-#include <X11/Xlib.h>
+#include "ui/gfx/x/x11_connection.h"
#endif
#if defined(USE_OZONE)
@@ -363,7 +363,7 @@ void BrowserMainLoop::EarlyInitialization() {
#if defined(USE_X11)
if (parsed_command_line_.HasSwitch(switches::kSingleProcess) ||
parsed_command_line_.HasSwitch(switches::kInProcessGPU)) {
- if (!XInitThreads()) {
+ if (!gfx::InitializeThreadedX11()) {
LOG(ERROR) << "Failed to put Xlib into threaded mode.";
}
}
diff --git a/content/browser/power_save_blocker_x11.cc b/content/browser/power_save_blocker_x11.cc
index cecb232..e5fb4e5 100644
--- a/content/browser/power_save_blocker_x11.cc
+++ b/content/browser/power_save_blocker_x11.cc
@@ -22,7 +22,6 @@
#include "base/memory/scoped_ptr.h"
#include "base/memory/singleton.h"
#include "base/message_loop/message_loop_proxy.h"
-#include "base/message_loop/message_pump_x11.h"
#include "base/nix/xdg_util.h"
#include "base/synchronization/lock.h"
#include "content/public/browser/browser_thread.h"
@@ -294,7 +293,7 @@ void PowerSaveBlockerImpl::Delegate::RemoveBlock(DBusAPI api) {
// static
bool PowerSaveBlockerImpl::Delegate::DPMSEnabled() {
- XDisplay* display = base::MessagePumpForUI::GetDefaultXDisplay();
+ XDisplay* display = gfx::GetXDisplay();
BOOL enabled = false;
int dummy;
if (DPMSQueryExtension(display, &dummy, &dummy) && DPMSCapable(display)) {
diff --git a/content/common/gpu/media/rendering_helper.cc b/content/common/gpu/media/rendering_helper.cc
index ae1549b..76d29d1 100644
--- a/content/common/gpu/media/rendering_helper.cc
+++ b/content/common/gpu/media/rendering_helper.cc
@@ -14,6 +14,10 @@
#include "ui/gl/gl_implementation.h"
#include "ui/gl/gl_surface.h"
+#if defined(USE_X11)
+#include "ui/gfx/x/x11_types.h"
+#endif
+
#ifdef GL_VARIANT_GLX
typedef GLXWindow NativeWindowType;
struct XFreeDeleter {
@@ -112,7 +116,7 @@ void RenderingHelper::Initialize(const RenderingHelperParams& params,
CHECK_GT(params.num_windows, 0);
#if GL_VARIANT_GLX
- x_display_ = base::MessagePumpForUI::GetDefaultXDisplay();
+ x_display_ = gfx::GetXDisplay();
CHECK(x_display_);
CHECK(glXQueryVersion(x_display_, NULL, NULL));
const int fbconfig_attr[] = {
@@ -144,7 +148,7 @@ void RenderingHelper::Initialize(const RenderingHelperParams& params,
#if defined(OS_WIN)
native_display = EGL_DEFAULT_DISPLAY;
#else
- x_display_ = base::MessagePumpForUI::GetDefaultXDisplay();
+ x_display_ = gfx::GetXDisplay();
CHECK(x_display_);
native_display = x_display_;
#endif
diff --git a/content/content_tests.gypi b/content/content_tests.gypi
index a9b801d..354500a 100644
--- a/content/content_tests.gypi
+++ b/content/content_tests.gypi
@@ -1400,6 +1400,7 @@
['use_x11==1', {
'dependencies': [
'../build/linux/system.gyp:x11', # Used by rendering_helper.cc
+ '../ui/gfx/gfx.gyp:gfx_x11',
],
}],
],
diff --git a/gpu/config/gpu_info_collector_x11.cc b/gpu/config/gpu_info_collector_x11.cc
index 8516918..b1182fa 100644
--- a/gpu/config/gpu_info_collector_x11.cc
+++ b/gpu/config/gpu_info_collector_x11.cc
@@ -20,6 +20,7 @@
#include "library_loaders/libpci.h"
#include "third_party/libXNVCtrl/NVCtrl.h"
#include "third_party/libXNVCtrl/NVCtrlLib.h"
+#include "ui/gfx/x/x11_types.h"
#include "ui/gl/gl_bindings.h"
#include "ui/gl/gl_context.h"
#include "ui/gl/gl_implementation.h"
@@ -70,7 +71,7 @@ std::string CollectDriverVersionATI() {
// Use NVCtrl extention to query NV driver version.
// Return empty string on failing.
std::string CollectDriverVersionNVidia() {
- Display* display = base::MessagePumpForUI::GetDefaultXDisplay();
+ Display* display = gfx::GetXDisplay();
if (!display) {
LOG(ERROR) << "XOpenDisplay failed.";
return std::string();
diff --git a/ui/aura/aura.gyp b/ui/aura/aura.gyp
index f49a294..26be1c3 100644
--- a/ui/aura/aura.gyp
+++ b/ui/aura/aura.gyp
@@ -208,6 +208,13 @@
'sources': [
'demo/demo_main.cc',
],
+ 'conditions': [
+ ['use_x11==1', {
+ 'dependencies': [
+ '../gfx/gfx.gyp:gfx_x11',
+ ],
+ }],
+ ]
},
{
'target_name': 'aura_bench',
@@ -234,6 +241,13 @@
'sources': [
'bench/bench_main.cc',
],
+ 'conditions': [
+ ['use_x11==1', {
+ 'dependencies': [
+ '../gfx/gfx.gyp:gfx_x11',
+ ],
+ }],
+ ]
},
{
'target_name': 'aura_unittests',
diff --git a/ui/aura/bench/bench_main.cc b/ui/aura/bench/bench_main.cc
index 337da8d..c5b98c0 100644
--- a/ui/aura/bench/bench_main.cc
+++ b/ui/aura/bench/bench_main.cc
@@ -33,6 +33,7 @@
#include "ui/gfx/canvas.h"
#include "ui/gfx/rect.h"
#include "ui/gfx/skia_util.h"
+#include "ui/gfx/x/x11_connection.h"
#include "ui/gl/gl_surface.h"
#ifndef GL_GLEXT_PROTOTYPES
@@ -40,10 +41,6 @@
#endif
#include "third_party/khronos/GLES2/gl2ext.h"
-#if defined(USE_X11)
-#include "base/message_loop/message_pump_x11.h"
-#endif
-
using base::TimeTicks;
using ui::Compositor;
using ui::Layer;
@@ -294,7 +291,7 @@ int main(int argc, char** argv) {
#if defined(USE_X11)
// This demo uses InProcessContextFactory which uses X on a separate Gpu
// thread.
- XInitThreads();
+ gfx::InitializeThreadedX11();
#endif
gfx::GLSurface::InitializeOneOff();
diff --git a/ui/aura/demo/demo_main.cc b/ui/aura/demo/demo_main.cc
index 548aede..21d1dda 100644
--- a/ui/aura/demo/demo_main.cc
+++ b/ui/aura/demo/demo_main.cc
@@ -2,10 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#if defined(USE_X11)
-#include <X11/Xlib.h>
-#endif
-
#include "base/at_exit.h"
#include "base/command_line.h"
#include "base/i18n/icu_util.h"
@@ -28,7 +24,7 @@
#include "ui/gl/gl_surface.h"
#if defined(USE_X11)
-#include "base/message_loop/message_pump_x11.h"
+#include "ui/gfx/x/x11_connection.h"
#endif
namespace {
@@ -111,7 +107,7 @@ int DemoMain() {
#if defined(USE_X11)
// This demo uses InProcessContextFactory which uses X on a separate Gpu
// thread.
- XInitThreads();
+ gfx::InitializeThreadedX11();
#endif
gfx::GLSurface::InitializeOneOff();
diff --git a/ui/base/x/selection_requestor.cc b/ui/base/x/selection_requestor.cc
index 158028d..080007a 100644
--- a/ui/base/x/selection_requestor.cc
+++ b/ui/base/x/selection_requestor.cc
@@ -4,10 +4,10 @@
#include "ui/base/x/selection_requestor.h"
-#include "base/message_loop/message_pump_x11.h"
#include "base/run_loop.h"
#include "ui/base/x/selection_utils.h"
#include "ui/base/x/x11_util.h"
+#include "ui/gfx/x/x11_types.h"
namespace ui {
diff --git a/ui/base/x/x11_util.cc b/ui/base/x/x11_util.cc
index ac97549..3d733dd 100644
--- a/ui/base/x/x11_util.cc
+++ b/ui/base/x/x11_util.cc
@@ -119,14 +119,14 @@ class XCursorCache {
std::pair<std::map<int, ::Cursor>::iterator, bool> it = cache_.insert(
std::make_pair(cursor_shape, 0));
if (it.second) {
- XDisplay* display = base::MessagePumpForUI::GetDefaultXDisplay();
+ XDisplay* display = gfx::GetXDisplay();
it.first->second = XCreateFontCursor(display, cursor_shape);
}
return it.first->second;
}
void Clear() {
- XDisplay* display = base::MessagePumpForUI::GetDefaultXDisplay();
+ XDisplay* display = gfx::GetXDisplay();
for (std::map<int, ::Cursor>::iterator it =
cache_.begin(); it != cache_.end(); ++it) {
XFreeCursor(display, it->second);
diff --git a/ui/display/chromeos/x11/touchscreen_delegate_x11.cc b/ui/display/chromeos/x11/touchscreen_delegate_x11.cc
index 6299023..4a72c69 100644
--- a/ui/display/chromeos/x11/touchscreen_delegate_x11.cc
+++ b/ui/display/chromeos/x11/touchscreen_delegate_x11.cc
@@ -10,14 +10,14 @@
#include <cmath>
#include <set>
-#include "base/message_loop/message_pump_x11.h"
#include "ui/display/chromeos/display_mode.h"
#include "ui/display/chromeos/display_snapshot.h"
+#include "ui/gfx/x/x11_types.h"
namespace ui {
TouchscreenDelegateX11::TouchscreenDelegateX11()
- : display_(base::MessagePumpX11::GetDefaultXDisplay()) {}
+ : display_(gfx::GetXDisplay()) {}
TouchscreenDelegateX11::~TouchscreenDelegateX11() {}
diff --git a/ui/display/x11/DEPS b/ui/display/x11/DEPS
new file mode 100644
index 0000000..25c2d71
--- /dev/null
+++ b/ui/display/x11/DEPS
@@ -0,0 +1,3 @@
+include_rules = [
+ "+ui/gfx/x",
+]
diff --git a/ui/display/x11/edid_parser_x11.cc b/ui/display/x11/edid_parser_x11.cc
index c53bd89..55fa62b 100644
--- a/ui/display/x11/edid_parser_x11.cc
+++ b/ui/display/x11/edid_parser_x11.cc
@@ -8,9 +8,9 @@
#include <X11/Xatom.h>
#include <X11/Xlib.h>
-#include "base/message_loop/message_loop.h"
#include "base/strings/string_util.h"
#include "ui/display/edid_parser.h"
+#include "ui/gfx/x/x11_types.h"
namespace ui {
@@ -20,7 +20,7 @@ bool IsRandRAvailable() {
int randr_version_major = 0;
int randr_version_minor = 0;
static bool is_randr_available = XRRQueryVersion(
- base::MessagePumpX11::GetDefaultXDisplay(),
+ gfx::GetXDisplay(),
&randr_version_major, &randr_version_minor);
return is_randr_available;
}
@@ -32,10 +32,10 @@ bool GetEDIDProperty(XID output, std::vector<uint8_t>* edid) {
if (!IsRandRAvailable())
return false;
- Display* display = base::MessagePumpX11::GetDefaultXDisplay();
+ Display* display = gfx::GetXDisplay();
static Atom edid_property = XInternAtom(
- base::MessagePumpX11::GetDefaultXDisplay(),
+ gfx::GetXDisplay(),
RR_PROPERTY_RANDR_EDID, false);
bool has_edid_property = false;
diff --git a/ui/events/x/events_x.cc b/ui/events/x/events_x.cc
index bf8b04e..15b1adc 100644
--- a/ui/events/x/events_x.cc
+++ b/ui/events/x/events_x.cc
@@ -12,7 +12,6 @@
#include "base/logging.h"
#include "base/memory/singleton.h"
-#include "base/message_loop/message_pump_x11.h"
#include "ui/events/event_utils.h"
#include "ui/events/keycodes/keyboard_code_conversion_x.h"
#include "ui/events/x/device_data_manager.h"
diff --git a/ui/gfx/gfx.gyp b/ui/gfx/gfx.gyp
index 421f593..def0d69 100644
--- a/ui/gfx/gfx.gyp
+++ b/ui/gfx/gfx.gyp
@@ -580,6 +580,8 @@
'sources': [
'x/x11_atom_cache.cc',
'x/x11_atom_cache.h',
+ 'x/x11_connection.cc',
+ 'x/x11_connection.h',
'x/x11_error_tracker.cc',
'x/x11_error_tracker.h',
'x/x11_types.cc',
diff --git a/ui/gfx/x/x11_connection.cc b/ui/gfx/x/x11_connection.cc
new file mode 100644
index 0000000..c5ee77f
--- /dev/null
+++ b/ui/gfx/x/x11_connection.cc
@@ -0,0 +1,17 @@
+// 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/gfx/x/x11_connection.h"
+
+#include <X11/Xlib.h>
+
+#include "ui/gfx/x/x11_types.h"
+
+namespace gfx {
+
+bool InitializeThreadedX11() {
+ return XInitThreads() && gfx::GetXDisplay();
+}
+
+} // namespace gfx
diff --git a/ui/gfx/x/x11_connection.h b/ui/gfx/x/x11_connection.h
new file mode 100644
index 0000000..06ca89f
--- /dev/null
+++ b/ui/gfx/x/x11_connection.h
@@ -0,0 +1,18 @@
+// 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.
+
+#ifndef UI_GFX_X_X11_CONNECTION_H_
+#define UI_GFX_X_X11_CONNECTION_H_
+
+#include "ui/gfx/gfx_export.h"
+
+namespace gfx {
+
+// Initializes thread support for X11, and opens a connection to the display.
+// Return false if either fails, and true otherwise.
+GFX_EXPORT bool InitializeThreadedX11();
+
+} // namespace gfx
+
+#endif // UI_GFX_X_X11_CONNECTION_H_
diff --git a/ui/gfx/x/x11_types.cc b/ui/gfx/x/x11_types.cc
index 48ce641..6c4f62d 100644
--- a/ui/gfx/x/x11_types.cc
+++ b/ui/gfx/x/x11_types.cc
@@ -11,7 +11,10 @@
namespace gfx {
XDisplay* GetXDisplay() {
- return base::MessagePumpForUI::GetDefaultXDisplay();
+ static XDisplay* display = NULL;
+ if (!display)
+ display = XOpenDisplay(NULL);
+ return display;
}
void PutARGBImage(XDisplay* display,
diff --git a/ui/gl/gl_image_glx.cc b/ui/gl/gl_image_glx.cc
index b68a5fe..4b7e883 100644
--- a/ui/gl/gl_image_glx.cc
+++ b/ui/gl/gl_image_glx.cc
@@ -12,6 +12,7 @@ extern "C" {
#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
#include "base/message_loop/message_loop.h"
+#include "ui/gfx/x/x11_types.h"
#include "ui/gl/gl_bindings.h"
#include "ui/gl/gl_surface_glx.h"
@@ -43,7 +44,7 @@ int TextureFormat(int depth) {
} // namespace anonymous
GLImageGLX::GLImageGLX(gfx::PluginWindowHandle window)
- : display_(base::MessagePumpForUI::GetDefaultXDisplay()),
+ : display_(gfx::GetXDisplay()),
window_(window),
pixmap_(0),
glx_pixmap_(0) {}
diff --git a/ui/gl/gl_surface_glx.cc b/ui/gl/gl_surface_glx.cc
index 7647694..b97606a3 100644
--- a/ui/gl/gl_surface_glx.cc
+++ b/ui/gl/gl_surface_glx.cc
@@ -21,6 +21,7 @@ extern "C" {
#include "base/threading/thread.h"
#include "base/time/time.h"
#include "third_party/mesa/src/include/GL/osmesa.h"
+#include "ui/gfx/x/x11_connection.h"
#include "ui/gfx/x/x11_types.h"
#include "ui/gl/gl_bindings.h"
#include "ui/gl/gl_implementation.h"
@@ -378,22 +379,8 @@ bool GLSurfaceGLX::InitializeOneOff() {
// SGIVideoSyncProviderShim (if instantiated) will issue X commands on
// it's own thread.
- XInitThreads();
-
-#if defined(TOOLKIT_GTK)
- // Be sure to use the X display handle and not the GTK display handle if this
- // is the GPU process.
- g_create_child_windows =
- base::MessageLoop::current() &&
- base::MessageLoop::current()->type() == base::MessageLoop::TYPE_GPU;
-
- if (g_create_child_windows)
- g_display = base::MessagePumpX11::GetDefaultXDisplay();
- else
- g_display = base::MessagePumpForUI::GetDefaultXDisplay();
-#else
- g_display = base::MessagePumpForUI::GetDefaultXDisplay();
-#endif
+ gfx::InitializeThreadedX11();
+ g_display = gfx::GetXDisplay();
if (!g_display) {
LOG(ERROR) << "XOpenDisplay failed.";
diff --git a/ui/gl/gl_surface_x11.cc b/ui/gl/gl_surface_x11.cc
index 066f915..a5d5aab 100644
--- a/ui/gl/gl_surface_x11.cc
+++ b/ui/gl/gl_surface_x11.cc
@@ -10,6 +10,7 @@
#include "base/message_loop/message_loop.h"
#include "third_party/mesa/src/include/GL/osmesa.h"
#include "ui/gfx/native_widget_types.h"
+#include "ui/gfx/x/x11_types.h"
#include "ui/gl/gl_bindings.h"
#include "ui/gl/gl_implementation.h"
#include "ui/gl/gl_surface_egl.h"
@@ -79,7 +80,7 @@ bool GLSurface::InitializeOneOffInternal() {
NativeViewGLSurfaceOSMesa::NativeViewGLSurfaceOSMesa(
gfx::AcceleratedWidget window)
: GLSurfaceOSMesa(OSMESA_BGRA, gfx::Size(1, 1)),
- xdisplay_(base::MessagePumpForUI::GetDefaultXDisplay()),
+ xdisplay_(gfx::GetXDisplay()),
window_graphics_context_(0),
window_(window),
pixmap_graphics_context_(0),
@@ -94,7 +95,7 @@ bool NativeViewGLSurfaceOSMesa::InitializeOneOff() {
if (initialized)
return true;
- if (!base::MessagePumpForUI::GetDefaultXDisplay()) {
+ if (!gfx::GetXDisplay()) {
LOG(ERROR) << "XOpenDisplay failed.";
return false;
}
@@ -341,7 +342,7 @@ scoped_refptr<GLSurface> GLSurface::CreateOffscreenGLSurface(
}
EGLNativeDisplayType GetPlatformDefaultEGLNativeDisplay() {
- return base::MessagePumpForUI::GetDefaultXDisplay();
+ return gfx::GetXDisplay();
}
} // namespace gfx
diff --git a/ui/views/examples/examples_main.cc b/ui/views/examples/examples_main.cc
index 9e028f0..90802d4 100644
--- a/ui/views/examples/examples_main.cc
+++ b/ui/views/examples/examples_main.cc
@@ -2,10 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#if defined(USE_X11)
-#include <X11/Xlib.h>
-#endif
-
#include "base/at_exit.h"
#include "base/command_line.h"
#include "base/files/file_path.h"
@@ -27,10 +23,15 @@
#if !defined(OS_CHROMEOS)
#include "ui/views/widget/desktop_aura/desktop_screen.h"
#endif
+
#if defined(OS_WIN)
#include "ui/base/win/scoped_ole_initializer.h"
#endif
+#if defined(USE_X11)
+#include "ui/gfx/x/x11_connection.h"
+#endif
+
int main(int argc, char** argv) {
#if defined(OS_WIN)
ui::ScopedOleInitializer ole_initializer_;
@@ -43,7 +44,7 @@ int main(int argc, char** argv) {
#if defined(USE_X11)
// This demo uses InProcessContextFactory which uses X on a separate Gpu
// thread.
- XInitThreads();
+ gfx::InitializeThreadedX11();
#endif
gfx::GLSurface::InitializeOneOff();
diff --git a/ui/views/test/ui_controls_factory_desktop_aurax11.cc b/ui/views/test/ui_controls_factory_desktop_aurax11.cc
index a846799..d574f66 100644
--- a/ui/views/test/ui_controls_factory_desktop_aurax11.cc
+++ b/ui/views/test/ui_controls_factory_desktop_aurax11.cc
@@ -21,6 +21,7 @@
#include "ui/compositor/dip_util.h"
#include "ui/events/keycodes/keyboard_code_conversion_x.h"
#include "ui/events/test/platform_event_waiter.h"
+#include "ui/gfx/x/x11_connection.h"
#include "ui/views/widget/desktop_aura/desktop_window_tree_host_x11.h"
namespace views {
@@ -280,8 +281,9 @@ class UIControlsDesktopX11 : public UIControlsAura {
} // namespace
UIControlsAura* CreateUIControlsDesktopAura() {
- // The constructor of UIControlsDesktopX11 needs XInitThreads to be called.
- XInitThreads();
+ // The constructor of UIControlsDesktopX11 needs X11 connection to be
+ // initialized.
+ gfx::InitializeThreadedX11();
return new UIControlsDesktopX11();
}
diff --git a/ui/views/widget/desktop_aura/desktop_screen_x11.cc b/ui/views/widget/desktop_aura/desktop_screen_x11.cc
index 6c89dd0..0e6858b 100644
--- a/ui/views/widget/desktop_aura/desktop_screen_x11.cc
+++ b/ui/views/widget/desktop_aura/desktop_screen_x11.cc
@@ -120,7 +120,7 @@ namespace views {
// DesktopScreenX11, public:
DesktopScreenX11::DesktopScreenX11()
- : xdisplay_(base::MessagePumpX11::GetDefaultXDisplay()),
+ : xdisplay_(gfx::GetXDisplay()),
x_root_window_(DefaultRootWindow(xdisplay_)),
has_xrandr_(false),
xrandr_event_base_(0) {
@@ -342,7 +342,7 @@ uint32_t DesktopScreenX11::DispatchEvent(const ui::PlatformEvent& event) {
DesktopScreenX11::DesktopScreenX11(
const std::vector<gfx::Display>& test_displays)
- : xdisplay_(base::MessagePumpX11::GetDefaultXDisplay()),
+ : xdisplay_(gfx::GetXDisplay()),
x_root_window_(DefaultRootWindow(xdisplay_)),
has_xrandr_(false),
xrandr_event_base_(0),
diff --git a/ui/views/widget/desktop_aura/desktop_window_tree_host_x11.cc b/ui/views/widget/desktop_aura/desktop_window_tree_host_x11.cc
index b799767..221d1843 100644
--- a/ui/views/widget/desktop_aura/desktop_window_tree_host_x11.cc
+++ b/ui/views/widget/desktop_aura/desktop_window_tree_host_x11.cc
@@ -12,7 +12,6 @@
#include "base/basictypes.h"
#include "base/debug/trace_event.h"
-#include "base/message_loop/message_pump_x11.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "third_party/skia/include/core/SkPath.h"
diff --git a/ui/views/widget/desktop_aura/x11_desktop_window_move_client.cc b/ui/views/widget/desktop_aura/x11_desktop_window_move_client.cc
index 34445c8..195d102 100644
--- a/ui/views/widget/desktop_aura/x11_desktop_window_move_client.cc
+++ b/ui/views/widget/desktop_aura/x11_desktop_window_move_client.cc
@@ -8,7 +8,6 @@
#include "base/debug/stack_trace.h"
#include "base/message_loop/message_loop.h"
-#include "base/message_loop/message_pump_x11.h"
#include "base/run_loop.h"
#include "ui/aura/env.h"
#include "ui/aura/window.h"
diff --git a/ui/views/widget/desktop_aura/x11_whole_screen_move_loop.cc b/ui/views/widget/desktop_aura/x11_whole_screen_move_loop.cc
index 7e18f3a..250b9de 100644
--- a/ui/views/widget/desktop_aura/x11_whole_screen_move_loop.cc
+++ b/ui/views/widget/desktop_aura/x11_whole_screen_move_loop.cc
@@ -10,7 +10,6 @@
#include "base/bind.h"
#include "base/message_loop/message_loop.h"
-#include "base/message_loop/message_pump_x11.h"
#include "base/run_loop.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "ui/aura/env.h"