Fix clipping of board GTK
[xboard.git] / gtk / xboard.c
index 0d04c5b..b1f7103 100644 (file)
@@ -639,7 +639,12 @@ void
 ResizeBoardWindow (int w, int h, int inhibit)
 {
     GtkAllocation a;
+    int bw;
 //    if(clockKludge) return; // ignore as long as clock does not have final height
+    gtk_widget_get_allocation(optList[W_BOARD].handle, &a);
+    bw = a.width;
+    gtk_widget_get_allocation(shellWidget, &a);
+    marginW = a.width - bw;
     gtk_widget_get_allocation(optList[W_WHITE].handle, &a);
     w += marginW + 1; // [HGM] not sure why the +1 is (sometimes) needed...
     h += marginH + a.height + 1;
@@ -1179,7 +1184,7 @@ main (int argc, char **argv)
        gtk_widget_get_allocation(optList[W_WHITE].handle, &a);
        clockKludge = hc = a.height;
        gtk_widget_get_allocation(boardWidget, &a);
-       marginW =  w - boardWidth; // [HGM] needed to set new shellWidget size when we resize board
+//     marginW =  w - boardWidth; // [HGM] needed to set new shellWidget size when we resize board
        marginH =  h - a.height - hc; // subtract current clock height, so it can be added back dynamically
     }
 
@@ -1647,10 +1652,13 @@ ReSize (WindowPlacement *wp)
        if(sqy < sqx) sqx = sqy;
         if(sqx < 20) return;
        if(appData.overrideLineGap < 0) { // do second iteration with adjusted lineGap
+           int oldSqx = sqx;
            lg = lineGap = sqx < 37 ? 1 : sqx < 59 ? 2 : sqx < 116 ? 3 : 4;
            sqx = (wp->width  - lg - marginW) / BOARD_WIDTH - lg;
            sqy = (wp->height - lg - marginH - hc) / BOARD_HEIGHT - lg;
            if(sqy < sqx) sqx = sqy;
+           lg = sqx < 37 ? 1 : sqx < 59 ? 2 : sqx < 116 ? 3 : 4;
+           if(sqx == oldSqx + 1 && lg == lineGap + 1) sqx = oldSqx, squareSize = 0; // prevent oscillations, force resize by kludge
        }
        if(sqx != squareSize) {
            squareSize = sqx; // adopt new square size