summaryrefslogtreecommitdiffstats
path: root/chrome/common/x11_util.cc
diff options
context:
space:
mode:
authoragl@chromium.org <agl@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-21 01:12:09 +0000
committeragl@chromium.org <agl@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-21 01:12:09 +0000
commit363b3b0800174428306597483e0f42ea8f502ad3 (patch)
tree9cca1044c75f516905893b15c5c5dbde7ae9b0e6 /chrome/common/x11_util.cc
parentb01998a811ed26bee97b9fb51358235af54a53ac (diff)
downloadchromium_src-363b3b0800174428306597483e0f42ea8f502ad3.zip
chromium_src-363b3b0800174428306597483e0f42ea8f502ad3.tar.gz
chromium_src-363b3b0800174428306597483e0f42ea8f502ad3.tar.bz2
Linux: move X operations from the IO to UI2 thread.
Currently we perform several X operations on the IO thread including geometry and clipboard work. This is causing races inside Xlib and crashing the browser. These are the result of synchronous calls from the renderer, so we cannot route these requests to the UI thread without risking deadlock. Thus we introduce the UI2 thread. This thread has a second connection to the X server and can perform X operations safely the without UI thread. Work remains to be done: Since we still have the hack where we pass GtkWidget pointers into the renderer and back, we still have to access these structures from the IO and UI2 threads. This still needs to be fixed, but this is not the patch for it. Also, not all the X calls from the IO thread have been moved over in this patch; just a few small ones. http://codereview.chromium.org/67145 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@14075 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common/x11_util.cc')
-rw-r--r--chrome/common/x11_util.cc30
1 files changed, 30 insertions, 0 deletions
diff --git a/chrome/common/x11_util.cc b/chrome/common/x11_util.cc
index d10c320..83fc02a 100644
--- a/chrome/common/x11_util.cc
+++ b/chrome/common/x11_util.cc
@@ -6,6 +6,7 @@
// ported from XCB since we can't use XCB on Ubuntu while its 32-bit support
// remains woefully incomplete.
+#include "base/thread.h"
#include "chrome/common/x11_util.h"
#include "chrome/common/x11_util_internal.h"
@@ -98,6 +99,10 @@ bool QueryRenderSupport(Display* dpy) {
return render_supported;
}
+int GetDefaultScreen(Display* display) {
+ return XDefaultScreen(display);
+}
+
XID GetX11RootWindow() {
return GDK_WINDOW_XID(gdk_get_default_root_window());
}
@@ -106,6 +111,10 @@ XID GetX11WindowFromGtkWidget(GtkWidget* widget) {
return GDK_WINDOW_XID(widget->window);
}
+XID GetX11WindowFromGdkWindow(GdkWindow* window) {
+ return GDK_WINDOW_XID(window);
+}
+
void* GetVisualFromGtkWidget(GtkWidget* widget) {
return GDK_VISUAL_XVISUAL(gtk_widget_get_visual(widget));
}
@@ -219,4 +228,25 @@ void FreePixmap(Display* display, XID pixmap) {
XFreePixmap(display, pixmap);
}
+// Called on BACKGROUND_X11 thread.
+Display* GetSecondaryDisplay() {
+ static Display* display = NULL;
+ if (!display) {
+ display = XOpenDisplay(NULL);
+ CHECK(display);
+ }
+
+ return display;
+}
+
+// Called on BACKGROUND_X11 thread.
+void GetWindowGeometry(int* x, int* y, unsigned* width, unsigned* height,
+ XID window) {
+ Window root_window;
+ unsigned border_width, depth;
+
+ CHECK(XGetGeometry(GetSecondaryDisplay(), window,
+ &root_window, x, y, width, height, &border_width, &depth));
+}
+
} // namespace x11_util