Fix ToDo item #406
authorTim Mann <tim@tim-mann.org>
Thu, 6 Nov 2003 07:22:14 +0000 (07:22 +0000)
committerTim Mann <tim@tim-mann.org>
Thu, 6 Nov 2003 07:22:14 +0000 (07:22 +0000)
ChangeLog
ToDo
backend.c
frontend.h
winboard/winboard.c
xboard.c

index 8f00de8..b9d19ac 100644 (file)
--- 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 (file)
--- 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 ***
index 690662d..5962591 100644 (file)
--- 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;
     }
index e611d41..7fad00f 100644 (file)
@@ -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));
index 68dab66..cd2e98c 100644 (file)
@@ -337,6 +337,7 @@ HWND analysisDialog = NULL;
 BOOLEAN analysisDialogUp = FALSE;\r
 static int analysisX, analysisY, analysisH, analysisW;\r
 \r
+char errorTitle[MSG_SIZ];\r
 char errorMessage[2*MSG_SIZ];\r
 HWND errorDialog = NULL;\r
 BOOLEAN moveErrorMessageUp = FALSE;\r
@@ -4942,6 +4943,45 @@ PopUpMoveDialog(char firstchar)
 \*---------------------------------------------------------------------------*/\r
 \r
 /* Nonmodal error box */\r
+LRESULT CALLBACK ErrorDialog(HWND hDlg, UINT message,\r
+                            WPARAM wParam, LPARAM lParam);\r
+\r
+VOID\r
+ErrorPopUp(char *title, char *content)\r
+{\r
+  FARPROC lpProc;\r
+  char *p, *q;\r
+  BOOLEAN modal = hwndMain == NULL;\r
+\r
+  p = content;\r
+  q = errorMessage;\r
+  while (*p) {\r
+    if (*p == '\n') {\r
+      if (modal) {\r
+       *q++ = ' ';\r
+       p++;\r
+      } else {\r
+       *q++ = '\r';\r
+       *q++ = *p++;\r
+      }\r
+    } else {\r
+      *q++ = *p++;\r
+    }\r
+  }\r
+  *q = NULLCHAR;\r
+  strncpy(errorTitle, title, sizeof(errorTitle));\r
+  errorTitle[sizeof(errorTitle) - 1] = '\0';\r
+  \r
+  if (modal) {\r
+    MessageBox(NULL, errorMessage, errorTitle, MB_OK|MB_ICONEXCLAMATION);\r
+  } else {\r
+    lpProc = MakeProcInstance((FARPROC)ErrorDialog, hInst);\r
+    CreateDialog(hInst, MAKEINTRESOURCE(DLG_Error),\r
+                hwndMain, (DLGPROC)lpProc);\r
+    FreeProcInstance(lpProc);\r
+  }\r
+}\r
+\r
 VOID\r
 ErrorPopDown()\r
 {\r
@@ -4964,6 +5004,7 @@ ErrorDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
       rChild.top + boardRect.top - (rChild.bottom - rChild.top), \r
       0, 0, SWP_NOZORDER|SWP_NOSIZE);\r
     errorDialog = hDlg;\r
+    SetWindowText(hDlg, errorTitle);\r
     hwndText = GetDlgItem(hDlg, OPT_ErrorText);\r
     SetDlgItemText(hDlg, OPT_ErrorText, errorMessage);\r
     return FALSE;\r
@@ -6316,31 +6357,8 @@ DisplayError(char *str, int error)
       }\r
     }\r
   }\r
-  p = buf;\r
-  q = errorMessage;\r
-  while (*p) {\r
-    if (*p == '\n') {\r
-      if (hwndMain != NULL /*!!?*/) {\r
-        *q++ = '\r';\r
-        *q++ = *p++;\r
-      } else {\r
-       *q++ = ' ';\r
-        p++;\r
-      }\r
-    } else {\r
-      *q++ = *p++;\r
-    }\r
-  }\r
-  *q = NULLCHAR;\r
   \r
-  if (hwndMain == NULL) {\r
-    MessageBox(NULL, errorMessage, "Error", MB_OK|MB_ICONEXCLAMATION);\r
-  } else {\r
-    lpProc = MakeProcInstance((FARPROC)ErrorDialog, hInst);\r
-    CreateDialog(hInst, MAKEINTRESOURCE(DLG_Error),\r
-      hwndMain, (DLGPROC)lpProc);\r
-    FreeProcInstance(lpProc);\r
-  }\r
+  ErrorPopUp("Error", buf);\r
 }\r
 \r
 \r
@@ -6351,7 +6369,7 @@ DisplayMoveError(char *str)
   ClearHighlights();\r
   DrawPosition(FALSE, NULL);\r
   if (appData.popupMoveErrors) {\r
-    DisplayError(str, 0);\r
+    ErrorPopUp("Error", str);\r
   } else {\r
     DisplayMessage(str, "");\r
     moveErrorMessageUp = TRUE;\r
@@ -6400,6 +6418,13 @@ DisplayInformation(char *str)
 }\r
 \r
 \r
+VOID\r
+DisplayNote(char *str)\r
+{\r
+  ErrorPopUp("Note", str);\r
+}\r
+\r
+\r
 typedef struct {\r
   char *title, *question, *replyPrefix;\r
   ProcRef pr;\r
index b31b64f..bc864fe 100644 (file)
--- 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;