summaryrefslogtreecommitdiffstats
path: root/chrome/common/x11_util.h
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.h
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.h')
-rw-r--r--chrome/common/x11_util.h95
1 files changed, 61 insertions, 34 deletions
diff --git a/chrome/common/x11_util.h b/chrome/common/x11_util.h
index 4800a69..aef133f 100644
--- a/chrome/common/x11_util.h
+++ b/chrome/common/x11_util.h
@@ -11,48 +11,75 @@
// we use a void* for Visual*). The Xlib headers are highly polluting so we try
// hard to limit their spread into the rest of the code.
+typedef struct _GdkDrawable GdkWindow;
typedef struct _GtkWidget GtkWidget;
typedef unsigned long XID;
typedef struct _XDisplay Display;
+namespace base {
+class Thread;
+}
+
namespace gfx {
class Size;
}
namespace x11_util {
- // These functions cache their results and must be called from the UI thread.
- // Currently they don't support multiple screens/displays.
-
- // Return an X11 connection for the current, primary display.
- Display* GetXDisplay();
- // Return true iff the connection supports X shared memory
- bool QuerySharedMemorySupport(Display* dpy);
- // Return true iff the display supports Xrender
- bool QueryRenderSupport(Display* dpy);
-
- // These functions do not cache their results
-
- // Get the X window id for the default root window
- XID GetX11RootWindow();
- // Get the X window id for the given GTK widget.
- XID GetX11WindowFromGtkWidget(GtkWidget*);
- // Get a Visual from the given widget. Since we don't include the Xlib
- // headers, this is returned as a void*.
- void* GetVisualFromGtkWidget(GtkWidget*);
- // Return the number of bits-per-pixel for a pixmap of the given depth
- int BitsPerPixelForPixmapDepth(Display*, int depth);
-
- // Return a handle to a server side pixmap. |shared_memory_key| is a SysV
- // IPC key. The shared memory region must contain 32-bit pixels.
- XID AttachSharedMemory(Display* display, int shared_memory_support);
- void DetachSharedMemory(Display* display, XID shmseg);
-
- // Return a handle to an XRender picture where |pixmap| is a handle to a
- // pixmap containing Skia ARGB data.
- XID CreatePictureFromSkiaPixmap(Display* display, XID pixmap);
-
- void FreePicture(Display* display, XID picture);
- void FreePixmap(Display* display, XID pixmap);
-};
+
+// These functions use the GDK default display and this /must/ be called from
+// the UI thread. Thus, they don't support multiple displays.
+
+// These functions cache their results.
+
+// Return an X11 connection for the current, primary display.
+Display* GetXDisplay();
+// Return true iff the connection supports X shared memory
+bool QuerySharedMemorySupport(Display* dpy);
+// Return true iff the display supports Xrender
+bool QueryRenderSupport(Display* dpy);
+// Return the default screen number for the display
+int GetDefaultScreen(Display* display);
+
+// These functions do not cache their results
+
+// Get the X window id for the default root window
+XID GetX11RootWindow();
+// Get the X window id for the given GTK widget.
+XID GetX11WindowFromGtkWidget(GtkWidget*);
+XID GetX11WindowFromGdkWindow(GdkWindow*);
+// Get a Visual from the given widget. Since we don't include the Xlib
+// headers, this is returned as a void*.
+void* GetVisualFromGtkWidget(GtkWidget*);
+// Return the number of bits-per-pixel for a pixmap of the given depth
+int BitsPerPixelForPixmapDepth(Display*, int depth);
+
+// Return a handle to a server side pixmap. |shared_memory_key| is a SysV
+// IPC key. The shared memory region must contain 32-bit pixels.
+XID AttachSharedMemory(Display* display, int shared_memory_support);
+void DetachSharedMemory(Display* display, XID shmseg);
+
+// Return a handle to an XRender picture where |pixmap| is a handle to a
+// pixmap containing Skia ARGB data.
+XID CreatePictureFromSkiaPixmap(Display* display, XID pixmap);
+
+void FreePicture(Display* display, XID picture);
+void FreePixmap(Display* display, XID pixmap);
+
+// These functions are for performing X opertions outside of the UI thread.
+
+// Return the Display for the secondary X connection. We keep a second
+// connection around for making X requests outside of the UI thread.
+// This function may only be called from the BACKGROUND_X11 thread.
+Display* GetSecondaryDisplay();
+
+// Since one cannot include both WebKit header and Xlib headers in the same
+// file (due to collisions), we wrap all the Xlib functions that we need here.
+// These functions must be called on the BACKGROUND_X11 thread since they
+// reference GetSecondaryDisplay().
+
+void GetWindowGeometry(int* x, int* y, unsigned* width, unsigned* height,
+ XID window);
+
+} // namespace x11_util
#endif // CHROME_COMMON_X11_UTIL_H_