From: Arun Persaud Date: Wed, 4 Nov 2009 03:24:56 +0000 (-0800) Subject: fixed problems in mouse handler from merge latest merge X-Git-Tag: gtk-20091122~5 X-Git-Url: http://winboard.nl/cgi-bin?p=xboard.git;a=commitdiff_plain;h=8c4c0bf587788e3cb10e3f47e21f2acd7c5816d6 fixed problems in mouse handler from merge latest merge --- diff --git a/backend.c b/backend.c index 3dce31a..ce49de2 100755 --- a/backend.c +++ b/backend.c @@ -5564,12 +5564,12 @@ UserMoveEvent(fromX, fromY, toX, toY, promoChar) FinishMove if the first part succeeded. Calls that do not need to do anything in between, can call this routine the old way. */ - ChessMove moveType = UserMoveTest(fromX, fromY, toX, toY, promoChar, FALSE); -if(appData.debugMode) fprintf(debugFP, "moveType 4 = %d, promochar = %x\n", moveType, promoChar); - if(moveType == AmbiguousMove) - DrawPosition(FALSE, boards[currentMove]); - else if(moveType != ImpossibleMove && moveType != Comment) - FinishMove(moveType, fromX, fromY, toX, toY, promoChar); + ChessMove moveType = UserMoveTest(fromX, fromY, toX, toY, promoChar, FALSE); + if(appData.debugMode) fprintf(debugFP, "moveType 4 = %d, promochar = %x\n", moveType, promoChar); + if(moveType == AmbiguousMove) + DrawPosition(FALSE, boards[currentMove]); + else if(moveType != ImpossibleMove && moveType != Comment) + FinishMove(moveType, fromX, fromY, toX, toY, promoChar); } void LeftClick(ClickType clickType, int xPix, int yPix) diff --git a/callback.c b/callback.c index 0f481f0..d961305 100644 --- a/callback.c +++ b/callback.c @@ -826,177 +826,25 @@ void UserMoveProc(window, event, data) GdkEvent *event; gpointer data; { - int x, y; - Boolean saveAnimate; - static int second = 0; - if (errorExitStatus != -1) return; - if (event->type == GDK_BUTTON_PRESS) ErrorPopDown(); - - if (promotionUp) + if (promotionUp) { - if (event->type == GDK_BUTTON_PRESS) + if (event->type == GDK_BUTTON_PRESS) { - /* todo add promotionshellwidget - XtPopdown(promotionShell); - XtDestroyWidget(promotionShell); */ promotionUp = False; ClearHighlights(); fromX = fromY = -1; } - else + else { return; } } - - x = EventToSquare( (int)event->button.x, BOARD_WIDTH ); - y = EventToSquare( (int)event->button.y, BOARD_HEIGHT ); - if (!flipView && y >= 0) - { - y = BOARD_HEIGHT - 1 - y; - } - if (flipView && x >= 0) - { - x = BOARD_WIDTH - 1 - x; - } - - if (fromX == -1) - { - if (event->type == ButtonPress) - { - /* First square */ - if (OKToStartUserMove(x, y)) - { - fromX = x; - fromY = y; - second = 0; - DragPieceBegin(event->button.x, event->button.y); - if (appData.highlightDragging) - { - SetHighlights(x, y, -1, -1); - } - } - } - return; - } - - /* fromX != -1 */ - if (event->type == GDK_BUTTON_PRESS && gameMode != EditPosition && - x >= 0 && y >= 0) { - ChessSquare fromP; - ChessSquare toP; - /* Check if clicking again on the same color piece */ - fromP = boards[currentMove][fromY][fromX]; - toP = boards[currentMove][y][x]; - if ((WhitePawn <= fromP && fromP <= WhiteKing && - WhitePawn <= toP && toP <= WhiteKing) || - (BlackPawn <= fromP && fromP <= BlackKing && - BlackPawn <= toP && toP <= BlackKing)) { - /* Clicked again on same color piece -- changed his mind */ - second = (x == fromX && y == fromY); - if (appData.highlightDragging) { - SetHighlights(x, y, -1, -1); - } else { - ClearHighlights(); - } - if (OKToStartUserMove(x, y)) { - fromX = x; - fromY = y; - DragPieceBegin(event->button.x, event->button.y); - } - return; - } - } - - if (event->type == GDK_BUTTON_RELEASE && x == fromX && y == fromY) - { - DragPieceEnd(event->button.x, event->button.y); - if (appData.animateDragging) - { - /* Undo animation damage if any */ - DrawPosition(FALSE, NULL); - } - if (second) - { - /* Second up/down in same square; just abort move */ - second = 0; - fromX = fromY = -1; - ClearHighlights(); - gotPremove = 0; - ClearPremoveHighlights(); - } - else - { - /* First upclick in same square; start click-click mode */ - SetHighlights(x, y, -1, -1); - } - return; - } - - /* Completed move */ - toX = x; - toY = y; - saveAnimate = appData.animate; - - if (event->type == GDK_BUTTON_PRESS) - { - /* Finish clickclick move */ - if (appData.animate || appData.highlightLastMove) - { - SetHighlights(fromX, fromY, toX, toY); - } - else - { - ClearHighlights(); - } - } - else - { - /* Finish drag move */ - if (appData.highlightLastMove) - { - SetHighlights(fromX, fromY, toX, toY); - } - else - { - ClearHighlights(); - } - DragPieceEnd(event->button.x, event->button.y); - /* Don't animate move and drag both */ - appData.animate = FALSE; - } - - if (IsPromotion(fromX, fromY, toX, toY)) - { - if (appData.alwaysPromoteToQueen) - { - UserMoveEvent(fromX, fromY, toX, toY, 'q'); - if (!appData.highlightLastMove || gotPremove) ClearHighlights(); - if (gotPremove) SetPremoveHighlights(fromX, fromY, toX, toY); - fromX = fromY = -1; - } - else - { - SetHighlights(fromX, fromY, toX, toY); - PromotionPopUp(); - } - } - else - { - UserMoveEvent(fromX, fromY, toX, toY, NULLCHAR); - - if (!appData.highlightLastMove || gotPremove) ClearHighlights(); - if (gotPremove) SetPremoveHighlights(fromX, fromY, toX, toY); - fromX = fromY = -1; - } - - appData.animate = saveAnimate; - if (appData.animate || appData.animateDragging) { - /* Undo animation damage if needed */ - DrawPosition(FALSE, NULL); - } + + // [HGM] mouse: the rest of the mouse handler is moved to the backend, and called here + if(event->type == GDK_BUTTON_PRESS) LeftClick(Press, (int)event->button.x, (int)event->button.y); + if(event->type == GDK_BUTTON_RELEASE) LeftClick(Release, (int)event->button.x, (int)event->button.y); return; }