From: Tim Mann Date: Thu, 6 Nov 2003 07:22:14 +0000 (+0000) Subject: Fix ToDo item #406 X-Git-Tag: v4.2.7~15 X-Git-Url: http://winboard.nl/cgi-bin?p=xboard.git;a=commitdiff_plain;h=1787d72dbd0f3ff703050df00dc6ebb5eebe14d7 Fix ToDo item #406 --- diff --git a/ChangeLog b/ChangeLog index 8f00de8..b9d19ac 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,13 @@ ChangeLog for XBoard/WinBoard +* 11/5/2003: When a chess engine sends a "telluser" command (including +the cases where "tellall" or "tellopponent" acts like telluser), the +information now goes into a nonmodel popup that is automatically +dismissed when the user clicks anywhere on the board. This fix is +more significant on WinBoard, where formerly you got a fully modal +dialog that had to be dismissed by clicking on OK before anything else +could happen. The bug was issue #406 in the ToDo file. + * 11/1/2003: Removed email addresses from this file to reduce spam load, as it gets linked to from the Web. diff --git a/ToDo b/ToDo index edafd00..6da49e1 100644 --- a/ToDo +++ b/ToDo @@ -843,8 +843,6 @@ console window, or something. 402. Internationalization. It probably isn't practical to retrofit this into the current code base. -****406. "telluser" needs to be made nonmodal in winboard. - 409. One user requested a way to put a time delay in the middle of sending zippyGameEnd commands. This would (for example) let the computer do a seek only if its opponent doesn't accept a rematch @@ -1277,8 +1275,6 @@ for WCCC and other computer competitions, where xboard/winboard's clock is not the master. I was going to do it in time for the July 2002 WCCC. Oops. -***540. Pick up GNU Chess 5.07! (or whatever is newest) - 541. Related to #327, John Iverson says, "It would be nice to have the coordinates shown outside of the board along the edges, rather than in the squares where they are hard to see and give a cluttered @@ -1376,5 +1372,5 @@ Before each release: - make sure ChangeLog is complete - test changes -*** up to date with mail received through 25 Oct 2003, except +*** up to date with mail received through 5 Nov 2003, except for the "protover 3" discussions on the chess-engines mailing list *** diff --git a/backend.c b/backend.c index 690662d..5962591 100644 --- a/backend.c +++ b/backend.c @@ -3907,7 +3907,7 @@ HandleMachineMove(message, cps) * Look for communication commands */ if (!strncmp(message, "telluser ", 9)) { - DisplayInformation(message + 9); + DisplayNote(message + 9); return; } if (!strncmp(message, "tellusererror ", 14)) { @@ -3921,7 +3921,7 @@ HandleMachineMove(message, cps) SendToICS(buf1); } } else { - DisplayInformation(message + 13); + DisplayNote(message + 13); } return; } @@ -3941,7 +3941,7 @@ HandleMachineMove(message, cps) SendToICS(buf1); } } else { - DisplayInformation(message + 8); + DisplayNote(message + 8); } return; } diff --git a/frontend.h b/frontend.h index e611d41..7fad00f 100644 --- a/frontend.h +++ b/frontend.h @@ -73,6 +73,7 @@ void DisplayMoveError P((String message)); void DisplayFatalError P((String message, int error, int status)); void DisplayInformation P((String message)); +void DisplayNote P((String message)); void AskQuestion P((String title, String question, String replyPrefix, ProcRef pr)); void DisplayIcsInteractionTitle P((String title)); diff --git a/winboard/winboard.c b/winboard/winboard.c index 68dab66..cd2e98c 100644 --- a/winboard/winboard.c +++ b/winboard/winboard.c @@ -337,6 +337,7 @@ HWND analysisDialog = NULL; BOOLEAN analysisDialogUp = FALSE; static int analysisX, analysisY, analysisH, analysisW; +char errorTitle[MSG_SIZ]; char errorMessage[2*MSG_SIZ]; HWND errorDialog = NULL; BOOLEAN moveErrorMessageUp = FALSE; @@ -4942,6 +4943,45 @@ PopUpMoveDialog(char firstchar) \*---------------------------------------------------------------------------*/ /* Nonmodal error box */ +LRESULT CALLBACK ErrorDialog(HWND hDlg, UINT message, + WPARAM wParam, LPARAM lParam); + +VOID +ErrorPopUp(char *title, char *content) +{ + FARPROC lpProc; + char *p, *q; + BOOLEAN modal = hwndMain == NULL; + + p = content; + q = errorMessage; + while (*p) { + if (*p == '\n') { + if (modal) { + *q++ = ' '; + p++; + } else { + *q++ = '\r'; + *q++ = *p++; + } + } else { + *q++ = *p++; + } + } + *q = NULLCHAR; + strncpy(errorTitle, title, sizeof(errorTitle)); + errorTitle[sizeof(errorTitle) - 1] = '\0'; + + if (modal) { + MessageBox(NULL, errorMessage, errorTitle, MB_OK|MB_ICONEXCLAMATION); + } else { + lpProc = MakeProcInstance((FARPROC)ErrorDialog, hInst); + CreateDialog(hInst, MAKEINTRESOURCE(DLG_Error), + hwndMain, (DLGPROC)lpProc); + FreeProcInstance(lpProc); + } +} + VOID ErrorPopDown() { @@ -4964,6 +5004,7 @@ ErrorDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) rChild.top + boardRect.top - (rChild.bottom - rChild.top), 0, 0, SWP_NOZORDER|SWP_NOSIZE); errorDialog = hDlg; + SetWindowText(hDlg, errorTitle); hwndText = GetDlgItem(hDlg, OPT_ErrorText); SetDlgItemText(hDlg, OPT_ErrorText, errorMessage); return FALSE; @@ -6316,31 +6357,8 @@ DisplayError(char *str, int error) } } } - p = buf; - q = errorMessage; - while (*p) { - if (*p == '\n') { - if (hwndMain != NULL /*!!?*/) { - *q++ = '\r'; - *q++ = *p++; - } else { - *q++ = ' '; - p++; - } - } else { - *q++ = *p++; - } - } - *q = NULLCHAR; - if (hwndMain == NULL) { - MessageBox(NULL, errorMessage, "Error", MB_OK|MB_ICONEXCLAMATION); - } else { - lpProc = MakeProcInstance((FARPROC)ErrorDialog, hInst); - CreateDialog(hInst, MAKEINTRESOURCE(DLG_Error), - hwndMain, (DLGPROC)lpProc); - FreeProcInstance(lpProc); - } + ErrorPopUp("Error", buf); } @@ -6351,7 +6369,7 @@ DisplayMoveError(char *str) ClearHighlights(); DrawPosition(FALSE, NULL); if (appData.popupMoveErrors) { - DisplayError(str, 0); + ErrorPopUp("Error", str); } else { DisplayMessage(str, ""); moveErrorMessageUp = TRUE; @@ -6400,6 +6418,13 @@ DisplayInformation(char *str) } +VOID +DisplayNote(char *str) +{ + ErrorPopUp("Note", str); +} + + typedef struct { char *title, *question, *replyPrefix; ProcRef pr; diff --git a/xboard.c b/xboard.c index b31b64f..bc864fe 100644 --- a/xboard.c +++ b/xboard.c @@ -6821,6 +6821,13 @@ void DisplayInformation(message) ErrorPopUp("Information", message, TRUE); } +void DisplayNote(message) + String message; +{ + ErrorPopDown(); + ErrorPopUp("Note", message, FALSE); +} + static int NullXErrorCheck(dpy, error_event) Display *dpy;