From http://www.jwz.org/xscreensaver/xscreensaver-5.39.tar.gz
[xscreensaver] / hacks / glx / sonar.c
index 42bcdc8e7d6cc4ddb3d8afff039dff1535c00f2a..c4ea949046812e66939893a474776fd97c6cd39f 100644 (file)
@@ -1,4 +1,4 @@
-/* sonar, Copyright (c) 1998-2015 Jamie Zawinski and Stephen Martin
+/* sonar, Copyright (c) 1998-2018 Jamie Zawinski and Stephen Martin
  *
  * Permission to use, copy, modify, distribute, and sell this software and its
  * documentation for any purpose is hereby granted without fee, provided that
@@ -76,7 +76,6 @@
                        THREAD_DEFAULTS_XLOCK
 
 
-# define refresh_sonar 0
 # define release_sonar 0
 #undef countof
 #define countof(x) (sizeof((x))/sizeof((*x)))
@@ -355,6 +354,8 @@ draw_text (ModeInfo *mi, const char *string, GLfloat r, GLfloat th,
   char *token = string2;
   char *line;
 
+  if (MI_WIDTH(mi) > 2560) font_scale /= 2;  /* Retina displays */
+
   if (size <= 0)   /* if size not specified, draw in yellow with alpha */
     {
       GLfloat color[4];
@@ -785,8 +786,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;
+
+  if (width > height * 5) {   /* tiny window: show middle */
+    height = width * 9/16;
+    y = -height/2;
+    h = height / (GLfloat) width;
+  }
 
-  glViewport (0, 0, (GLint) width, (GLint) height);
+  glViewport (0, y, (GLint) width, (GLint) height);
 
   glMatrixMode(GL_PROJECTION);
   glLoadIdentity();
@@ -817,14 +825,12 @@ sonar_handle_event (ModeInfo *mi, XEvent *event)
   return False;
 }
 
-static void free_sonar (ModeInfo *mi);
-
 ENTRYPOINT void 
 init_sonar (ModeInfo *mi)
 {
   sonar_configuration *sp;
 
-  MI_INIT (mi, sps, free_sonar);
+  MI_INIT (mi, sps);
   sp = &sps[MI_SCREEN(mi)];
   sp->glx_context = init_GL(mi);
 
@@ -1218,7 +1224,7 @@ draw_sonar (ModeInfo *mi)
 # endif /* TEST_ASYNC_NETDB */
 }
 
-static void
+ENTRYPOINT void
 free_sonar (ModeInfo *mi)
 {
 #if 0