]> Pileus Git - ~andy/gtk/blobdiff - docs/tools/shooter.c
wayland: Remove non-existing gdkscreen-wayland.h from SOURCES
[~andy/gtk] / docs / tools / shooter.c
index f8df8b57539a32ad79c2d911c61d4b5be6201b4c..fa7e8459c227d732ba5c352ef1b73a2569c1fb30 100644 (file)
@@ -33,7 +33,7 @@ find_toplevel_window (Window xid)
 
   do
     {
-      if (XQueryTree (GDK_DISPLAY (), xid, &root,
+      if (XQueryTree (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), xid, &root,
                      &parent, &children, &nchildren) == 0)
        {
          g_warning ("Couldn't find window manager window");
@@ -82,7 +82,7 @@ remove_shaped_area (GdkPixbuf *pixbuf,
                           gdk_pixbuf_get_height (pixbuf));
   
   gdk_pixbuf_fill (retval, 0);
-  rectangles = XShapeGetRectangles (GDK_DISPLAY (), window,
+  rectangles = XShapeGetRectangles (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), window,
                                    ShapeBounding, &rectangle_count, &rectangle_order);
 
   for (i = 0; i < rectangle_count; i++)
@@ -130,7 +130,7 @@ take_window_shot (Window   child,
   GdkPixbuf *tmp, *tmp2;
   GdkPixbuf *retval;
 
-  disp = GDK_DISPLAY ();
+  disp = GDK_DISPLAY_XDISPLAY (gdk_display_get_default ());
   w = GDK_ROOT_WINDOW ();
 
   if (include_decoration)
@@ -138,9 +138,10 @@ take_window_shot (Window   child,
   else
     xid = child;
 
-  window = gdk_window_foreign_new (xid);
+  window = gdk_x11_window_foreign_new_for_display (gdk_display_get_default (), xid);
 
-  gdk_drawable_get_size (window, &width, &height);
+  width = gdk_window_get_width (window);
+  height = gdk_window_get_height (window);
   gdk_window_get_origin (window, &x_orig, &y_orig);
 
   if (x_orig < 0)
@@ -163,8 +164,8 @@ take_window_shot (Window   child,
   if (y_orig + height > gdk_screen_height ())
     height = gdk_screen_height () - y_orig;
 
-  tmp = gdk_pixbuf_get_from_drawable (NULL, window, NULL,
-                                     x, y, 0, 0, width, height);
+  tmp = gdk_pixbuf_get_from_window (window,
+                                   x, y, width, height);
 
   if (include_decoration)
     tmp2 = remove_shaped_area (tmp, xid);
@@ -193,6 +194,7 @@ int main (int argc, char **argv)
 
   for (node = toplevels; node; node = g_list_next (node))
     {
+      GtkAllocation allocation;
       GdkWindow *window;
       WidgetInfo *info;
       XID id;
@@ -202,12 +204,14 @@ int main (int argc, char **argv)
 
       gtk_widget_show (info->window);
 
-      window = info->window->window;
+      window = gtk_widget_get_window (info->window);
+      gtk_widget_get_allocation (info->window, &allocation);
 
       gtk_widget_show_now (info->window);
       gtk_widget_queue_draw_area (info->window,
-        info->window->allocation.x, info->window->allocation.y,
-        info->window->allocation.width, info->window->allocation.height);
+                                  allocation.x, allocation.y,
+                                  allocation.width, allocation.height);
+      gdk_window_process_updates (window, TRUE);
 
       while (gtk_events_pending ())
        {
@@ -220,7 +224,7 @@ int main (int argc, char **argv)
          gtk_main_iteration ();
        }
 
-      id = gdk_x11_drawable_get_xid (GDK_DRAWABLE (window));
+      id = gdk_x11_window_get_xid (window);
       screenshot = take_window_shot (id, info->include_decorations);
       filename = g_strdup_printf ("./%s.png", info->name);
       gdk_pixbuf_save (screenshot, filename, "png", NULL, NULL);