From 8cadd120c307bb1049f6d08d9ae23f67432bd038 Mon Sep 17 00:00:00 2001
From: H.G.Muller <hgm@hgm-xboard.(none)>
Date: Thu, 23 Oct 2014 23:33:18 +0200
Subject: [PATCH] Add persistent Boolean option -fixedSize

When set, this option suppresses sizing of the board and clocks when
the window is sized by the user. This is achieved by wrapping the entire
dialog in a non-expanding hbox.
---
 args.h         |    1 +
 common.h       |    1 +
 dialogs.c      |    3 ++-
 gtk/xboard.c   |    2 +-
 gtk/xoptions.c |    5 +++++
 5 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/args.h b/args.h
index 304278f..270866d 100644
--- a/args.h
+++ b/args.h
@@ -610,6 +610,7 @@ ArgDescriptor argDescriptors[] = {
   { "finger", ArgFilename, (void *) &appData.finger, FALSE, (ArgIniType) "" },
   { "inscriptions", ArgString, (void *) &appData.inscriptions, XBOARD, (ArgIniType) "" },
   { "autoInstall", ArgString, (void *) &appData.autoInstall, XBOARD, (ArgIniType) "" },
+  { "fixedSize", ArgBoolean, (void *) &appData.fixedSize, TRUE, (ArgIniType) FALSE },
 
   // [HGM] tournament options
   { "tourneyFile", ArgFilename, (void *) &appData.tourneyFile, FALSE, (ArgIniType) "" },
diff --git a/common.h b/common.h
index 9f54f47..2b0ddf0 100644
--- a/common.h
+++ b/common.h
@@ -756,6 +756,7 @@ typedef struct {
     char *logo[ENGINES];/* [HGM] logo      */
     char *pairingEngine;/* [HGM] pairing   */
     Boolean autoLogo;
+    Boolean fixedSize;
     Boolean noGUI;      /* [HGM] fast: suppress all display updates */
     char *engOptions[ENGINES]; /* [HGM] options   */
     char *fenOverride[ENGINES];
diff --git a/dialogs.c b/dialogs.c
index 0378c01..2ea3d0a 100644
--- a/dialogs.c
+++ b/dialogs.c
@@ -2590,13 +2590,14 @@ Option *
 BoardPopUp (int squareSize, int lineGap, void *clockFontThingy)
 {
     int i, size = BOARD_WIDTH*(squareSize + lineGap) + lineGap, logo = appData.logoSize;
+    int f = 2*appData.fixedSize; // width fudge, needed for unknown reasons to not clip board
     mainOptions[W_WHITE].choice = (char**) clockFontThingy;
     mainOptions[W_BLACK].choice = (char**) clockFontThingy;
     mainOptions[W_BOARD].value = BOARD_HEIGHT*(squareSize + lineGap) + lineGap;
     mainOptions[W_BOARD].max = mainOptions[W_SMALL].max = size; // board size
     mainOptions[W_SMALL].max = size - 2; // board title (subtract border!)
     mainOptions[W_BLACK].max = mainOptions[W_WHITE].max = size/2-3; // clock width
-    mainOptions[W_MESSG].max = appData.showButtonBar ? size-135 : size-2; // message
+    mainOptions[W_MESSG].max = appData.showButtonBar ? size-135+f : size-2+f; // message
     mainOptions[W_MENU].max = size-40; // menu bar
     mainOptions[W_TITLE].type = appData.titleInWindow ? Label : Skip ;
     if(logo && logo <= size/4) { // Activate logos
diff --git a/gtk/xboard.c b/gtk/xboard.c
index 8958e3c..a8afcb3 100644
--- a/gtk/xboard.c
+++ b/gtk/xboard.c
@@ -1691,7 +1691,7 @@ ReSize (WindowPlacement *wp)
 	h = BOARD_HEIGHT * (squareSize + lineGap) + lineGap;
 	if(optList[W_BOARD].max   > w) optList[W_BOARD].max = w;
 	if(optList[W_BOARD].value > h) optList[W_BOARD].value = h;
-	first = 0;
+	first = appData.fixedSize;
 }
 
 static guint delayedDragTag = 0;
diff --git a/gtk/xoptions.c b/gtk/xoptions.c
index 31598bd..67675ff 100644
--- a/gtk/xoptions.c
+++ b/gtk/xoptions.c
@@ -1627,6 +1627,11 @@ if(appData.debugMode) printf("n=%d, h=%d, w=%d\n",n,height,width);
     }
 
     gtk_table_resize(GTK_TABLE(table), top+1, r);
+    if(dlgNr == BoardWindow && appData.fixedSize) { // inhibit sizing
+	GtkWidget *h = gtk_hbox_new(FALSE, 0);
+	gtk_box_pack_start (GTK_BOX (h), table, TRUE, FALSE, 2);
+	table = h;
+    }
     if(pane)
 	gtk_box_pack_start (GTK_BOX (pane), table, expandable, TRUE, 0);
     else
-- 
1.7.0.4