From 86954a32c5af3819765ba9fc1acf05b2cef1d9a2 Mon Sep 17 00:00:00 2001 From: gb Date: Thu, 25 Mar 2010 13:54:06 +0000 Subject: [PATCH] Allow window creation with a specific visual (e.g. for GLX support). --- gst-libs/gst/vaapi/gstvaapiutils_x11.c | 20 +++++++++++++++++--- gst-libs/gst/vaapi/gstvaapiutils_x11.h | 2 +- gst-libs/gst/vaapi/gstvaapiwindow_x11.c | 2 +- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/gst-libs/gst/vaapi/gstvaapiutils_x11.c b/gst-libs/gst/vaapi/gstvaapiutils_x11.c index 46ed19097a..317609a609 100644 --- a/gst-libs/gst/vaapi/gstvaapiutils_x11.c +++ b/gst-libs/gst/vaapi/gstvaapiutils_x11.c @@ -55,23 +55,37 @@ static const int x11_event_mask = (KeyPressMask | ExposureMask | StructureNotifyMask); +/** + * x11_create_window: + * @display: an X11 #Display + * @width: the requested width, in pixels + * @height: the requested height, in pixels + * @vis: the request visual + * + * Creates a border-less window with the specified dimensions. If @vis + * is %NULL, the default visual for @display will be used. The default + * background color is black. + * + * Return value: the newly created X #Window. + */ Window -x11_create_window(Display *display, guint width, guint height) +x11_create_window(Display *display, guint width, guint height, Visual *vis) { Window root_window, window; int screen, depth; - Visual *vis; XSetWindowAttributes xswa; unsigned long xswa_mask; XWindowAttributes wattr; unsigned long black_pixel, white_pixel; screen = DefaultScreen(display); - vis = DefaultVisual(display, screen); root_window = RootWindow(display, screen); black_pixel = BlackPixel(display, screen); white_pixel = WhitePixel(display, screen); + if (!vis) + vis = DefaultVisual(display, screen); + XGetWindowAttributes(display, root_window, &wattr); depth = wattr.depth; if (depth != 15 && depth != 16 && depth != 24 && depth != 32) diff --git a/gst-libs/gst/vaapi/gstvaapiutils_x11.h b/gst-libs/gst/vaapi/gstvaapiutils_x11.h index b66e5c165e..9ab013141a 100644 --- a/gst-libs/gst/vaapi/gstvaapiutils_x11.h +++ b/gst-libs/gst/vaapi/gstvaapiutils_x11.h @@ -32,7 +32,7 @@ int x11_untrap_errors(void) attribute_hidden; Window -x11_create_window(Display *display, guint width, guint height) +x11_create_window(Display *display, guint width, guint height, Visual *vis) attribute_hidden; gboolean diff --git a/gst-libs/gst/vaapi/gstvaapiwindow_x11.c b/gst-libs/gst/vaapi/gstvaapiwindow_x11.c index ffe1a3720f..2630836e2e 100644 --- a/gst-libs/gst/vaapi/gstvaapiwindow_x11.c +++ b/gst-libs/gst/vaapi/gstvaapiwindow_x11.c @@ -241,7 +241,7 @@ gst_vaapi_window_x11_create(GstVaapiWindow *window, guint *width, guint *height) priv->atom_NET_WM_STATE = atoms[0]; priv->atom_NET_WM_STATE_FULLSCREEN = atoms[1]; - xid = x11_create_window(dpy, *width, *height); + xid = x11_create_window(dpy, *width, *height, NULL); if (xid) XRaiseWindow(dpy, xid); GST_VAAPI_OBJECT_UNLOCK_DISPLAY(window);