summaryrefslogtreecommitdiff
path: root/src/cairo-xlib-xcb-surface.c
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2010-05-08 18:20:11 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2010-05-08 18:24:48 +0100
commit9d863cd3942c3086c24d67305f7a5892604d0eeb (patch)
treea8251b12822c03c7b05926b3d45bd46f6c5045e6 /src/cairo-xlib-xcb-surface.c
parent448d3571088463fc61641badcdfdc8c0002ae12a (diff)
downloadcairo-9d863cd3942c3086c24d67305f7a5892604d0eeb.tar.gz
xcb: Find the correct xcb_screen_t for faking Screen
When choosing the xcb_screen_t to use for the xlib-xcb backing surface, it helps if it matches the screen used to generate similar surfaces and snapshots - otherwise we end up pulling the image back from the XServer every time we want to use the Picture.
Diffstat (limited to 'src/cairo-xlib-xcb-surface.c')
-rw-r--r--src/cairo-xlib-xcb-surface.c23
1 files changed, 21 insertions, 2 deletions
diff --git a/src/cairo-xlib-xcb-surface.c b/src/cairo-xlib-xcb-surface.c
index 4db129eb8..7e674bf07 100644
--- a/src/cairo-xlib-xcb-surface.c
+++ b/src/cairo-xlib-xcb-surface.c
@@ -342,6 +342,21 @@ cairo_xlib_surface_create_for_bitmap (Display *dpy,
}
#if CAIRO_HAS_XLIB_XRENDER_SURFACE
+static xcb_screen_t *
+_cairo_xcb_screen_from_root (xcb_connection_t *connection,
+ xcb_window_t id)
+{
+ xcb_depth_iterator_t d;
+ xcb_screen_iterator_t s;
+
+ s = xcb_setup_roots_iterator (xcb_get_setup (connection));
+ for (; s.rem; xcb_screen_next (&s)) {
+ if (s.data->root == id)
+ return s.data;
+ }
+
+ return NULL;
+}
cairo_surface_t *
cairo_xlib_surface_create_with_xrender_format (Display *dpy,
Drawable drawable,
@@ -351,6 +366,8 @@ cairo_xlib_surface_create_with_xrender_format (Display *dpy,
int height)
{
xcb_render_pictforminfo_t xcb_format;
+ xcb_connection_t *connection;
+ xcb_screen_t *screen;
xcb_format.id = format->id;
xcb_format.type = format->type;
@@ -365,9 +382,11 @@ cairo_xlib_surface_create_with_xrender_format (Display *dpy,
xcb_format.direct.alpha_mask = format->direct.alphaMask;
xcb_format.colormap = format->colormap;
+ connection = XGetXCBConnection (dpy);
+ screen = _cairo_xcb_screen_from_root (connection, (xcb_window_t) scr->root);
+
return _cairo_xlib_xcb_surface_create (dpy, scr, NULL, format,
- cairo_xcb_surface_create_with_xrender_format (XGetXCBConnection (dpy),
- (xcb_screen_t *) scr,
+ cairo_xcb_surface_create_with_xrender_format (connection, screen,
drawable,
&xcb_format,
width, height));