Util: add an accessor for the root background pixmap

The background of the root window is accessible as the _XROOTPMAP_ID
property on the root window. Given that the root window is always
fully covered by the Composite Overlay Window, we use that as temporary
storage while the COW is not mapped, that is, before the GDM greeter
is started and between killing the greeter and starting GDM from the
session.

https://bugzilla.gnome.org/show_bug.cgi?id=682429
This commit is contained in:
Giovanni Campagna 2012-12-24 15:20:39 +01:00
parent 8b2864ee70
commit d457073c10
3 changed files with 59 additions and 1 deletions

View File

@ -292,7 +292,7 @@ libgnome_shell_la_LIBADD = \
libgnome_shell_la_CPPFLAGS = $(gnome_shell_cflags) libgnome_shell_la_CPPFLAGS = $(gnome_shell_cflags)
Shell-0.1.gir: libgnome-shell.la St-1.0.gir Shell-0.1.gir: libgnome-shell.la St-1.0.gir
Shell_0_1_gir_INCLUDES = Clutter-1.0 ClutterX11-1.0 Meta-3.0 TelepathyGLib-0.12 TelepathyLogger-0.2 Soup-2.4 GMenu-3.0 NetworkManager-1.0 NMClient-1.0 Shell_0_1_gir_INCLUDES = Clutter-1.0 ClutterX11-1.0 Meta-3.0 TelepathyGLib-0.12 TelepathyLogger-0.2 Soup-2.4 GMenu-3.0 NetworkManager-1.0 NMClient-1.0 xlib-2.0
Shell_0_1_gir_CFLAGS = $(libgnome_shell_la_CPPFLAGS) -I $(srcdir) Shell_0_1_gir_CFLAGS = $(libgnome_shell_la_CPPFLAGS) -I $(srcdir)
Shell_0_1_gir_LIBS = libgnome-shell.la Shell_0_1_gir_LIBS = libgnome-shell.la
Shell_0_1_gir_FILES = $(libgnome_shell_la_gir_sources) Shell_0_1_gir_FILES = $(libgnome_shell_la_gir_sources)

View File

@ -9,6 +9,8 @@
#include <glib/gi18n-lib.h> #include <glib/gi18n-lib.h>
#include <gtk/gtk.h> #include <gtk/gtk.h>
#include <gdk-pixbuf/gdk-pixbuf.h> #include <gdk-pixbuf/gdk-pixbuf.h>
#include <gdk/gdkx.h>
#include <X11/Xatom.h>
#ifdef HAVE__NL_TIME_FIRST_WEEKDAY #ifdef HAVE__NL_TIME_FIRST_WEEKDAY
#include <langinfo.h> #include <langinfo.h>
@ -430,3 +432,56 @@ shell_util_create_pixbuf_from_data (const guchar *data,
bits_per_sample, width, height, rowstride, bits_per_sample, width, height, rowstride,
(GdkPixbufDestroyNotify) g_free, NULL); (GdkPixbufDestroyNotify) g_free, NULL);
} }
Pixmap
shell_util_get_root_background (void)
{
Display *display;
Pixmap pixmap;
Window rootwin;
Atom xrootpmap;
Atom actual_type;
int actual_format;
unsigned long n_items;
unsigned long bytes_after;
unsigned char *buffer;
display = gdk_x11_get_default_xdisplay ();
xrootpmap = gdk_x11_atom_to_xatom (gdk_atom_intern_static_string ("_XROOTPMAP_ID"));
rootwin = gdk_x11_get_default_root_xwindow ();
gdk_error_trap_push ();
actual_type = None;
buffer = NULL;
if (XGetWindowProperty (display, rootwin, xrootpmap,
0, G_MAXLONG,
False, XA_PIXMAP, &actual_type, &actual_format,
&n_items,
&bytes_after,
&buffer) != Success ||
actual_type == None)
{
if (buffer)
XFree (buffer);
gdk_error_trap_pop_ignored ();
return FALSE;
}
if (gdk_error_trap_pop () != Success ||
n_items == 0 ||
actual_type != XA_PIXMAP ||
actual_format != 32)
{
if (buffer)
XFree (buffer);
return FALSE;
}
pixmap = *((Pixmap*) buffer);
XFree (buffer);
return pixmap;
}

View File

@ -7,6 +7,7 @@
#include <clutter/clutter.h> #include <clutter/clutter.h>
#include <libsoup/soup.h> #include <libsoup/soup.h>
#include <gdk-pixbuf/gdk-pixbuf.h> #include <gdk-pixbuf/gdk-pixbuf.h>
#include <gdk/gdkx.h>
G_BEGIN_DECLS G_BEGIN_DECLS
@ -46,6 +47,8 @@ GdkPixbuf *shell_util_create_pixbuf_from_data (const guchar *data,
int height, int height,
int rowstride); int rowstride);
Pixmap shell_util_get_root_background (void);
G_END_DECLS G_END_DECLS
#endif /* __SHELL_UTIL_H__ */ #endif /* __SHELL_UTIL_H__ */