From 4216c43fb3c06eb4b4c65c044e8342d1e7672199 Mon Sep 17 00:00:00 2001
From: Greg Frost <gregfrost1@bigpond.com>
Date: Wed, 5 Aug 2009 00:44:25 +0000
Subject: LinHES-timezone: all keys exit help when it is displayed. Added
 aspect ratio correction code

---
 abs/core-testing/LinHES-timezone/PKGBUILD          |  2 +-
 abs/core-testing/LinHES-timezone/linhes_timezone.c | 30 +++++++++++++++++++---
 2 files changed, 27 insertions(+), 5 deletions(-)

diff --git a/abs/core-testing/LinHES-timezone/PKGBUILD b/abs/core-testing/LinHES-timezone/PKGBUILD
index 4c72659..e819965 100644
--- a/abs/core-testing/LinHES-timezone/PKGBUILD
+++ b/abs/core-testing/LinHES-timezone/PKGBUILD
@@ -2,7 +2,7 @@
 # Maintainer: Greg Frost <gregfrost1@bigpond.com>
 pkgname=LinHES-timezone
 pkgver=1
-pkgrel=8
+pkgrel=9
 pkgdesc="GUI timezone selector used by LinHES-config."
 arch=i686
 depends=()
diff --git a/abs/core-testing/LinHES-timezone/linhes_timezone.c b/abs/core-testing/LinHES-timezone/linhes_timezone.c
index 4ab4ab0..d7a56d2 100644
--- a/abs/core-testing/LinHES-timezone/linhes_timezone.c
+++ b/abs/core-testing/LinHES-timezone/linhes_timezone.c
@@ -38,6 +38,7 @@ Position y = 0;
 XFontStruct *font;
 XPoint xpoints[1000];
 int radius;
+double aspect_correction = 1;
 
 double target_lat;
 double target_lon;
@@ -108,12 +109,12 @@ int translate_point (vect_type *v, XPoint *p)
   // If the point is behind the face of the globe, project it to the edge.
   if (v3.x < 0)
   {
-    p->x = width /2 + radius * sin (atan2 (v3.y,v3.z));
+    p->x = width /2 + radius * sin (atan2 (v3.y,v3.z)) * aspect_correction;
     p->y = height/2 - radius * cos (atan2 (v3.y,v3.z));
   }
   else
   {
-    p->x = width /2 + lrint (v3.y);
+    p->x = width /2 + lrint (v3.y) * aspect_correction;
     p->y = height/2 - lrint (v3.z);
   }
   
@@ -261,8 +262,8 @@ void redraw_map ()
 
   XSetForeground (display, gc, ocean.pixel);
   XFillArc (display, pixmap, gc, 
-    width / 2 - radius, height / 2 - radius,
-    radius * 2, radius * 2, 0, 360 * 64);
+    width / 2 - radius * aspect_correction, height / 2 - radius,
+    radius * 2 * aspect_correction, radius * 2, 0, 360 * 64);
 
   XSetForeground (display, gc, lat_lon.pixel);
   XSetLineAttributes (display, gc, 2, LineSolid, CapRound, JoinRound);
@@ -416,6 +417,12 @@ void handle_key (char key)
   
   selected_z = zone_data[selected_zone].place_info[selected_place].v.z;
 
+  if (show_information)
+  {
+    show_information = FALSE;
+    return;
+  }
+
   switch (key)
   {
     case 'U':
@@ -933,6 +940,21 @@ int main (int argc, char *argv[])
 
   radius = 0.96 * radius / 2;
 
+  if ((screen_height == 0) || 
+      (XWidthMMOfScreen (DefaultScreenOfDisplay (display)) == 0))
+    aspect_correction = 1;
+  else
+    aspect_correction = 
+      sqrt (screen_width * 
+            XHeightMMOfScreen (DefaultScreenOfDisplay (display)) * 1.0 /
+            screen_height /
+            XWidthMMOfScreen (DefaultScreenOfDisplay (display)));
+
+  // Protect against very wierd aspect corrections from bogus 
+  // screen dimensions.
+  if ((aspect_correction < 0.5) || (aspect_correction > 2))
+    aspect_correction = 1;
+
   window = XCreateSimpleWindow (display,
              DefaultRootWindow(display), x, y, width, height, 0,
              land[0].pixel, ocean.pixel);
-- 
cgit v0.12