Merge branch 'master' into v4.6.x
authorArun Persaud <arun@nubati.net>
Mon, 27 Feb 2012 03:07:54 +0000 (19:07 -0800)
committerArun Persaud <arun@nubati.net>
Mon, 27 Feb 2012 03:07:54 +0000 (19:07 -0800)
args.h
backend.c
backend.h
engineoutput.c
po/Makefile.in.in
winboard/language.txt
winboard/language/nederlands.lng
winboard/winboard.c
xboard.c
xoptions.c

diff --git a/args.h b/args.h
index 613f0a4..713e2ab 100644 (file)
--- a/args.h
+++ b/args.h
@@ -715,7 +715,7 @@ ArgDescriptor argDescriptors[] = {
   { "useInternalWrap", ArgTrue, (void *) &appData.useInternalWrap, FALSE, INVALID }, /* noJoin usurps this if set */
 
   // [HGM] placement: put all window layouts last in ini file, but man X,Y before all others
-  { "minX", ArgZ, (void *) &minX, FALSE, INVALID }, // [HGM] placement: to make suer auxialary windows can be placed
+  { "minX", ArgZ, (void *) &minX, FALSE, INVALID }, // [HGM] placement: to make sure auxiliary windows can be placed
   { "minY", ArgZ, (void *) &minY, FALSE, INVALID },
   { "winWidth",  ArgInt, (void *) &wpMain.width,  TRUE, INVALID }, // [HGM] placement: dummies to remember right & bottom
   { "winHeight", ArgInt, (void *) &wpMain.height, TRUE, INVALID }, //       for attaching auxiliary windows to them
index 3cd2f0c..f00997e 100644 (file)
--- a/backend.c
+++ b/backend.c
@@ -1485,6 +1485,8 @@ MatchEvent (int mode)
        NextMatchGame();
 }
 
+char *comboLine = NULL; // [HGM] recent: WinBoard's first-engine combobox line
+
 void
 InitBackEnd3 P((void))
 {
@@ -1498,7 +1500,7 @@ InitBackEnd3 P((void))
        free(programVersion);
        programVersion = (char*) malloc(8 + strlen(PACKAGE_STRING) + strlen(first.tidy));
        sprintf(programVersion, "%s + %s", PACKAGE_STRING, first.tidy);
-       FloatToFront(&appData.recentEngineList, appData.firstChessProgram);
+       FloatToFront(&appData.recentEngineList, comboLine ? comboLine : appData.firstChessProgram);
     }
 
     if (appData.icsActive) {
@@ -4507,7 +4509,10 @@ ParseBoard12 (char *string)
         r = boards[moveNum][CASTLING][5] = initialRights[5];
     }
     /* [HGM] e.p. rights. Assume that ICS sends file number here? */
-    boards[moveNum][EP_STATUS] = double_push == -1 ? EP_NONE : double_push + BOARD_LEFT;
+    boards[moveNum][EP_STATUS] = EP_NONE;
+    if(str[0] == 'P') boards[moveNum][EP_STATUS] = EP_PAWN_MOVE;
+    if(strchr(move_str, 'x')) boards[moveNum][EP_STATUS] = EP_CAPTURE;
+    if(double_push !=  -1) boards[moveNum][EP_STATUS] = double_push + BOARD_LEFT;
 
 
     if (ics_getting_history == H_GOT_REQ_HEADER ||
index 561a0b3..3fef1ea 100644 (file)
--- a/backend.h
+++ b/backend.h
@@ -436,6 +436,7 @@ extern ChessProgramStats programStats;
 extern int opponentKibitzes; // used by wengineo.c
 extern int errorExitStatus;
 extern char *recentEngines;
+extern char *comboLine;
 void SettingsPopUp P((ChessProgramState *cps)); // [HGM] really in front-end, but CPS not known in frontend.h
 int WaitForEngine P((ChessProgramState *cps, DelayedEventCallback x));
 void Load P((ChessProgramState *cps, int n));
index caf8f8b..35f3c69 100644 (file)
 # define  _(s) gettext (s)
 # define N_(s) gettext_noop (s)
 #else
-# define  _(s) (s)
+# ifdef WIN32
+#  define  _(s) T_(s)
+#  undef  ngettext
+#  define  ngettext(s,p,n) T_(p)
+# else
+#  define  _(s) (s)
+# endif
 # define N_(s)  s
 #endif
 
index 83d8838..f2a4217 100644 (file)
@@ -265,6 +265,8 @@ install-data-yes: all
 
 install-strip: install
 
+install-info install-dvi install-ps install-pdf install-html:
+
 installdirs: installdirs-exec installdirs-data
 installdirs-exec:
 installdirs-data: installdirs-data-@USE_NLS@
index bf65ac0..9e56f82 100644 (file)
@@ -612,7 +612,8 @@ EVALUATION GRAPH
 \r
 ENGINE OUTPUT WINDOW\r
 \r
-"Engine output" === ""\r
+"Engine Output" === ""\r
+"%s (%d reversible plies)" === ""\r
 "Engine #1" === ""\r
 "NPS" === ""\r
 "Engine #2" === ""\r
index 1546de1..853b9da 100644 (file)
@@ -586,7 +586,8 @@ EVALUATION GRAPH
 \r
 ENGINE OUTPUT WINDOW\r
 \r
-"Engine output" === "Overwogen zetten"\r
+"Engine Output" === "Overwogen zetten"\r
+"%s (%d reversible plies)" === "%s (%d omkeerbare zetten)"\r
 "Engine #1" === "Programma #1"\r
 "NPS" === ""\r
 "Engine #2" === "Programma #1"\r
index 5c9bc1c..9cdd4b9 100644 (file)
@@ -497,6 +497,7 @@ TranslateMenus(int addLanguage)
 void\r
 RecentEngineMenu (char *s)\r
 {\r
+    if(appData.icsActive) return;\r
     if(appData.recentEngines > 0 && *s) { // feature is on, and list non-empty\r
        HMENU mainMenu = GetMenu(hwndMain);\r
        HMENU subMenu = GetSubMenu(mainMenu, 5); // Engine menu\r
@@ -6181,6 +6182,7 @@ StartupDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
         safeStrCpy(buf, "/fcp=", sizeof(buf)/sizeof(buf[0]) );\r
        GetDlgItemText(hDlg, OPT_ChessEngineName, buf + strlen(buf), sizeof(buf) - strlen(buf));\r
         p = buf;\r
+       comboLine = strdup(p+5); // [HGM] recent: remember complete line of first combobox\r
        ParseArgs(StringGet, &p);\r
        safeStrCpy(buf, singleList ? "/fcp=" : "/scp=", sizeof(buf)/sizeof(buf[0]) );\r
        GetDlgItemText(hDlg, OPT_SecondChessEngineName, buf + strlen(buf), sizeof(buf) - strlen(buf));\r
index 0b3c7f4..84e0aec 100644 (file)
--- a/xboard.c
+++ b/xboard.c
@@ -273,6 +273,7 @@ void CreateGrid P((void));
 int EventToSquare P((int x, int limit));
 void DrawSquare P((int row, int column, ChessSquare piece, int do_flash));
 void EventProc P((Widget widget, caddr_t unused, XEvent *event));
+void DelayedDrag P((void));
 void MoveTypeInProc P((Widget widget, caddr_t unused, XEvent *event));
 void HandleUserMove P((Widget w, XEvent *event,
                     String *prms, Cardinal *nprms));
@@ -1555,6 +1556,7 @@ ParseCommPortSettings (char *s)
 }
 
 extern Widget engineOutputShell;
+int frameX, frameY;
 
 void
 GetActualPlacement (Widget wg, WindowPlacement *wp)
@@ -1562,20 +1564,20 @@ GetActualPlacement (Widget wg, WindowPlacement *wp)
   Arg args[16];
   Dimension w, h;
   Position x, y;
-  int i;
+  XWindowAttributes winAt;
+  Window win, dummy;
+  int i, rx, ry;
 
   if(!wg) return;
 
-    i = 0;
-    XtSetArg(args[i], XtNx, &x); i++;
-    XtSetArg(args[i], XtNy, &y); i++;
-    XtSetArg(args[i], XtNwidth, &w); i++;
-    XtSetArg(args[i], XtNheight, &h); i++;
-    XtGetValues(wg, args, i);
-    wp->x = x - 4;
-    wp->y = y - 23;
-    wp->height = h;
-    wp->width = w;
+    win = XtWindow(wg);
+    XGetWindowAttributes(xDisplay, win, &winAt); // this works, where XtGetValues on XtNx, XtNy does not!
+    XTranslateCoordinates (xDisplay, win, winAt.root, -winAt.border_width, -winAt.border_width, &rx, &ry, &dummy);
+    wp->x = rx - winAt.x;
+    wp->y = ry - winAt.y;
+    wp->height = winAt.height;
+    wp->width = winAt.width;
+    frameX = winAt.x; frameY = winAt.y; // remember to decide if windows touch
 }
 
 void
@@ -1745,6 +1747,9 @@ InitDrawingSizes (BoardSize boardSize, int flags)
     shellArgs[4].value = shellArgs[2].value = w;
     shellArgs[5].value = shellArgs[3].value = h;
     XtSetValues(shellWidget, &shellArgs[0], 6);
+
+    XSync(xDisplay, False);
+    DelayedDrag();
   }
 
     // [HGM] pieces: tailor piece bitmaps to needs of specific variant
@@ -1819,6 +1824,7 @@ InitDrawingSizes (BoardSize boardSize, int flags)
       }
     }
     oldMono = -10; // kludge to force recreation of animation masks
+    oldVariant = gameInfo.variant;
   }
 #if HAVE_LIBXPM
   if(appData.monoMode != oldMono)
@@ -2662,6 +2668,8 @@ XBoard square size (hint): %d\n\
     /* end why */
     XtAddEventHandler(formWidget, KeyPressMask, False,
                      (XtEventHandler) MoveTypeInProc, NULL);
+    XtAddEventHandler(shellWidget, StructureNotifyMask, False,
+                     (XtEventHandler) EventProc, NULL);
 
     /* [AS] Restore layout */
     if( wpMoveHistory.visible ) {
@@ -3897,7 +3905,7 @@ MenuBarSelect (Widget w, caddr_t addr, caddr_t index)
 static void
 MenuEngineSelect (Widget w, caddr_t addr, caddr_t index)
 {
-    RecentEngineEvent((int) addr);
+    RecentEngineEvent((int) (intptr_t) addr);
 }
 
 void
@@ -3909,7 +3917,7 @@ AppendEnginesToMenu (Widget menu, char *list)
     Arg args[16];
     char *p;
 
-    if(appData.recentEngines <= 0) return;
+    if(appData.icsActive || appData.recentEngines <= 0) return;
     recentEngines = strdup(list);
     j = 0;
     XtSetArg(args[j], XtNleftMargin, 20);   j++;
@@ -3922,7 +3930,7 @@ AppendEnginesToMenu (Widget menu, char *list)
        entry = XtCreateManagedWidget("engine", smeBSBObjectClass, menu, args, j+1);
        XtAddCallback(entry, XtNcallback,
                          (XtCallbackProc) MenuEngineSelect,
-                         (caddr_t) i);
+                         (caddr_t) (intptr_t) i);
        i++; *p = '\n'; list = p + 1;
     }
 }
@@ -4646,6 +4654,75 @@ DrawSquare (int row, int column, ChessSquare piece, int do_flash)
     }
 }
 
+double
+Fraction (int x, int start, int stop)
+{
+   double f = ((double) x - start)/(stop - start);
+   if(f > 1.) f = 1.; else if(f < 0.) f = 0.;
+   return f;
+}
+
+static WindowPlacement wpNew;
+
+void
+CoDrag (Widget sh, WindowPlacement *wp)
+{
+    Arg args[16];
+    int j=0, touch=0, fudge = 2;
+    GetActualPlacement(sh, wp);
+    if(abs(wpMain.x + wpMain.width + 2*frameX - wp->x)         < fudge) touch = 1; else // right touch
+    if(abs(wp->x + wp->width + 2*frameX - wpMain.x)            < fudge) touch = 2; else // left touch
+    if(abs(wpMain.y + wpMain.height + frameX + frameY - wp->y) < fudge) touch = 3; else // bottom touch
+    if(abs(wp->y + wp->height + frameX + frameY - wpMain.y)    < fudge) touch = 4;      // top touch
+    if(!touch ) return; // only windows that touch co-move
+    if(touch < 3 && wpNew.height != wpMain.height) { // left or right and height changed
+       int heightInc = wpNew.height - wpMain.height;
+       double fracTop = Fraction(wp->y, wpMain.y, wpMain.y + wpMain.height + frameX + frameY);
+       double fracBot = Fraction(wp->y + wp->height + frameX + frameY + 1, wpMain.y, wpMain.y + wpMain.height + frameX + frameY);
+       wp->y += fracTop * heightInc;
+       heightInc = (int) (fracBot * heightInc) - (int) (fracTop * heightInc);
+       if(heightInc) XtSetArg(args[j], XtNheight, wp->height + heightInc), j++;
+    } else if(touch > 2 && wpNew.width != wpMain.width) { // top or bottom and width changed
+       int widthInc = wpNew.width - wpMain.width;
+       double fracLeft = Fraction(wp->x, wpMain.x, wpMain.x + wpMain.width + 2*frameX);
+       double fracRght = Fraction(wp->x + wp->width + 2*frameX + 1, wpMain.x, wpMain.x + wpMain.width + 2*frameX);
+       wp->y += fracLeft * widthInc;
+       widthInc = (int) (fracRght * widthInc) - (int) (fracLeft * widthInc);
+       if(widthInc) XtSetArg(args[j], XtNwidth, wp->width + widthInc), j++;
+    }
+    wp->x += wpNew.x - wpMain.x;
+    wp->y += wpNew.y - wpMain.y;
+    if(touch == 1) wp->x += wpNew.width - wpMain.width; else
+    if(touch == 3) wp->y += wpNew.height - wpMain.height;
+    XtSetArg(args[j], XtNx, wp->x); j++;
+    XtSetArg(args[j], XtNy, wp->y); j++;
+    XtSetValues(sh, args, j);
+}
+
+void
+DragProc ()
+{
+       GetActualPlacement(shellWidget, &wpNew);
+       if(wpNew.x == wpMain.x && wpNew.y == wpMain.y && // not moved
+          wpNew.width == wpMain.width && wpNew.height == wpMain.height) // not sized
+           return; // false alarm
+       if(EngineOutputIsUp()) CoDrag(engineOutputShell, &wpEngineOutput);
+       if(MoveHistoryIsUp()) CoDrag(shells[7], &wpMoveHistory);
+       if(EvalGraphIsUp()) CoDrag(evalGraphShell, &wpEvalGraph);
+       if(GameListIsUp()) CoDrag(gameListShell, &wpGameList);
+       wpMain = wpNew;
+       XDrawPosition(boardWidget, True, NULL);
+}
+
+
+void
+DelayedDrag ()
+{
+    static XtIntervalId delayedDragID = 0;
+    if(delayedDragID) XtRemoveTimeOut(delayedDragID); // cancel pending
+    delayedDragID =
+      XtAppAddTimeOut(appContext, 50, (XtTimerCallbackProc) DragProc, (XtPointer) 0); // and schedule new one 50 msec later
+}
 
 /* Why is this needed on some versions of X? */
 void
@@ -4653,8 +4730,11 @@ EventProc (Widget widget, caddr_t unused, XEvent *event)
 {
     if (!XtIsRealized(widget))
       return;
-
     switch (event->type) {
+      case ConfigureNotify: // main window is being dragged: drag attached windows with it
+       if(appData.useStickyWindows)
+           DelayedDrag(); // as long as events keep coming in faster than 50 msec, they destroy each other
+       break;
       case Expose:
        if (event->xexpose.count > 0) return;  /* no clipping is done */
        XDrawPosition(widget, True, NULL);
@@ -6595,7 +6675,11 @@ _("%s%s\n\n"
 "Enhancements Copyright 1992-2012 Free Software Foundation\n"
 "Enhancements Copyright 2005 Alessandro Scotti\n\n"
 "%s is free software and carries NO WARRANTY;"
-"see the file COPYING for more information."),
+"see the file COPYING for more information.\n\n"
+"Visit XBoard on the web at: http://www.gnu.org/software/xboard/\n"
+"Check out the newest features at: http://www.gnu.org/software/xboard/whats_new.html\n\n"
+"Report bugs via email at: <bug-xboard@gnu.org>\n\n"
+  ),
            programVersion, zippy, PACKAGE);
     ErrorPopUp(_("About XBoard"), buf, FALSE);
 }
index e2646c1..42aacb9 100644 (file)
@@ -434,6 +434,7 @@ Option generalOptions[] = {
 { 0,  0, 0, NULL, (void*) &appData.showEvalInMoveHistory, "", NULL, CheckBox, N_("Scores in Move List") },
 { 0,  0, 0, NULL, (void*) &appData.showCoords, "", NULL, CheckBox, N_("Show Coordinates") },
 { 0,  0, 0, NULL, (void*) &appData.markers, "", NULL, CheckBox, N_("Show Target Squares") },
+{ 0,  0, 0, NULL, (void*) &appData.useStickyWindows, "", NULL, CheckBox, N_("Sticky Windows") },
 { 0,  0, 0, NULL, (void*) &appData.testLegality, "", NULL, CheckBox, N_("Test Legality") },
 { 0, 0, 10, NULL, (void*) &appData.flashCount, "", NULL, Spin, N_("Flash Moves (0 = no flashing):") },
 { 0, 1, 10, NULL, (void*) &appData.flashRate, "", NULL, Spin, N_("Flash Rate (high = fast):") },