Improve arrow drawing
[xboard.git] / backend.c
index 8021102..9ac6a58 100644 (file)
--- a/backend.c
+++ b/backend.c
@@ -6932,7 +6932,7 @@ MarkTargetSquares (int clear)
       for(x=0; x<BOARD_WIDTH; x++) for(y=0; y<BOARD_HEIGHT; y++) if(marker[y][x] == 1) marker[y][x] = 0;
     }
   }
-  DrawPosition(TRUE, NULL);
+  DrawPosition(FALSE, NULL);
 }
 
 int
@@ -7073,6 +7073,8 @@ LeftClick (ClickType clickType, int xPix, int yPix)
                }
                if (appData.highlightDragging) {
                    SetHighlights(fromX, fromY, -1, -1);
+               } else {
+                   ClearHighlights();
                }
            } else fromX = fromY = -1;
            return;
@@ -7174,7 +7176,6 @@ LeftClick (ClickType clickType, int xPix, int yPix)
     toX = x;
     toY = y;
     saveAnimate = appData.animate;
-    MarkTargetSquares(1);
     if (clickType == Press) {
        if(gameMode == EditPosition && boards[currentMove][fromY][fromX] == EmptySquare) {
            // must be Edit Position mode with empty-square selected
@@ -7182,16 +7183,21 @@ LeftClick (ClickType clickType, int xPix, int yPix)
            if(x >= BOARD_LEFT && x < BOARD_RGHT) clearFlag = 1; // and defer click-click move of empty-square to up-click
            return;
        }
-       if(appData.sweepSelect && HasPromotionChoice(fromX, fromY, toX, toY, &promoChoice, FALSE)) {
+       if(HasPromotionChoice(fromX, fromY, toX, toY, &promoChoice, FALSE)) {
+         if(appData.sweepSelect) {
            ChessSquare piece = boards[currentMove][fromY][fromX];
+           ChessSquare victim = boards[currentMove][toY][toX];
+           boards[currentMove][toY][toX] = piece; // kludge: make sure there is something to grab for drag
            DragPieceBegin(xPix, yPix, TRUE); dragging = 1;
+           boards[currentMove][toY][toX] = victim;
            promoSweep = defaultPromoChoice;
            if(PieceToChar(PROMOTED piece) == '+') promoSweep = PROMOTED piece;
            selectFlag = 0; lastX = xPix; lastY = yPix;
            Sweep(0); // Pawn that is going to promote: preview promotion piece
            DisplayMessage("", _("Pull pawn backwards to under-promote"));
            DrawPosition(FALSE, boards[currentMove]);
-           return;
+         }
+         return; // promo popup appears on up-click
        }
        /* Finish clickclick move */
        if (appData.animate || appData.highlightLastMove) {
@@ -7210,6 +7216,7 @@ LeftClick (ClickType clickType, int xPix, int yPix)
        /* Don't animate move and drag both */
        appData.animate = FALSE;
     }
+    MarkTargetSquares(1);
 
     // moves into holding are invalid for now (except in EditPosition, adapting to-square)
     if(x >= 0 && x < BOARD_LEFT || x >= BOARD_RGHT) {