From http://www.jwz.org/xscreensaver/xscreensaver-5.30.tar.gz
[xscreensaver] / utils / grabclient.c
index 47d1c3bd5d5ebb3a1d3f95885ae2586c39130f3b..dd8b225807843f995af36529161df20aaecc3e66 100644 (file)
@@ -1,4 +1,4 @@
-/* xscreensaver, Copyright (c) 1992-2013 Jamie Zawinski <jwz@jwz.org>
+/* xscreensaver, Copyright (c) 1992-2014 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
@@ -648,27 +648,40 @@ pipe_cb (XtPointer closure, int *source, XtInputId *id)
    image from the iOS device's Photo Library.  See iosgrabimage.m.
  */
 static void
-ios_load_random_image_cb (void *uiimage, const char *filename, void *closure)
+ios_load_random_image_cb (void *uiimage, const char *filename, 
+                          int width, int height, void *closure)
 {
   struct pipe_closure *clo2 = (struct pipe_closure *) closure;
   Display *dpy = DisplayOfScreen (clo2->screen);
   XRectangle geom;
+  XWindowAttributes xgwa;
+  Window r;
+  int x, y;
+  unsigned int w, h, bbw, d;
+  int rot = 0;
+
+  XGetWindowAttributes (dpy, clo2->xwindow, &xgwa);
+  XGetGeometry (dpy, clo2->drawable, &r, &x, &y, &w, &h, &bbw, &d);
+
+  /* If the image is portrait and the window is landscape, or vice versa,
+     rotate the image. The idea is to fill up as many pixels as possible,
+     and assume the user will just rotate their phone until it looks right.
+     This makes "decayscreen", etc. much more easily viewable.
+   */
+  if (get_boolean_resource (dpy, "rotateImages", "RotateImages")) {
+    if ((width > height) != (w > h))
+      rot = 5;
+  }
 
   if (uiimage)
     {
       jwxyz_draw_NSImage_or_CGImage (DisplayOfScreen (clo2->screen), 
                                      clo2->drawable,
                                      True, uiimage, &geom,
-                                     0);
+                                     rot);
     }
   else  /* Probably means no images in the gallery. */
     {
-      XWindowAttributes xgwa;
-      Window r;
-      int x, y;
-      unsigned int w, h, bbw, d;
-      XGetWindowAttributes (dpy, clo2->xwindow, &xgwa);
-      XGetGeometry (dpy, clo2->drawable, &r, &x, &y, &w, &h, &bbw, &d);
       draw_colorbars (clo2->screen, xgwa.visual, clo2->drawable, xgwa.colormap,
                       0, 0, w, h);
       geom.x = geom.y = 0;