From c93d98b646a9a4fce3052260a1f08808d62d7155 Mon Sep 17 00:00:00 2001 From: Ray Strode Date: Fri, 27 Nov 2009 18:27:53 -0500 Subject: [PATCH] daemon: save root window to pixmap at _XROOTPMAP_ID This combined with starting the X server with -background none will give distros using plymouth (or potentially other boot splashes) a a nice fade transition when g-s-d starts. https://bugzilla.gnome.org/show_bug.cgi?id=572173 --- daemon/gdm-simple-slave.c | 8 +++++ daemon/gdm-slave.c | 72 +++++++++++++++++++++++++++++++++++++++++++++ daemon/gdm-slave.h | 1 + 3 files changed, 81 insertions(+), 0 deletions(-) diff --git a/daemon/gdm-simple-slave.c b/daemon/gdm-simple-slave.c index 9d1347a..fc8649c 100644 --- a/daemon/gdm-simple-slave.c +++ b/daemon/gdm-simple-slave.c @@ -1215,6 +1215,14 @@ setup_server (GdmSimpleSlave *slave) /* Set the initial keyboard layout to something reasonable */ gdm_slave_set_initial_keyboard_layout (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 a5ce62f..53633c0 100644 --- a/daemon/gdm-slave.c +++ b/daemon/gdm-slave.c @@ -43,6 +43,7 @@ #include #include /* for Display */ +#include /* for XA_PIXMAP */ #include /* for watch cursor */ #include #include @@ -364,6 +365,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_initial_keyboard_layout (GdmSlave *slave) { diff --git a/daemon/gdm-slave.h b/daemon/gdm-slave.h index 7af20ed..aaaa8f2 100644 --- a/daemon/gdm-slave.h +++ b/daemon/gdm-slave.h @@ -78,6 +78,7 @@ void gdm_slave_set_initial_keyboard_layout (GdmSlave *slave); void gdm_slave_set_initial_cursor_position (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); -- 1.7.8.6