From http://www.jwz.org/xscreensaver/xscreensaver-5.37.tar.gz
[xscreensaver] / hacks / glx / splitflap.c
index 8a0df74cc97921694add922e0265ea216a1e67d9..35a05f929a0da9fdec6ffd6018ecbc6d931b7efa 100644 (file)
@@ -27,6 +27,7 @@
                        "*usePty:       False\n"
 
 # define refresh_splitflap 0
+# define release_splitflap 0
 #undef countof
 #define countof(x) (sizeof((x))/sizeof((*x)))
 
@@ -213,6 +214,14 @@ reshape_splitflap (ModeInfo *mi, int width, int height)
              0, 0, 0,
              0, 1, 0);
 
+# ifdef HAVE_MOBILE    /* Keep it the same relative size when rotated. */
+  {
+    int o = (int) current_device_rotation();
+    if (o != 0 && o != 180 && o != -180)
+      glScalef (h, h, h);
+  }
+# endif
+
   glClear(GL_COLOR_BUFFER_BIT);
 }
 
@@ -284,6 +293,7 @@ parse_color (ModeInfo *mi, char *key, GLfloat color[4])
 
 
 static int draw_outer_frame (ModeInfo *mi);
+static void free_splitflap (ModeInfo *mi);
 
 ENTRYPOINT void 
 init_splitflap (ModeInfo *mi)
@@ -291,14 +301,7 @@ init_splitflap (ModeInfo *mi)
   splitflap_configuration *bp;
   int wire = MI_IS_WIREFRAME(mi);
   int i;
-  if (!bps) {
-    bps = (splitflap_configuration *)
-      calloc (MI_NUM_SCREENS(mi), sizeof (splitflap_configuration));
-    if (!bps) {
-      fprintf(stderr, "%s: out of memory\n", progname);
-      exit(1);
-    }
-  }
+  MI_INIT (mi, bps, free_splitflap);
 
   bp = &bps[MI_SCREEN(mi)];
   bp->glx_context = init_GL(mi);
@@ -1362,7 +1365,7 @@ draw_splitflap (ModeInfo *mi)
                  ? grid_width * r
                  : grid_height);
     GLfloat s = 8;
-# ifdef USE_IPHONE
+# ifdef HAVE_MOBILE
     s *= 2; /* #### What. Why is this necessary? */
 #endif
     s /= cells;
@@ -1392,8 +1395,8 @@ draw_splitflap (ModeInfo *mi)
   glXSwapBuffers(dpy, window);
 }
 
-ENTRYPOINT void
-release_splitflap (ModeInfo *mi)
+static void
+free_splitflap (ModeInfo *mi)
 {
   splitflap_configuration *bp = &bps[MI_SCREEN(mi)];
   if (bp->tc)