Implement entering gating moves with mouse
[xboard.git] / xboard.c
index 59796c7..3a39fe0 100644 (file)
--- a/xboard.c
+++ b/xboard.c
@@ -5431,7 +5431,7 @@ void PromotionCallback(w, client_data, call_data)
     } else if (strcmp(name, _("Knight")) == 0) {
        promoChar = 'n';
     } else if (strcmp(name, _("Promote")) == 0) {
-       promoChar = '^';
+       promoChar = '+';
     } else if (strcmp(name, _("Defer")) == 0) {
        promoChar = '=';
     } else {
@@ -5815,7 +5815,7 @@ SendPositionSelection(Widget w, Atom *selection, Atom *target,
      * automatically call XtFree on the value returned.  So have to
      * make a copy of it allocated with XtMalloc */
     selection_tmp= XtMalloc(strlen(selected_fen_position)+16);
-    safeStrCpy(selection_tmp, selected_fen_position, sizeof(selection_tmp)/sizeof(selection_tmp[0]) );
+    safeStrCpy(selection_tmp, selected_fen_position, strlen(selected_fen_position)+16 );
 
     *value_return=selection_tmp;
     *length_return=strlen(selection_tmp);
@@ -9048,6 +9048,17 @@ DragPieceBegin(x, y)
            XCopyArea(xDisplay, xBoardWindow, player.saveBuf, player.blitGC,
                     corner.x, corner.y, squareSize, squareSize,
                     0, 0); // [HGM] zh: unstack in stead of grab
+           if(gatingPiece != EmptySquare) {
+               /* Kludge alert: When gating we want the introduced
+                  piece to appear on the from square. To generate an
+                  image of it, we draw it on the board, copy the image,
+                  and draw the original piece again. */
+               ChessSquare piece = boards[currentMove][boardY][boardX];
+               DrawSquare(boardY, boardX, gatingPiece, 0);
+               XCopyArea(xDisplay, xBoardWindow, player.saveBuf, player.blitGC,
+                    corner.x, corner.y, squareSize, squareSize, 0, 0);
+               DrawSquare(boardY, boardX, piece, 0);
+           }
        damage[0][boardY][boardX] = True;
     } else {
        player.dragActive = False;