# # Description: Saves the root window background so that other things like gnome-settings-daemon can access it. Taken from the plymouth-integration branch of Upstream GIT. # From 9768d9e2783de7e836421d9645070bb1917800dd Mon Sep 17 00:00:00 2001 From: Ray Strode Date: Fri, 27 Nov 2009 23:27:53 +0000 Subject: Save root window to pixmap at _XROOTPMAP_ID This combined with starting the X server with -nr will give us a nice fade transition when g-s-d starts --- diff --git a/daemon/gdm-simple-slave.c b/daemon/gdm-simple-slave.c index 2cbb568..66d1c77 100644 --- a/daemon/gdm-simple-slave.c +++ b/daemon/gdm-simple-slave.c @@ -863,6 +863,15 @@ setup_server (GdmSimpleSlave *slave) { /* Set the busy cursor */ gdm_slave_set_busy_cursor (GDM_SLAVE (slave)); + + /* The root window has a background that may be useful + * to cross fade or transition from when setting the + * login screen background. We read it here, and stuff + * it into the standard _XROOTPMAP_ID root window property, + * so gnome-settings-daemon can get at it. + */ + gdm_slave_save_root_windows (GDM_SLAVE (slave)); + } static void diff --git a/daemon/gdm-slave.c b/daemon/gdm-slave.c index e11e16c..da86f77 100644 --- a/daemon/gdm-slave.c +++ b/daemon/gdm-slave.c @@ -42,6 +42,7 @@ #include #include /* for Display */ +#include /* for XA_PIXMAP */ #include /* for watch cursor */ #include "gdm-common.h" @@ -351,6 +352,77 @@ gdm_slave_run_script (GdmSlave *slave, return ret; } +static void +gdm_slave_save_root_window_of_screen (GdmSlave *slave, + Atom id_atom, + int screen_number) +{ + Window root_window; + GC gc; + XGCValues values; + Pixmap pixmap; + int width, height, depth; + + root_window = RootWindow (slave->priv->server_display, + screen_number); + + width = DisplayWidth (slave->priv->server_display, screen_number); + height = DisplayHeight (slave->priv->server_display, screen_number); + depth = DefaultDepth (slave->priv->server_display, screen_number); + pixmap = XCreatePixmap (slave->priv->server_display, + root_window, + width, height, depth); + + values.function = GXcopy; + values.plane_mask = AllPlanes; + values.fill_style = FillSolid; + values.subwindow_mode = IncludeInferiors; + + gc = XCreateGC (slave->priv->server_display, + root_window, + GCFunction | GCPlaneMask | GCFillStyle | GCSubwindowMode, + &values); + + if (XCopyArea (slave->priv->server_display, + root_window, pixmap, gc, 0, 0, + width, height, 0, 0)) { + + long pixmap_as_long; + + pixmap_as_long = (long) pixmap; + + XChangeProperty (slave->priv->server_display, + root_window, id_atom, XA_PIXMAP, + 32, PropModeReplace, (guchar *) &pixmap_as_long, + 1); + + } + + XFreeGC (slave->priv->server_display, gc); +} + +void +gdm_slave_save_root_windows (GdmSlave *slave) +{ + int i, number_of_screens; + Atom atom; + + number_of_screens = ScreenCount (slave->priv->server_display); + + atom = XInternAtom (slave->priv->server_display, + "_XROOTPMAP_ID", False); + + if (atom == 0) { + return; + } + + for (i = 0; i < number_of_screens; i++) { + gdm_slave_save_root_window_of_screen (slave, atom, i); + } + + XSync (slave->priv->server_display, False); +} + void gdm_slave_set_busy_cursor (GdmSlave *slave) { diff --git a/daemon/gdm-slave.h b/daemon/gdm-slave.h index af28b00..1652457 100644 --- a/daemon/gdm-slave.h +++ b/daemon/gdm-slave.h @@ -74,6 +74,7 @@ gboolean gdm_slave_switch_to_user_session (GdmSlave *slave, gboolean gdm_slave_connect_to_x11_display (GdmSlave *slave); void gdm_slave_set_busy_cursor (GdmSlave *slave); +void gdm_slave_save_root_windows (GdmSlave *slave); gboolean gdm_slave_run_script (GdmSlave *slave, const char *dir, const char *username); -- cgit v0.8.2