summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlberts Muktupāvels <alberts.muktupavels@gmail.com>2015-02-19 01:14:53 +0200
committerAlberts Muktupāvels <alberts.muktupavels@gmail.com>2015-02-19 01:14:53 +0200
commit758902aef22629943738241cea1f597b6db4b18e (patch)
tree86ef242c2988f33dcc948905cdc01325b3851753
parent89580e1eabaadedd322b2ab93cfd48db717edc77 (diff)
downloadmetacity-758902aef22629943738241cea1f597b6db4b18e.tar.gz
ui: update meta_ui_get_pixbuf_from_pixmap
-rw-r--r--src/ui/ui.c34
1 files changed, 16 insertions, 18 deletions
diff --git a/src/ui/ui.c b/src/ui/ui.c
index 9ee7ea60..e0ffa8b8 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;
}