From: H.G.Muller Date: Mon, 21 Mar 2016 11:25:02 +0000 (+0100) Subject: Repair flashing of moved piece (XB) X-Git-Url: http://winboard.nl/cgi-bin?p=xboard.git;a=commitdiff_plain;h=a360a8beeeff933c8517413eace57a144362df65 Repair flashing of moved piece (XB) The flashing was not working (at least in GTK), because the redraw of the square needed even processing to show something. So the draw/erase loop that does the flashing needs to call DoEvents() to make things visible. This however could lead to recursive processing of LeftClick, as the press of a click-click move already enters the move and starts the flashing, so that the release usually comes before the press processing has finished. Which would cause it to be interpreted as a second move identical to the first. A static flag inside LeftClick now makes it ignore clicks during flashing, which is just what we had to do with the release anyway. Flashing should be suppressed during sweep-selection under-promotion. --- diff --git a/backend.c b/backend.c index 5a1780d..9b81c39 100644 --- a/backend.c +++ b/backend.c @@ -7525,11 +7525,13 @@ LeftClick (ClickType clickType, int xPix, int yPix) { int x, y; Boolean saveAnimate; - static int second = 0, promotionChoice = 0, clearFlag = 0, sweepSelecting = 0; + static int second = 0, promotionChoice = 0, clearFlag = 0, sweepSelecting = 0, flashing = 0, saveFlash; char promoChoice = NULLCHAR; ChessSquare piece; static TimeMark lastClickTime, prevClickTime; + if(flashing) return; + x = EventToSquare(xPix, BOARD_WIDTH); y = EventToSquare(yPix, BOARD_HEIGHT); if (!flipView && y >= 0) { @@ -7788,6 +7790,7 @@ LeftClick (ClickType clickType, int xPix, int yPix) if(gameInfo.variant != VariantChuChess && PieceToChar(CHUPROMOTED(piece)) == '+') promoSweep = CHUPROMOTED(piece); selectFlag = 0; lastX = xPix; lastY = yPix; ReportClick("put", x, y); // extra put to prompt engine for 'choice' command + saveFlash = appData.flashCount; appData.flashCount = 0; Sweep(0); // Pawn that is going to promote: preview promotion piece sweepSelecting = 1; DisplayMessage("", _("Pull pawn backwards to under-promote")); @@ -7804,7 +7807,7 @@ LeftClick (ClickType clickType, int xPix, int yPix) MarkTargetSquares(1); } else if(sweepSelecting) { // this must be the up-click corresponding to the down-click that started the sweep sweepSelecting = 0; appData.animate = FALSE; // do not animate, a selected piece already on to-square - *promoRestrict = 0; + *promoRestrict = 0; appData.flashCount = saveFlash; if (appData.animate || appData.highlightLastMove) { SetHighlights(fromX, fromY, toX, toY); } else { @@ -7898,6 +7901,7 @@ LeftClick (ClickType clickType, int xPix, int yPix) PromotionPopUp(promoChoice); } else { int oldMove = currentMove; + flashing = 1; // prevent recursive calling (by release of to-click) while flashing piece UserMoveEvent(fromX, fromY, toX, toY, promoChoice); if (!appData.highlightLastMove || gotPremove) ClearHighlights(); if (gotPremove) SetPremoveHighlights(fromX, fromY, toX, toY); @@ -7905,6 +7909,7 @@ LeftClick (ClickType clickType, int xPix, int yPix) Explode(boards[currentMove-1], fromX, fromY, toX, toY)) DrawPosition(TRUE, boards[currentMove]); fromX = fromY = -1; + flashing = 0; } appData.animate = saveAnimate; if (appData.animate || appData.animateDragging) { diff --git a/board.c b/board.c index cb6ae94..000af83 100644 --- a/board.c +++ b/board.c @@ -821,9 +821,11 @@ DrawSquare (int row, int column, ChessSquare piece, int do_flash) for (i=0; i