diff options
author | Benjamin Otte <otte@redhat.com> | 2010-04-19 01:18:39 +0200 |
---|---|---|
committer | Benjamin Otte <otte@redhat.com> | 2010-04-23 23:33:58 +0200 |
commit | da34cf0b77422abe739ac4b6e060d68956dfedbb (patch) | |
tree | 1f9dabef4bd8346f6f93030c8c5aed8e59e2536c | |
parent | 0bec1672945ac11c9a6d45aef6a19a1e2e662f70 (diff) |
xlib: Add cairo_xlib_device API
cairo_xlib_device_create() and cairo_xlib_device_get_display() were
added and used as replacements for the previous private APIs.
-rw-r--r-- | src/cairo-xlib-display.c | 26 | ||||
-rw-r--r-- | src/cairo-xlib-private.h | 3 | ||||
-rw-r--r-- | src/cairo-xlib-screen.c | 2 | ||||
-rw-r--r-- | src/cairo-xlib-surface.c | 2 | ||||
-rw-r--r-- | src/cairo-xlib.h | 6 |
5 files changed, 33 insertions, 6 deletions
diff --git a/src/cairo-xlib-display.c b/src/cairo-xlib-display.c index 5834cef2..fdb20bf2 100644 --- a/src/cairo-xlib-display.c +++ b/src/cairo-xlib-display.c @@ -272,7 +272,7 @@ static const cairo_device_backend_t _cairo_xlib_device_backend = { * Returns: the device belonging to @dpy **/ cairo_device_t * -_cairo_xlib_device_create (Display *dpy) +cairo_xlib_device_create (Display *dpy) { cairo_xlib_display_t *display; cairo_xlib_display_t **prev; @@ -451,6 +451,30 @@ UNLOCK: return device; } +/** + * cairo_xlib_device_get_display: + * @device: The device + * + * Gets the #Display in use by @device. If the display has been closed + * already, %NULL is returned. + * + * Returns: The #Display in use by the given @device or %NULL. + **/ +cairo_public Display * +cairo_xlib_device_get_display (cairo_device_t *device) +{ + cairo_xlib_display_t *display; + + if (device->backend->type != CAIRO_DEVICE_TYPE_XLIB) { + _cairo_error_throw (CAIRO_STATUS_DEVICE_TYPE_MISMATCH); + return NULL; + } + + display = (cairo_xlib_display_t *) device; + + return display->display; +} + void _cairo_xlib_add_close_display_hook (cairo_xlib_display_t *display, cairo_xlib_hook_t *hook) diff --git a/src/cairo-xlib-private.h b/src/cairo-xlib-private.h index d8acf9a9..8bf28668 100644 --- a/src/cairo-xlib-private.h +++ b/src/cairo-xlib-private.h @@ -112,9 +112,6 @@ struct _cairo_xlib_screen { cairo_array_t visuals; }; -cairo_private cairo_device_t * -_cairo_xlib_device_create (Display *display); - cairo_private void _cairo_xlib_display_add_screen (cairo_xlib_display_t *display, cairo_xlib_screen_t *screen); diff --git a/src/cairo-xlib-screen.c b/src/cairo-xlib-screen.c index 810e484b..e5bbd53f 100644 --- a/src/cairo-xlib-screen.c +++ b/src/cairo-xlib-screen.c @@ -323,7 +323,7 @@ _cairo_xlib_screen_get (Display *dpy, cairo_xlib_screen_t *info; cairo_status_t status; - device = _cairo_xlib_device_create (dpy); + device = cairo_xlib_device_create (dpy); status = device->status; if (unlikely (status)) goto CLEANUP_DEVICE; diff --git a/src/cairo-xlib-surface.c b/src/cairo-xlib-surface.c index cf7497a6..4a5b88cd 100644 --- a/src/cairo-xlib-surface.c +++ b/src/cairo-xlib-surface.c @@ -3467,7 +3467,7 @@ cairo_xlib_surface_get_display (cairo_surface_t *abstract_surface) return NULL; } - return ((cairo_xlib_display_t *) abstract_surface->device)->display; + return cairo_xlib_device_get_display (abstract_surface->device); } /** diff --git a/src/cairo-xlib.h b/src/cairo-xlib.h index 29e9f100..3bbb0e68 100644 --- a/src/cairo-xlib.h +++ b/src/cairo-xlib.h @@ -45,6 +45,12 @@ CAIRO_BEGIN_DECLS +cairo_public cairo_device_t * +cairo_xlib_device_create (Display *dpy); + +cairo_public Display * +cairo_xlib_device_get_display (cairo_device_t *device); + cairo_public cairo_surface_t * cairo_xlib_surface_create (Display *dpy, Drawable drawable, |