http://www.jwz.org/xscreensaver/xscreensaver-5.12.tar.gz
[xscreensaver] / driver / xscreensaver-getimage.c
index 6790ee10f5fa9af510fb1027afcb87be29c6f3d0..856e05a6bc480ff37515f949e08d6b566b4de232 100644 (file)
@@ -1,4 +1,4 @@
-/* xscreensaver, Copyright (c) 2001-2006 by Jamie Zawinski <jwz@jwz.org>
+/* xscreensaver, Copyright (c) 2001-2008 by Jamie Zawinski <jwz@jwz.org>
  *
  * Permission to use, copy, modify, distribute, and sell this software and its
  * documentation for any purpose is hereby granted without fee, provided that
@@ -405,6 +405,20 @@ read_file_gdk (Screen *screen, Window window, Drawable drawable,
       int srcx, srcy, destx, desty, w2, h2;
       Bool bg_p = False;
 
+# ifdef HAVE_GDK_PIXBUF_APPLY_EMBEDDED_ORIENTATION
+      {
+        int ow = w, oh = h;
+        GdkPixbuf *opb = pb;
+        pb = gdk_pixbuf_apply_embedded_orientation (opb);
+        gdk_pixbuf_unref (opb);
+        w = gdk_pixbuf_get_width (pb);
+        h = gdk_pixbuf_get_height (pb);
+        if (verbose_p && (w != ow || h != oh))
+          fprintf (stderr, "%s: rotated %dx%d to %dx%d\n",
+                   progname, ow, oh, w, h);
+      }
+# endif
+
       compute_image_scaling (w, h, win_width, win_height, verbose_p,
                              &srcx, &srcy, &destx, &desty, &w2, &h2);
       if (w != w2 || h != h2)
@@ -1442,6 +1456,19 @@ display_desktop (Screen *screen, Window window, Drawable drawable,
 }
 
 
+/* Whether the given Drawable is unreasonably small.
+ */
+static Bool
+drawable_miniscule_p (Display *dpy, Drawable drawable)
+{
+  Window root;
+  int xx, yy;
+  unsigned int bw, d, w = 0, h = 0;
+  XGetGeometry (dpy, drawable, &root, &xx, &yy, &w, &h, &bw, &d);
+  return (w < 32 || h < 32);
+}
+
+
 /* Grabs an image (from a file, video, or the desktop) and renders it on
    the Drawable.  If `file' is specified, always use that file.  Otherwise,
    select randomly, based on the other arguments.
@@ -1525,6 +1552,15 @@ get_image (Screen *screen,
       image_p = False;
     }
 
+  /* If the target drawable is really small, no good can come of that.
+     Always do colorbars in that case.
+   */
+  if (drawable_miniscule_p (dpy, drawable))
+    {
+      desk_p  = False;
+      video_p = False;
+      image_p = False;
+    }
 
 # ifndef _VROOT_H_
 #  error Error!  This file definitely needs vroot.h!