[metacity] ui: update meta_ui_get_pixbuf_from_pixmap



commit 758902aef22629943738241cea1f597b6db4b18e
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date:   Thu Feb 19 01:14:53 2015 +0200

    ui: update meta_ui_get_pixbuf_from_pixmap

 src/ui/ui.c |   34 ++++++++++++++++------------------
 1 files changed, 16 insertions(+), 18 deletions(-)
---
diff --git a/src/ui/ui.c b/src/ui/ui.c
index 9ee7ea6..e0ffa8b 100644
--- a/src/ui/ui.c
+++ b/src/ui/ui.c
@@ -925,29 +925,27 @@ meta_ui_get_direction (void)
 }
 
 GdkPixbuf *
-meta_ui_get_pixbuf_from_pixmap (Pixmap   pmap)
+meta_ui_get_pixbuf_from_pixmap (Pixmap pixmap)
 {
-  GdkPixmap *gpmap;
-  GdkScreen *screen;
+  Display *display;
+  Window root;
+  int x, y;
+  unsigned int width, height, border, depth;
+  XWindowAttributes attrs;
+  cairo_surface_t *surface;
   GdkPixbuf *pixbuf;
-  GdkColormap *cmap;
-  int width, height, depth;
 
-  gpmap = gdk_pixmap_foreign_new (pmap);
-  screen = gdk_drawable_get_screen (gpmap);
+  display = GDK_DISPLAY_XDISPLAY (gdk_display_get_default ());
 
-  gdk_drawable_get_size (GDK_DRAWABLE (gpmap), &width, &height);
-  
-  depth = gdk_drawable_get_depth (GDK_DRAWABLE (gpmap));
-  if (depth <= 24)
-    cmap = gdk_screen_get_system_colormap (screen);
-  else
-    cmap = gdk_screen_get_rgba_colormap (screen);
-  
-  pixbuf = gdk_pixbuf_get_from_drawable (NULL, gpmap, cmap, 0, 0, 0, 0,
-                                         width, height);
+  if (!XGetGeometry (display, pixmap, &root, &x, &y, &width, &height, &border, &depth))
+    return NULL;
+
+  if (!XGetWindowAttributes (display, root, &attrs))
+    return NULL;
 
-  g_object_unref (gpmap);
+  surface = cairo_xlib_surface_create (display, pixmap, attrs.visual, width, height);
+  pixbuf = gdk_pixbuf_get_from_surface (surface, x, y, width, height);
+  cairo_surface_destroy (surface);
 
   return pixbuf;
 }


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