From d5e1ced63182849f6c1fcaf3abb5d15d437545c5 Mon Sep 17 00:00:00 2001 From: Matt Zimmerman <> Date: Sat, 27 Jun 2009 15:45:14 -0700 Subject: [PATCH] add a visual low time warning (tiny change from Debian patches) --- common.h | 2 ++ xboard.c | 32 ++++++++++++++++++++++++++++++-- xboard.h | 1 + xboard.texi | 10 +++++++++- 4 files changed, 42 insertions(+), 3 deletions(-) diff --git a/common.h b/common.h index 62086db..bf447c9 100644 --- a/common.h +++ b/common.h @@ -569,6 +569,8 @@ typedef struct { int zippyShortGame; /* [HGM] aborter */ #endif + char *lowTimeWarningColor; + Boolean lowTimeWarning; char *serverMovesName; Boolean suppressLoadMoves; int serverPause; diff --git a/xboard.c b/xboard.c index b599a8d..d47a15d 100644 --- a/xboard.c +++ b/xboard.c @@ -456,6 +456,7 @@ Display *xDisplay; Window xBoardWindow; Pixel lightSquareColor, darkSquareColor, whitePieceColor, blackPieceColor, jailSquareColor, highlightSquareColor, premoveHighlightColor; +Pixel lowTimeWarningColor; GC lightSquareGC, darkSquareGC, jailSquareGC, lineGC, wdPieceGC, wlPieceGC, bdPieceGC, blPieceGC, wbPieceGC, bwPieceGC, coordGC, highlineGC, wjPieceGC, bjPieceGC, prelineGC, countGC; @@ -1195,6 +1196,12 @@ XtResource clientResources[] = { { "showButtonBar", "showButtonBar", XtRBoolean, sizeof(Boolean), XtOffset(AppDataPtr, showButtonBar), XtRImmediate, (XtPointer) True }, + { "lowTimeWarningColor", "lowTimeWarningColor", XtRString, + sizeof(String), XtOffset(AppDataPtr, lowTimeWarningColor), + XtRString, COLOR_LOWTIMEWARNING }, + { "lowTimeWarning", "lowTimeWarning", XtRBoolean, + sizeof(Boolean), XtOffset(AppDataPtr, lowTimeWarning), + XtRImmediate, (XtPointer) False }, {"icsEngineAnalyze", "icsEngineAnalyze", XtRBoolean, /* [DM] icsEngineAnalyze */ sizeof(Boolean), XtOffset(AppDataPtr, icsEngineAnalyze), XtRImmediate, (XtPointer) False }, @@ -1673,6 +1680,8 @@ XrmOptionDescRec shellOptions[] = { { "-showButtonBar", "showButtonBar", XrmoptionSepArg, NULL }, { "-buttons", "showButtonBar", XrmoptionNoArg, "True" }, { "-xbuttons", "showButtonBar", XrmoptionNoArg, "False" }, + { "-lowTimeWarningColor", "lowTimeWarningColor", XrmoptionSepArg, NULL }, + { "-lowTimeWarning", "lowTimeWarning", XrmoptionSepArg, NULL }, /* [AS,HR] New features */ { "-firstScoreAbs", "firstScoreAbs", XrmoptionSepArg, NULL }, { "-secondScoreAbs", "secondScoreAbs", XrmoptionSepArg, NULL }, @@ -2579,6 +2588,16 @@ XBoard square size (hint): %d\n\ programName); } + if (appData.lowTimeWarning && !appData.monoMode) { + vFrom.addr = (caddr_t) appData.lowTimeWarningColor; + vFrom.size = strlen(appData.lowTimeWarningColor); + XtConvert(shellWidget, XtRString, &vFrom, XtRPixel, &vTo); + if (vTo.addr == NULL) + appData.monoMode = True; + else + lowTimeWarningColor = *(Pixel *) vTo.addr; + } + if (appData.monoMode && appData.debugMode) { fprintf(stderr, _("white pixel = 0x%lx, black pixel = 0x%lx\n"), (unsigned long) XWhitePixel(xDisplay, xScreen), @@ -8092,6 +8111,14 @@ DisplayTimerLabel(w, color, timer, highlight) char buf[MSG_SIZ]; Arg args[16]; + Pixel foregroundOrWarningColor = timerForegroundPixel; + + if (timer > 0 + && appData.lowTimeWarning + && (timer / 1000) < appData.icsAlarmTime) + + foregroundOrWarningColor = lowTimeWarningColor; + if (appData.clockMode) { sprintf(buf, "%s: %s", color, TimeString(timer)); XtSetArg(args[0], XtNlabel, buf); @@ -8101,11 +8128,12 @@ DisplayTimerLabel(w, color, timer, highlight) } if (highlight) { - XtSetArg(args[1], XtNbackground, timerForegroundPixel); + + XtSetArg(args[1], XtNbackground, foregroundOrWarningColor); XtSetArg(args[2], XtNforeground, timerBackgroundPixel); } else { XtSetArg(args[1], XtNbackground, timerBackgroundPixel); - XtSetArg(args[2], XtNforeground, timerForegroundPixel); + XtSetArg(args[2], XtNforeground, foregroundOrWarningColor); } XtSetValues(w, args, 3); diff --git a/xboard.h b/xboard.h index 115000d..534e556 100644 --- a/xboard.h +++ b/xboard.h @@ -67,6 +67,7 @@ #define COLOR_REQUEST "red" #define COLOR_SEEK "blue" #define COLOR_NORMAL "default" +#define COLOR_LOWTIMEWARNING "red" typedef struct { char *name; diff --git a/xboard.texi b/xboard.texi index 07c569f..4d43eaa 100644 --- a/xboard.texi +++ b/xboard.texi @@ -1558,8 +1558,12 @@ Sets the Get Move List menu option. @xref{Options Menu}. Default: true. Sets the ICS Alarm menu option. @xref{Options Menu}. Default: true. @item -icsAlarmTime ms @cindex icsAlarmTime, option -Sets the time in milliseconds for the ICS Alarm menu option. +Sets the time in milliseconds for the ICS Alarm menu option. @xref{Options Menu}. Default: 5000. +@item lowTimeWarning true/false +@cindex lowTimeWarning, option +Controls a color change of the board as a warning your time is running out. +@xref{Options Menu}. Default: false. @item -pre/-xpre \fRor\fB -premove true/false @cindex pre, option @cindex premove, option @@ -2037,12 +2041,14 @@ sets, see @ref{zic2xpm} below. @itemx -lightSquareColor color @itemx -darkSquareColor color @itemx -highlightSquareColor color +@itemx -lowTimeWarningColor color @cindex Colors @cindex whitePieceColor, option @cindex blackPieceColor, option @cindex lightSquareColor, option @cindex darkSquareColor, option @cindex highlightSquareColor, option +@cindex lowTimeWarningColor, option Colors to use for the pieces, squares, and square highlights. Defaults: @@ -2053,6 +2059,7 @@ Defaults: -darkSquareColor #77A26D -highlightSquareColor #FFFF00 -premoveHighlightColor #FF0000 +-lowTimeWarningColor #FF0000 @end example On a grayscale monitor you might prefer: @@ -2064,6 +2071,7 @@ On a grayscale monitor you might prefer: -darkSquareColor gray60 -highlightSquareColor gray100 -premoveHighlightColor gray70 +-lowTimeWarningColor gray70 @end example @item -drag/-xdrag or -animateDragging true/false @cindex drag, option -- 1.7.0.4