[gnome-shell/wip/background-rework: 2/4] Util: add an accessor for getting still frame



commit d8bf97d1c42875c7de21cd90a0b202fd3fed3a5c
Author: Giovanni Campagna <gcampagna src gnome org>
Date:   Mon Dec 24 15:20:39 2012 +0100

    Util: add an accessor for getting still frame
    
    This gives us the state of the screen right when
    gnome-shell is starting, so we can use it for
    transition purposes.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=682429

 src/Makefile.am  |    2 +-
 src/shell-util.c |   40 ++++++++++++++++++++++++++++++++++++++++
 src/shell-util.h |    3 +++
 3 files changed, 44 insertions(+), 1 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index 0e035ba..852df89 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -291,7 +291,7 @@ libgnome_shell_la_LIBADD =		\
 libgnome_shell_la_CPPFLAGS = $(gnome_shell_cflags)
 
 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_LIBS = libgnome-shell.la
 Shell_0_1_gir_FILES = $(libgnome_shell_la_gir_sources)
diff --git a/src/shell-util.c b/src/shell-util.c
index 3821b3a..8a6d6c3 100644
--- a/src/shell-util.c
+++ b/src/shell-util.c
@@ -9,6 +9,8 @@
 #include <glib/gi18n-lib.h>
 #include <gtk/gtk.h>
 #include <gdk-pixbuf/gdk-pixbuf.h>
+#include <gdk/gdkx.h>
+#include <X11/Xatom.h>
 
 #ifdef HAVE__NL_TIME_FIRST_WEEKDAY
 #include <langinfo.h>
@@ -430,3 +432,41 @@ shell_util_create_pixbuf_from_data (const guchar      *data,
                                    bits_per_sample, width, height, rowstride,
                                    (GdkPixbufDestroyNotify) g_free, NULL);
 }
+
+Pixmap
+shell_util_get_still_frame (void)
+{
+  Display *display;
+  Pixmap pixmap;
+  Window rootwin;
+  GC gc;
+  XGCValues values;
+  int width, height, depth;
+
+  display = gdk_x11_get_default_xdisplay ();
+  rootwin = gdk_x11_get_default_root_xwindow ();
+
+  width = DisplayWidth (display, gdk_x11_get_default_screen ());
+  height = DisplayHeight (display, gdk_x11_get_default_screen ());
+  depth = DefaultDepth (display, gdk_x11_get_default_screen ());
+  pixmap = XCreatePixmap (display,
+                          rootwin,
+                          width, height, depth);
+
+  values.function = GXcopy;
+  values.plane_mask = AllPlanes;
+  values.fill_style = FillSolid;
+  values.subwindow_mode = IncludeInferiors;
+
+  gc = XCreateGC (display,
+                  rootwin,
+                  GCFunction | GCPlaneMask | GCFillStyle | GCSubwindowMode,
+                  &values);
+
+  XCopyArea (display,
+             rootwin, pixmap, gc, 0, 0,
+             width, height, 0, 0);
+
+  XFreeGC (display, gc);
+  return pixmap;
+}
diff --git a/src/shell-util.h b/src/shell-util.h
index 41ba96f..0476cbd 100644
--- a/src/shell-util.h
+++ b/src/shell-util.h
@@ -7,6 +7,7 @@
 #include <clutter/clutter.h>
 #include <libsoup/soup.h>
 #include <gdk-pixbuf/gdk-pixbuf.h>
+#include <gdk/gdkx.h>
 
 G_BEGIN_DECLS
 
@@ -46,6 +47,8 @@ GdkPixbuf *shell_util_create_pixbuf_from_data (const guchar      *data,
                                                int                height,
                                                int                rowstride);
 
+Pixmap  shell_util_get_still_frame            (void);
+
 G_END_DECLS
 
 #endif /* __SHELL_UTIL_H__ */



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]