From: H.G.Muller Date: Tue, 5 Apr 2016 12:32:54 +0000 (+0200) Subject: Adjust window height after clock-font change X-Git-Url: http://winboard.nl/cgi-bin?a=commitdiff_plain;h=f5445dab3a8035dfdfa3eb8581d323c0661390fb;p=xboard.git Adjust window height after clock-font change A routine LockBoardSize are added, and called to protect the board's Graph widget from absorbing the height change pf clock and message field. Enlarging these now forces the top-level window to expand, and after the change we try to reduce this window size to tightly fit the board to squeeze out empty area after shrinking. --- diff --git a/dialogs.c b/dialogs.c index 306bc97..2cdf6a9 100644 --- a/dialogs.c +++ b/dialogs.c @@ -1629,9 +1629,12 @@ FontsOK (int n) { extern Option historyOptions[], engoutOptions[], gamesOptions[], chatOptions[]; int i; + PopDown(TransientDlg); // Early popdown to prevent expose events frommasking each other + LockBoardSize(0); DisplayBothClocks(); ApplyFont(&mainOptions[W_MESSG], NULL); for(i=1; i<6; i++) ApplyFont(&mainOptions[W_BUTTON+i], NULL); + LockBoardSize(1); ApplyFont(&tagsOptions[1], NULL); ApplyFont(&historyOptions[0], NULL); ApplyFont(&engoutOptions[5], NULL); @@ -1640,7 +1643,7 @@ FontsOK (int n) ApplyFont(&chatOptions[11], appData.icsFont); AppendColorized(&chatOptions[6], NULL, 0); // kludge to replace font tag DrawPosition(TRUE, NULL); // for coord font - return 1; + return 0; // suppress normal popdown because already done } static Option fontOptions[] = { diff --git a/dialogs.h b/dialogs.h index 28f7abb..0d933d9 100644 --- a/dialogs.h +++ b/dialogs.h @@ -205,6 +205,7 @@ void DisplayHelp P((char *name)); void WidgetEcho P((Option *opt, int n)); int ErrorOK P((int n)); void ApplyFont P((Option *opt, char *font)); +void LockBoardSize P((int after)); // in ngamelist.c diff --git a/gtk/xboard.c b/gtk/xboard.c index 8dc5253..03f2f9a 100644 --- a/gtk/xboard.c +++ b/gtk/xboard.c @@ -2057,6 +2057,25 @@ DisplayIcsInteractionTitle (String message) #endif } +void +LockBoardSize (int after) +{ + static char *oldClockFont, *oldMessgFont; + int w, h; + if(oldMessgFont && !strcmp(oldMessgFont, appData.font) && + oldClockFont && !strcmp(oldClockFont, appData.clockFont) ) return; // only do something when font changed + w = BOARD_WIDTH*(squareSize + lineGap) + lineGap; + h = BOARD_HEIGHT*(squareSize + lineGap) + lineGap; + if(after) { + ASSIGN(oldClockFont, appData.clockFont); + ASSIGN(oldMessgFont, appData.font); + gtk_window_resize(GTK_WINDOW(shellWidget), w, h); + DoEvents(); + gtk_widget_set_size_request(optList[W_BOARD].handle, -1, -1); // liberate board + } else { // before + gtk_widget_set_size_request(optList[W_BOARD].handle, w, h); // protect board widget + } +} void DisplayTimerLabel (Option *opt, char *color, long timer, int highlight) diff --git a/xaw/xoptions.c b/xaw/xoptions.c index 5feb56a..1c0a897 100644 --- a/xaw/xoptions.c +++ b/xaw/xoptions.c @@ -1446,3 +1446,8 @@ FileNamePopUpWrapper (char *label, char *def, char *filter, FileProc proc, Boole { Browse(BoardWindow, label, (def[0] ? def : NULL), filter, False, openMode, openName, openFP); } + +void +LockBoardSize (int after) +{ +}