From http://www.jwz.org/xscreensaver/xscreensaver-5.38.tar.gz
[xscreensaver] / hacks / glx / sonar.c
index f3a4d9d518b73f66ce2576bc6a2995456b498db0..218a62269e1506e05a49697f789345869c0d8b52 100644 (file)
@@ -76,7 +76,7 @@
                        THREAD_DEFAULTS_XLOCK
 
 
-# define refresh_sonar 0
+# define release_sonar 0
 #undef countof
 #define countof(x) (sizeof((x))/sizeof((*x)))
 
@@ -784,8 +784,15 @@ reshape_sonar (ModeInfo *mi, int width, int height)
 {
   sonar_configuration *sp = &sps[MI_SCREEN(mi)];
   GLfloat h = (GLfloat) height / (GLfloat) width;
+  int y = 0;
 
-  glViewport (0, 0, (GLint) width, (GLint) height);
+  if (width > height * 5) {   /* tiny window: show middle */
+    height = width * 9/16;
+    y = -height/2;
+    h = height / (GLfloat) width;
+  }
+
+  glViewport (0, y, (GLint) width, (GLint) height);
 
   glMatrixMode(GL_PROJECTION);
   glLoadIdentity();
@@ -816,20 +823,12 @@ sonar_handle_event (ModeInfo *mi, XEvent *event)
   return False;
 }
 
-
 ENTRYPOINT void 
 init_sonar (ModeInfo *mi)
 {
   sonar_configuration *sp;
 
-  if (!sps) {
-    sps = (sonar_configuration *)
-      calloc (MI_NUM_SCREENS(mi), sizeof (sonar_configuration));
-    if (!sps) {
-      fprintf(stderr, "%s: out of memory\n", progname);
-      exit(1);
-    }
-  }
+  MI_INIT (mi, sps);
   sp = &sps[MI_SCREEN(mi)];
   sp->glx_context = init_GL(mi);
 
@@ -1224,7 +1223,7 @@ draw_sonar (ModeInfo *mi)
 }
 
 ENTRYPOINT void
-release_sonar (ModeInfo *mi)
+free_sonar (ModeInfo *mi)
 {
 #if 0
   sonar_configuration *sp = &sps[MI_SCREEN(mi)];