summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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, 205 insertions, 118 deletions
diff --git a/ash/shell.cc b/ash/shell.cc
index 6891419..98f7346 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 "ui/gfx/x/x11_types.h"
+#include "base/message_loop/message_pump_x11.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 61fa218..49f1d08 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 "ui/gfx/x/x11_connection.h"
+#include <X11/Xlib.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.
- gfx::InitializeThreadedX11();
+ XInitThreads();
#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 5eee024..5084e7c 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 "ui/gfx/x/x11_types.h"
+#include "base/message_loop/message_pump_x11.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(gfx::GetXDisplay(),
+ XWarpPointer(base::MessagePumpX11::GetDefaultXDisplay(),
None,
window->GetHost()->GetAcceleratedWidget(),
0, 0, 0, 0,
diff --git a/base/BUILD.gn b/base/BUILD.gn
index feff58b..4da113c 100644
--- a/base/BUILD.gn
+++ b/base/BUILD.gn
@@ -330,6 +330,8 @@ 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 12d2a5f..1e9ae28 100644
--- a/base/base.gyp
+++ b/base/base.gyp
@@ -245,6 +245,8 @@
'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 92ecf6e..645ef66 100644
--- a/base/base.gypi
+++ b/base/base.gypi
@@ -733,6 +733,11 @@
'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'],
}],
@@ -886,6 +891,7 @@
['<(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 07f9105..6539c65 100644
--- a/base/message_loop/message_loop.h
+++ b/base/message_loop/message_loop.h
@@ -34,10 +34,14 @@
#include "base/message_loop/message_pump_libevent.h"
#if !defined(OS_MACOSX) && !defined(OS_ANDROID)
-#if defined(USE_GLIB) && !defined(OS_NACL)
-#include "base/message_loop/message_pump_glib.h"
+#if defined(USE_AURA) && defined(USE_X11) && !defined(OS_NACL)
+#include "base/message_loop/message_pump_x11.h"
#elif !defined(OS_ANDROID_HOST)
-#include "base/message_loop/message_pump_glib.h"
+#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
#endif
#endif
@@ -91,6 +95,8 @@ 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
@@ -407,6 +413,13 @@ 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_;
@@ -580,6 +593,10 @@ 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 9acc472..0211b0f 100644
--- a/base/message_loop/message_pump_glib.h
+++ b/base/message_loop/message_pump_glib.h
@@ -94,8 +94,6 @@ 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
new file mode 100644
index 0000000..fb40b1d
--- /dev/null
+++ b/base/message_loop/message_pump_x11.cc
@@ -0,0 +1,63 @@
+// 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
new file mode 100644
index 0000000..5fdfeea
--- /dev/null
+++ b/base/message_loop/message_pump_x11.h
@@ -0,0 +1,42 @@
+// 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 9f71177..fe32abd 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 "ui/gfx/x/x11_types.h"
+#include "base/message_loop/message_pump_x11.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 = gfx::GetXDisplay();
+ x_event.xkey.display = base::MessagePumpX11::GetDefaultXDisplay();
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 948314e..618d750 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,7 +20,6 @@
#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 {
@@ -104,7 +103,8 @@ X11InputMethodContextImplGtk2::X11InputMethodContextImplGtk2(
CHECK(delegate_);
{
- XModifierKeymap* keymap = XGetModifierMapping(gfx::GetXDisplay());
+ XModifierKeymap* keymap = XGetModifierMapping(
+ base::MessagePumpForUI::GetDefaultXDisplay());
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 0229944..70f0812 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 "ui/gfx/x/x11_connection.h"
+#include <X11/Xlib.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 (!gfx::InitializeThreadedX11()) {
+ if (!XInitThreads()) {
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 e5fb4e5..cecb232 100644
--- a/content/browser/power_save_blocker_x11.cc
+++ b/content/browser/power_save_blocker_x11.cc
@@ -22,6 +22,7 @@
#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"
@@ -293,7 +294,7 @@ void PowerSaveBlockerImpl::Delegate::RemoveBlock(DBusAPI api) {
// static
bool PowerSaveBlockerImpl::Delegate::DPMSEnabled() {
- XDisplay* display = gfx::GetXDisplay();
+ XDisplay* display = base::MessagePumpForUI::GetDefaultXDisplay();
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 76d29d1..ae1549b 100644
--- a/content/common/gpu/media/rendering_helper.cc
+++ b/content/common/gpu/media/rendering_helper.cc
@@ -14,10 +14,6 @@
#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 {
@@ -116,7 +112,7 @@ void RenderingHelper::Initialize(const RenderingHelperParams& params,
CHECK_GT(params.num_windows, 0);
#if GL_VARIANT_GLX
- x_display_ = gfx::GetXDisplay();
+ x_display_ = base::MessagePumpForUI::GetDefaultXDisplay();
CHECK(x_display_);
CHECK(glXQueryVersion(x_display_, NULL, NULL));
const int fbconfig_attr[] = {
@@ -148,7 +144,7 @@ void RenderingHelper::Initialize(const RenderingHelperParams& params,
#if defined(OS_WIN)
native_display = EGL_DEFAULT_DISPLAY;
#else
- x_display_ = gfx::GetXDisplay();
+ x_display_ = base::MessagePumpForUI::GetDefaultXDisplay();
CHECK(x_display_);
native_display = x_display_;
#endif
diff --git a/content/content_tests.gypi b/content/content_tests.gypi
index 354500a..a9b801d 100644
--- a/content/content_tests.gypi
+++ b/content/content_tests.gypi
@@ -1400,7 +1400,6 @@
['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 b1182fa..8516918 100644
--- a/gpu/config/gpu_info_collector_x11.cc
+++ b/gpu/config/gpu_info_collector_x11.cc
@@ -20,7 +20,6 @@
#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"
@@ -71,7 +70,7 @@ std::string CollectDriverVersionATI() {
// Use NVCtrl extention to query NV driver version.
// Return empty string on failing.
std::string CollectDriverVersionNVidia() {
- Display* display = gfx::GetXDisplay();
+ Display* display = base::MessagePumpForUI::GetDefaultXDisplay();
if (!display) {
LOG(ERROR) << "XOpenDisplay failed.";
return std::string();
diff --git a/ui/aura/aura.gyp b/ui/aura/aura.gyp
index 26be1c3..f49a294 100644
--- a/ui/aura/aura.gyp
+++ b/ui/aura/aura.gyp
@@ -208,13 +208,6 @@
'sources': [
'demo/demo_main.cc',
],
- 'conditions': [
- ['use_x11==1', {
- 'dependencies': [
- '../gfx/gfx.gyp:gfx_x11',
- ],
- }],
- ]
},
{
'target_name': 'aura_bench',
@@ -241,13 +234,6 @@
'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 c5b98c0..337da8d 100644
--- a/ui/aura/bench/bench_main.cc
+++ b/ui/aura/bench/bench_main.cc
@@ -33,7 +33,6 @@
#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
@@ -41,6 +40,10 @@
#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;
@@ -291,7 +294,7 @@ int main(int argc, char** argv) {
#if defined(USE_X11)
// This demo uses InProcessContextFactory which uses X on a separate Gpu
// thread.
- gfx::InitializeThreadedX11();
+ XInitThreads();
#endif
gfx::GLSurface::InitializeOneOff();
diff --git a/ui/aura/demo/demo_main.cc b/ui/aura/demo/demo_main.cc
index 21d1dda..548aede 100644
--- a/ui/aura/demo/demo_main.cc
+++ b/ui/aura/demo/demo_main.cc
@@ -2,6 +2,10 @@
// 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"
@@ -24,7 +28,7 @@
#include "ui/gl/gl_surface.h"
#if defined(USE_X11)
-#include "ui/gfx/x/x11_connection.h"
+#include "base/message_loop/message_pump_x11.h"
#endif
namespace {
@@ -107,7 +111,7 @@ int DemoMain() {
#if defined(USE_X11)
// This demo uses InProcessContextFactory which uses X on a separate Gpu
// thread.
- gfx::InitializeThreadedX11();
+ XInitThreads();
#endif
gfx::GLSurface::InitializeOneOff();
diff --git a/ui/base/x/selection_requestor.cc b/ui/base/x/selection_requestor.cc
index 080007a..158028d 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 3d733dd..ac97549 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 = gfx::GetXDisplay();
+ XDisplay* display = base::MessagePumpForUI::GetDefaultXDisplay();
it.first->second = XCreateFontCursor(display, cursor_shape);
}
return it.first->second;
}
void Clear() {
- XDisplay* display = gfx::GetXDisplay();
+ XDisplay* display = base::MessagePumpForUI::GetDefaultXDisplay();
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 4a72c69..6299023 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_(gfx::GetXDisplay()) {}
+ : display_(base::MessagePumpX11::GetDefaultXDisplay()) {}
TouchscreenDelegateX11::~TouchscreenDelegateX11() {}
diff --git a/ui/display/x11/DEPS b/ui/display/x11/DEPS
deleted file mode 100644
index 25c2d71..0000000
--- a/ui/display/x11/DEPS
+++ /dev/null
@@ -1,3 +0,0 @@
-include_rules = [
- "+ui/gfx/x",
-]
diff --git a/ui/display/x11/edid_parser_x11.cc b/ui/display/x11/edid_parser_x11.cc
index 55fa62b..c53bd89 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(
- gfx::GetXDisplay(),
+ base::MessagePumpX11::GetDefaultXDisplay(),
&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 = gfx::GetXDisplay();
+ Display* display = base::MessagePumpX11::GetDefaultXDisplay();
static Atom edid_property = XInternAtom(
- gfx::GetXDisplay(),
+ base::MessagePumpX11::GetDefaultXDisplay(),
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 15b1adc..bf8b04e 100644
--- a/ui/events/x/events_x.cc
+++ b/ui/events/x/events_x.cc
@@ -12,6 +12,7 @@
#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 def0d69..421f593 100644
--- a/ui/gfx/gfx.gyp
+++ b/ui/gfx/gfx.gyp
@@ -580,8 +580,6 @@
'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
deleted file mode 100644
index c5ee77f..0000000
--- a/ui/gfx/x/x11_connection.cc
+++ /dev/null
@@ -1,17 +0,0 @@
-// 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
deleted file mode 100644
index 06ca89f..0000000
--- a/ui/gfx/x/x11_connection.h
+++ /dev/null
@@ -1,18 +0,0 @@
-// 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 6c4f62d..48ce641 100644
--- a/ui/gfx/x/x11_types.cc
+++ b/ui/gfx/x/x11_types.cc
@@ -11,10 +11,7 @@
namespace gfx {
XDisplay* GetXDisplay() {
- static XDisplay* display = NULL;
- if (!display)
- display = XOpenDisplay(NULL);
- return display;
+ return base::MessagePumpForUI::GetDefaultXDisplay();
}
void PutARGBImage(XDisplay* display,
diff --git a/ui/gl/gl_image_glx.cc b/ui/gl/gl_image_glx.cc
index 4b7e883..b68a5fe 100644
--- a/ui/gl/gl_image_glx.cc
+++ b/ui/gl/gl_image_glx.cc
@@ -12,7 +12,6 @@ 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"
@@ -44,7 +43,7 @@ int TextureFormat(int depth) {
} // namespace anonymous
GLImageGLX::GLImageGLX(gfx::PluginWindowHandle window)
- : display_(gfx::GetXDisplay()),
+ : display_(base::MessagePumpForUI::GetDefaultXDisplay()),
window_(window),
pixmap_(0),
glx_pixmap_(0) {}
diff --git a/ui/gl/gl_surface_glx.cc b/ui/gl/gl_surface_glx.cc
index b97606a3..7647694 100644
--- a/ui/gl/gl_surface_glx.cc
+++ b/ui/gl/gl_surface_glx.cc
@@ -21,7 +21,6 @@ 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"
@@ -379,8 +378,22 @@ bool GLSurfaceGLX::InitializeOneOff() {
// SGIVideoSyncProviderShim (if instantiated) will issue X commands on
// it's own thread.
- gfx::InitializeThreadedX11();
- g_display = gfx::GetXDisplay();
+ 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
if (!g_display) {
LOG(ERROR) << "XOpenDisplay failed.";
diff --git a/ui/gl/gl_surface_x11.cc b/ui/gl/gl_surface_x11.cc
index a5d5aab..066f915 100644
--- a/ui/gl/gl_surface_x11.cc
+++ b/ui/gl/gl_surface_x11.cc
@@ -10,7 +10,6 @@
#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"
@@ -80,7 +79,7 @@ bool GLSurface::InitializeOneOffInternal() {
NativeViewGLSurfaceOSMesa::NativeViewGLSurfaceOSMesa(
gfx::AcceleratedWidget window)
: GLSurfaceOSMesa(OSMESA_BGRA, gfx::Size(1, 1)),
- xdisplay_(gfx::GetXDisplay()),
+ xdisplay_(base::MessagePumpForUI::GetDefaultXDisplay()),
window_graphics_context_(0),
window_(window),
pixmap_graphics_context_(0),
@@ -95,7 +94,7 @@ bool NativeViewGLSurfaceOSMesa::InitializeOneOff() {
if (initialized)
return true;
- if (!gfx::GetXDisplay()) {
+ if (!base::MessagePumpForUI::GetDefaultXDisplay()) {
LOG(ERROR) << "XOpenDisplay failed.";
return false;
}
@@ -342,7 +341,7 @@ scoped_refptr<GLSurface> GLSurface::CreateOffscreenGLSurface(
}
EGLNativeDisplayType GetPlatformDefaultEGLNativeDisplay() {
- return gfx::GetXDisplay();
+ return base::MessagePumpForUI::GetDefaultXDisplay();
}
} // namespace gfx
diff --git a/ui/views/examples/examples_main.cc b/ui/views/examples/examples_main.cc
index 90802d4..9e028f0 100644
--- a/ui/views/examples/examples_main.cc
+++ b/ui/views/examples/examples_main.cc
@@ -2,6 +2,10 @@
// 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"
@@ -23,15 +27,10 @@
#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_;
@@ -44,7 +43,7 @@ int main(int argc, char** argv) {
#if defined(USE_X11)
// This demo uses InProcessContextFactory which uses X on a separate Gpu
// thread.
- gfx::InitializeThreadedX11();
+ XInitThreads();
#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 d574f66..a846799 100644
--- a/ui/views/test/ui_controls_factory_desktop_aurax11.cc
+++ b/ui/views/test/ui_controls_factory_desktop_aurax11.cc
@@ -21,7 +21,6 @@
#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 {
@@ -281,9 +280,8 @@ class UIControlsDesktopX11 : public UIControlsAura {
} // namespace
UIControlsAura* CreateUIControlsDesktopAura() {
- // The constructor of UIControlsDesktopX11 needs X11 connection to be
- // initialized.
- gfx::InitializeThreadedX11();
+ // The constructor of UIControlsDesktopX11 needs XInitThreads to be called.
+ XInitThreads();
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 0e6858b..6c89dd0 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_(gfx::GetXDisplay()),
+ : xdisplay_(base::MessagePumpX11::GetDefaultXDisplay()),
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_(gfx::GetXDisplay()),
+ : xdisplay_(base::MessagePumpX11::GetDefaultXDisplay()),
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 221d1843..b799767 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,6 +12,7 @@
#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 195d102..34445c8 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,6 +8,7 @@
#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 250b9de..7e18f3a 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,6 +10,7 @@
#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"