Bug 1173520 - Add support for test screenshots on GTK3. r=karlt
authorAndrew Comminos <acomminos@mozilla.com>
Wed, 10 Jun 2015 13:38:00 -0400
changeset 267913 63fd849c06a3ddfd17cc16969206cd30e11cc9fb
parent 267912 536bd9910bc2bb0dfa2997a16eaf5ba80a4148c4
child 267914 b901a06091560f80346396f43657b731b25b9a24
push id8157
push userjlund@mozilla.com
push dateMon, 29 Jun 2015 20:36:23 +0000
treeherdermozilla-aurora@d480e05bd276 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskarlt
bugs1173520
milestone41.0a1
Bug 1173520 - Add support for test screenshots on GTK3. r=karlt
testing/tools/screenshot/gdk-screenshot.cpp
--- a/testing/tools/screenshot/gdk-screenshot.cpp
+++ b/testing/tools/screenshot/gdk-screenshot.cpp
@@ -55,18 +55,17 @@ gboolean save_to_stdout(const gchar *buf
 
   return TRUE;
 }
 
 int main(int argc, char** argv)
 {
   gdk_init(&argc, &argv);
 
-// TODO GTK3
-#if defined(HAVE_LIBXSS) && (MOZ_WIDGET_GTK == 2)
+#if defined(HAVE_LIBXSS) && defined(MOZ_WIDGET_GTK)
   int event_base, error_base;
   Bool have_xscreensaver =
     XScreenSaverQueryExtension(GDK_DISPLAY(), &event_base, &error_base);
 
   if (!have_xscreensaver) {
     fprintf(stderr, "No XScreenSaver extension on display\n");
   } else {
     XScreenSaverInfo* info = XScreenSaverAllocInfo();
@@ -122,23 +121,26 @@ int main(int argc, char** argv)
 
     fprintf(stderr, "User input has been idle for %lu seconds\n", info->idle / 1000);
 
     XFree(info);
   }
 #endif
 
   GdkPixbuf* screenshot = nullptr;
-// TODO GTK3
+  GdkWindow* window = gdk_get_default_root_window();
 #if (MOZ_WIDGET_GTK == 2)
-  GdkWindow* window = gdk_get_default_root_window();
   screenshot = gdk_pixbuf_get_from_drawable(nullptr, window, nullptr,
                                             0, 0, 0, 0,
                                             gdk_screen_width(),
                                             gdk_screen_height());
+#else
+  screenshot = gdk_pixbuf_get_from_window(window, 0, 0,
+                                          gdk_window_get_width(window),
+                                          gdk_window_get_height(window));
 #endif
   if (!screenshot) {
     fprintf(stderr, "%s: failed to create screenshot GdkPixbuf\n", argv[0]);
     return 1;
   }
 
   GError* error = nullptr;
   if (argc > 1) {