add support for "include inferiors" xlib surfaces --- commit 223405fe5c4009ebfd36322b359a4212b90fc47c tree d3e047a10a5e38b511aac0f9ac99dce2aa5d12db parent 5aaf584bf44d762af5e486f21a037eb0cc6e1197 author Ryan Lortie Sun, 18 Mar 2007 12:40:57 -0400 committer Ryan Lortie Sun, 18 Mar 2007 12:40:57 -0400 src/cairo-xlib-surface.c | 103 +++++++++++++++++++++++++++++++++++++++++++++- src/cairo-xlib.h | 7 +++ 2 files changed, 108 insertions(+), 2 deletions(-) diff --git a/src/cairo-xlib-surface.c b/src/cairo-xlib-surface.c index 49bdaae..9f3f583 100644 --- a/src/cairo-xlib-surface.c +++ b/src/cairo-xlib-surface.c @@ -121,6 +121,7 @@ struct _cairo_xlib_surface { int depth; Picture dst_picture, src_picture; + int include_inferiors; cairo_bool_t have_clip_rects; XRectangle *clip_rects; @@ -689,10 +690,21 @@ static void _cairo_xlib_surface_ensure_src_picture (cairo_xlib_surface_t *surface) { if (!surface->src_picture) + { + XRenderPictureAttributes pa; + int mask = 0; + + if (surface->include_inferiors) + { + pa.subwindow_mode = IncludeInferiors; + mask |= CPSubwindowMode; + } + surface->src_picture = XRenderCreatePicture (surface->dpy, surface->drawable, surface->xrender_format, - 0, NULL); + mask, &pa); + } } static void @@ -719,10 +731,19 @@ static void _cairo_xlib_surface_ensure_dst_picture (cairo_xlib_surface_t *surface) { if (!surface->dst_picture) { + XRenderPictureAttributes pa; + int mask = 0; + + if (surface->include_inferiors) + { + pa.subwindow_mode = IncludeInferiors; + mask |= CPSubwindowMode; + } + surface->dst_picture = XRenderCreatePicture (surface->dpy, surface->drawable, surface->xrender_format, - 0, NULL); + mask, &pa); _cairo_xlib_surface_set_picture_clip_rects (surface); } @@ -2053,6 +2074,7 @@ cairo_xlib_surface_set_size (cairo_surface_t *abstract_surface, surface->width = width; surface->height = height; } + /** * cairo_xlib_surface_set_drawable: * @surface: a #cairo_surface_t for the XLib backend @@ -2101,6 +2123,59 @@ cairo_xlib_surface_set_drawable (cairo_surface_t *abstract_surface, } /** + * cairo_xlib_surface_set_include_inferiors: + * @surface: a #cairo_surface_t for the XLib backend + * @include_inferiors: if child windows should be included + * in draw ops + * + * Sets the surface as "include inferiors" or not. + * + * For destinations of draws this means that child windows + * that would normally clip the draw are simply drawn over + * top of. + * + * For sources of draws this means that child windows that + * would normally clip the content of the parent window have + * their image data include as part of that content. + * + * This flag corresponds to the XRender IncludeInferiors + * attribute. + * + * Since: 1.4 + **/ +void +cairo_xlib_surface_set_include_inferiors (cairo_surface_t *abstract_surface, + int include_inferiors) +{ + cairo_xlib_surface_t *surface = (cairo_xlib_surface_t *)abstract_surface; + + if (! _cairo_surface_is_xlib (abstract_surface)) { + _cairo_surface_set_error (abstract_surface, CAIRO_STATUS_SURFACE_TYPE_MISMATCH); + return; + } + + include_inferiors = include_inferiors != 0; + + if (surface->owns_pixmap) { + surface->include_inferiors = include_inferiors; + return; + } + + if (surface->include_inferiors != include_inferiors) { + if (surface->dst_picture) + XRenderFreePicture (surface->dpy, surface->dst_picture); + + if (surface->src_picture) + XRenderFreePicture (surface->dpy, surface->src_picture); + + surface->dst_picture = None; + surface->src_picture = None; + + surface->include_inferiors = include_inferiors; + } +} + +/** * cairo_xlib_surface_get_display: * @surface: a #cairo_xlib_surface_t * @@ -2147,6 +2222,30 @@ cairo_xlib_surface_get_drawable (cairo_surface_t *abstract_surface) } /** + * cairo_xlib_surface_get_include_inferiors: + * @surface: a #cairo_xlib_surface_t + * + * Returns if the surface includes inferiors or not. + * See cairo_xlib_surface_set_include_inferiors(). + * + * Return value: 1 if the surface includes inferiors. + * + * Since: 1.4 + **/ +int +cairo_xlib_surface_get_include_inferiors (cairo_surface_t *abstract_surface) +{ + cairo_xlib_surface_t *surface = (cairo_xlib_surface_t *) abstract_surface; + + if (! _cairo_surface_is_xlib (abstract_surface)) { + _cairo_error (CAIRO_STATUS_SURFACE_TYPE_MISMATCH); + return 0; + } + + return surface->include_inferiors; +} + +/** * cairo_xlib_surface_get_screen: * @surface: a #cairo_xlib_surface_t * diff --git a/src/cairo-xlib.h b/src/cairo-xlib.h index ad92b39..c7e9db2 100644 --- a/src/cairo-xlib.h +++ b/src/cairo-xlib.h @@ -70,12 +70,19 @@ cairo_xlib_surface_set_drawable (cairo_surface_t *surface, int width, int height); +cairo_public void +cairo_xlib_surface_set_include_inferiors (cairo_surface_t *surface, + int include_inferiors); + cairo_public Display * cairo_xlib_surface_get_display (cairo_surface_t *surface); cairo_public Drawable cairo_xlib_surface_get_drawable (cairo_surface_t *surface); +cairo_public int +cairo_xlib_surface_get_include_inferiors (cairo_surface_t *surface); + cairo_public Screen * cairo_xlib_surface_get_screen (cairo_surface_t *surface);