Complete.Org: Mailing Lists: Archives: freeciv-dev: June 2004:
[Freeciv-Dev] (PR#8970) gtk2 scrollbars caught in loop
Home

[Freeciv-Dev] (PR#8970) gtk2 scrollbars caught in loop

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients: ;
Subject: [Freeciv-Dev] (PR#8970) gtk2 scrollbars caught in loop
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Wed, 23 Jun 2004 21:47:51 -0700
Reply-to: rt@xxxxxxxxxxx

<URL: http://rt.freeciv.org/Ticket/Display.html?id=8970 >

> [jdorje - Sat Jun 12 17:54:52 2004]:
> 
> I tried out a small map and a maximized mapview.  I was just scrolling 
> around on it at random.  However when I hit the wrong place the 
> scrollbars got caught in a loop jumping back and forth.  This is worse 
> than a client crash.

Probably this is a bug in libgtk2.  However the root cause is that the
scroll slider is bigger than the scroll range.  This also makes for ugly
scrolling.  This patch fixes it.

This would also be fixed by imposing a maximum width on the mapview. 
However that will take a little longer.

jason

Index: client/mapview_common.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/mapview_common.c,v
retrieving revision 1.132
diff -u -r1.132 mapview_common.c
--- client/mapview_common.c     24 Jun 2004 00:15:50 -0000      1.132
+++ client/mapview_common.c     24 Jun 2004 04:36:36 -0000
@@ -512,6 +512,8 @@
 void get_mapview_scroll_window(int *xmin, int *ymin, int *xmax, int *ymax,
                               int *xsize, int *ysize)
 {
+  int diff;
+
   *xsize = mapview_canvas.width;
   *ysize = mapview_canvas.height;
 
@@ -568,6 +570,20 @@
     *ymax = MAX(gui_y4, MAX(gui_y2, gui_y3)) + mapview_canvas.height / 2;
   }
 
+  /* Make sure the scroll window is big enough to hold the mapview.  If
+   * not scrolling will be very ugly and the GUI may become confused. */
+  diff = *xsize - (*xmax - *xmin);
+  if (diff > 0) {
+    *xmin -= diff / 2;
+    *xmax += (diff + 1) / 2;
+  }
+
+  diff = *ysize - (*ymax - *ymin);
+  if (diff > 0) {
+    *ymin -= diff / 2;
+    *ymax += (diff + 1) / 2;
+  }
+
   freelog(LOG_DEBUG, "x: %d<-%d->%d; y: %d<-%d->%d",
          *xmin, *xsize, *xmax, *ymin, *ymax, *ysize);
 }

[Prev in Thread] Current Thread [Next in Thread]