From: Arun Persaud Date: Wed, 4 Nov 2009 02:36:55 +0000 (-0800) Subject: Merge commit 'v4.4.1.20091019' into gtk X-Git-Tag: gtk-20091122~8 X-Git-Url: http://winboard.nl/cgi-bin?p=xboard.git;a=commitdiff_plain;h=715036074c2087caa603bd1aa489fa88c03e7d02 Merge commit 'v4.4.1.20091019' into gtk Conflicts: backend.c configure.ac xboard.c --- 715036074c2087caa603bd1aa489fa88c03e7d02 diff --cc backend.c index 81d22e6,e2aa771..37521d7 mode 100644,100755..100755 --- a/backend.c +++ b/backend.c @@@ -1039,30 -1038,31 +1038,31 @@@ ParseTimeControl(tc, ti, mps void InitBackEnd2() { - if (appData.debugMode) { - fprintf(debugFP, "%s\n", programVersion); - } + if (appData.debugMode) { + fprintf(debugFP, "%s\n", programVersion); + } - set_cont_sequence(appData.wrapContSeq); - if (appData.matchGames > 0) { - appData.matchMode = TRUE; - } else if (appData.matchMode) { - appData.matchGames = 1; - } - if(appData.matchMode && appData.sameColorGames > 0) /* [HGM] alternate: overrule matchGames */ - appData.matchGames = appData.sameColorGames; - if(appData.rewindIndex > 1) { /* [HGM] autoinc: rewind implies auto-increment and overrules given index */ - if(appData.loadPositionIndex >= 0) appData.loadPositionIndex = -1; - if(appData.loadGameIndex >= 0) appData.loadGameIndex = -1; - } - Reset(TRUE, FALSE); - if (appData.noChessProgram || first.protocolVersion == 1) { - InitBackEnd3(); ++ set_cont_sequence(appData.wrapContSeq); + if (appData.matchGames > 0) { + appData.matchMode = TRUE; + } else if (appData.matchMode) { + appData.matchGames = 1; + } + if(appData.matchMode && appData.sameColorGames > 0) /* [HGM] alternate: overrule matchGames */ + appData.matchGames = appData.sameColorGames; + if(appData.rewindIndex > 1) { /* [HGM] autoinc: rewind implies auto-increment and overrules given index */ + if(appData.loadPositionIndex >= 0) appData.loadPositionIndex = -1; + if(appData.loadGameIndex >= 0) appData.loadGameIndex = -1; + } + Reset(TRUE, FALSE); + if (appData.noChessProgram || first.protocolVersion == 1) { + InitBackEnd3(); - } else { + } else { - /* kludge: allow timeout for initial "feature" commands */ - FreezeUI(); - DisplayMessage("", _("Starting chess program")); - ScheduleDelayedEvent(InitBackEnd3, FEATURE_TIMEOUT); - } + /* kludge: allow timeout for initial "feature" commands */ + FreezeUI(); + DisplayMessage("", _("Starting chess program")); + ScheduleDelayedEvent(InitBackEnd3, FEATURE_TIMEOUT); + } } void @@@ -3343,9 -3397,10 +3396,10 @@@ ParseBoard12(string char promoChar; int ranks=1, files=0; /* [HGM] ICS80: allow variable board size */ char *bookHit = NULL; // [HGM] book + Boolean weird = FALSE; fromX = fromY = toX = toY = -1; - + newGame = FALSE; if (appData.debugMode) @@@ -5147,8 -5259,11 +5259,11 @@@ UserMoveTest(fromX, fromY, toX, toY, pr return ImpossibleMove; } + pdown = boards[currentMove][fromY][fromX]; + pup = boards[currentMove][toY][toX]; + /* [HGM] If move started in holdings, it means a drop */ - if( fromX == BOARD_LEFT-2 || fromX == BOARD_RGHT+1) { + if( fromX == BOARD_LEFT-2 || fromX == BOARD_RGHT+1) { if( pup != EmptySquare ) return ImpossibleMove; if(appData.testLegality) { /* it would be more logical if LegalityTest() also figured out @@@ -6763,11 -7008,10 +7055,10 @@@ if(appData.debugMode) fprintf(debugFP, programStats.line_is_book = 1; SendProgramStatsToFrontend( cps, &programStats ); - - if (currentMove == forwardMostMove || gameMode==AnalyzeMode || + + if (currentMove == forwardMostMove || gameMode==AnalyzeMode || gameMode == AnalyzeFile || appData.icsEngineAnalyze) { DisplayMove(currentMove - 1); - DisplayAnalysis(); } return; } else if (sscanf(message,"stat01: %d " u64Display " %d %d %d %s", diff --cc callback.c index dcf4779,0000000..0f481f0 mode 100644,000000..100644 --- a/callback.c +++ b/callback.c @@@ -1,1019 -1,0 +1,1019 @@@ +#include +#include "common.h" +#include "xboard.h" +#include +#include "backend.h" + +#ifdef ENABLE_NLS +# define _(s) gettext (s) +# define N_(s) gettext_noop (s) +#else +# define _(s) (s) +# define N_(s) s +#endif + +extern GtkWidget *about; +extern GtkWidget *GUI_Window; +extern GtkWidget *GUI_Aspect; +extern GtkWidget *GUI_Menubar; +extern GtkWidget *GUI_Timer; +extern GtkWidget *GUI_Buttonbar; +extern GtkWidget *GUI_Board; + +extern char *programVersion; +extern int errorExitStatus; +extern int promotionUp; +extern int fromX; +extern int fromY; +extern int toX; +extern int toY; +extern int squareSize,lineGap; + +extern int LoadGamePopUp P((FILE *f, int gameNumber, char *title)); +extern int LoadPosition P((FILE *f, int gameNumber, char *title)); +extern int SaveGame P((FILE *f, int gameNumber, char *title)); +extern int SavePosition P((FILE *f, int gameNumber, char *title)); + +gboolean +ExposeProc(object, user_data) + GtkObject *object; + gpointer user_data; +{ + /* do resizing to a fixed aspect ratio */ + GtkRequisition w; + int totalh=0,nw,nh; + float ratio; + int boardWidth,boardHeight,old,new; + + nw=GTK_WIDGET(object)->allocation.width; + nh=GTK_WIDGET(object)->allocation.height; + + old=squareSize; + squareSize = nw/(BOARD_WIDTH*1.05+0.05); + + if(old!=squareSize) + { + lineGap = squareSize*0.05; + + boardWidth = lineGap + BOARD_WIDTH * (squareSize + lineGap); + boardHeight = lineGap + BOARD_HEIGHT * (squareSize + lineGap); + + /* get the height of the menus, etc. and calculate the aspect ratio */ + gtk_widget_size_request(GTK_WIDGET(GUI_Menubar), &w); + totalh += w.height; + gtk_widget_size_request(GTK_WIDGET(GUI_Timer), &w); + totalh += w.height; + gtk_widget_size_request(GTK_WIDGET(GUI_Buttonbar), &w); + totalh += w.height; + + ratio = ((float)totalh+boardHeight)/((float)boardWidth) ; + + gtk_widget_set_size_request(GTK_WIDGET(GUI_Board), + boardWidth,boardHeight); + + gtk_aspect_frame_set (GTK_ASPECT_FRAME(GUI_Aspect),0,0,ratio,TRUE); + + /* recreate pieces with new size... TODO: keep svg in memory and just recreate pixmap instead of reloading files */ + CreatePieces(); + } + return FALSE; /* return false, so that other expose events are called too */ +} + +void +QuitProc (object, user_data) + GtkObject *object; + gpointer user_data; +{ + gtk_main_quit(); + ExitEvent(0); +} + +/* Help Menu */ +void InfoProc(object, user_data) + GtkObject *object; + gpointer user_data; +{ + char buf[MSG_SIZ]; + snprintf(buf, sizeof(buf), "xterm -e info --directory %s --directory . -f %s &", + INFODIR, INFOFILE); + system(buf); + return; +} + +void ManProc(object, user_data) + GtkObject *object; + gpointer user_data; +{ + char buf[MSG_SIZ]; + snprintf(buf, sizeof(buf), "xterm -e man xboard &"); + system(buf); + return; +} + +void HintProc(object, user_data) + GtkObject *object; + gpointer user_data; +{ + HintEvent(); + return; +} + +void BookProc(object, user_data) + GtkObject *object; + gpointer user_data; +{ + BookEvent(); + return; +} + +void AboutProc (object, user_data) + GtkObject *object; + gpointer user_data; +{ + GtkWidget *about; + + const gchar *authors[] = {"Tim Mann ", + "John Chanak", + "Evan Welsh ", + "Elmar Bartel ", + "Jochen Wiedmann", + "Frank McIngvale", + "Hugh Fisher ", + "Allessandro Scotti", + "H.G. Muller ", + "Eric Mullins ", + "Arun Persaud "}; + + /* set up about window */ + about = GTK_WIDGET(gtk_about_dialog_new()); + + /* fill in some information */ + char buf[MSG_SIZ]; +#if ZIPPY + char *zippy = " (with Zippy code)"; +#else + char *zippy = ""; +#endif + sprintf(buf, "%s%s", programVersion, zippy); + + gtk_about_dialog_set_version(GTK_ABOUT_DIALOG(about),buf); + + gtk_about_dialog_set_copyright(GTK_ABOUT_DIALOG(about), + "Copyright 1991 Digital Equipment Corporation\n" + "Enhancements Copyright 1992-2009 Free Software Foundation\n" + "Enhancements Copyright 2005 Alessandro Scotti"); + gtk_about_dialog_set_website(GTK_ABOUT_DIALOG(about),"http://www.gnu.org/software/xboard/"); + gtk_about_dialog_set_authors(GTK_ABOUT_DIALOG(about),authors); + gtk_about_dialog_set_translator_credits(GTK_ABOUT_DIALOG(about), + " A. Alper (turkish)\n" + " A. Persaud (german)\n"); + + /* end set up about window */ + gtk_dialog_run(GTK_DIALOG (about)); + gtk_widget_destroy(about); +} + +/* End Help Menu */ + +void IcsClientProc(object, user_data) + GtkObject *object; + gpointer user_data; +{ + IcsClientEvent(); + return; +} + +/* + * File menu + */ + +void +LoadNextGameProc(object, user_data) + GtkObject *object; + gpointer user_data; +{ + ReloadGame(1); + return; +} + +void +LoadPrevGameProc(object, user_data) + GtkObject *object; + gpointer user_data; +{ + ReloadGame(-1); + return; +} + +void +ReloadGameProc(object, user_data) + GtkObject *object; + gpointer user_data; +{ + ReloadGame(0); + return; +} + +void +LoadNextPositionProc(object, user_data) + GtkObject *object; + gpointer user_data; +{ + ReloadPosition(1); + return; +} + +void +LoadPrevPositionProc(object, user_data) + GtkObject *object; + gpointer user_data; +{ + ReloadPosition(-1); + return; +} + +void +ReloadPositionProc(object, user_data) + GtkObject *object; + gpointer user_data; +{ + ReloadPosition(0); + return; +} + +void +LoadPositionProc(object, user_data) + GtkObject *object; + gpointer user_data; +{ + if (gameMode == AnalyzeMode || gameMode == AnalyzeFile) + { + Reset(FALSE, TRUE); + }; + + FileNamePopUp(_("Load position file name?"), "", LoadPosition, "rb"); + return; +} + +void +SaveGameProc(object, user_data) + GtkObject *object; + gpointer user_data; +{ + FileNamePopUp(_("Save game file name?"), + DefaultFileName(appData.oldSaveStyle ? "game" : "pgn"), + SaveGame, "a"); + return; +} + +void +SavePositionProc(object, user_data) + GtkObject *object; + gpointer user_data; +{ + FileNamePopUp(_("Save position file name?"), + DefaultFileName(appData.oldSaveStyle ? "pos" : "fen"), + SavePosition, "a"); + return; +} + +void +AnalyzeFileProc(object, user_data) + GtkObject *object; + gpointer user_data; +{ + if (!first.analysisSupport) + { + char buf[MSG_SIZ]; + snprintf(buf, sizeof(buf), _("%s does not support analysis"), first.tidy); + DisplayError(buf, 0); + return; + }; + Reset(FALSE, TRUE); + + if (!appData.showThinking) + ShowThinkingProc(NULL,NULL); + + AnalyzeFileEvent(); + FileNamePopUp(_("File to analyze"), "", LoadGamePopUp, "rb"); + AnalysisPeriodicEvent(1); + return; +} + + +/* End File Menu */ + +void MachineWhiteProc(object, user_data) + GtkObject *object; + gpointer user_data; +{ + MachineWhiteEvent(); + return; +} + +void MachineBlackProc(object, user_data) + GtkObject *object; + gpointer user_data; +{ + MachineBlackEvent(); + return; +} + +void TwoMachinesProc(object, user_data) + GtkObject *object; + gpointer user_data; +{ + TwoMachinesEvent(); + return; +} + +void AcceptProc(object, user_data) + GtkObject *object; + gpointer user_data; +{ + AcceptEvent(); + return; +} + +void DeclineProc(object, user_data) + GtkObject *object; + gpointer user_data; +{ + DeclineEvent(); + return; +} + +void RematchProc(object, user_data) + GtkObject *object; + gpointer user_data; +{ + RematchEvent(); + return; +} + +void CallFlagProc(object, user_data) + GtkObject *object; + gpointer user_data; +{ + CallFlagEvent(); + return; +} + +void DrawProc(object, user_data) + GtkObject *object; + gpointer user_data; +{ + DrawEvent(); + return; +} + +void AbortProc(object, user_data) + GtkObject *object; + gpointer user_data; +{ + AbortEvent(); + return; +} + +void AdjournProc(object, user_data) + GtkObject *object; + gpointer user_data; +{ + AdjournEvent(); + return; +} + +void ResignProc(object, user_data) + GtkObject *object; + gpointer user_data; +{ + ResignEvent(); + return; +} + +void StopObservingProc(object, user_data) + GtkObject *object; + gpointer user_data; +{ + StopObservingEvent(); + return; +} + +void StopExaminingProc(object, user_data) + GtkObject *object; + gpointer user_data; +{ + StopExaminingEvent(); + return; +} + +void AdjuWhiteProc(object, user_data) + GtkObject *object; + gpointer user_data; +{ + UserAdjudicationEvent(+1); + return; +} + +void AdjuBlackProc(object, user_data) + GtkObject *object; + gpointer user_data; +{ + UserAdjudicationEvent(-1); + return; +} + +void AdjuDrawProc(object, user_data) + GtkObject *object; + gpointer user_data; +{ + UserAdjudicationEvent(0); + return; +} + +void BackwardProc(object, user_data) + GtkObject *object; + gpointer user_data; +{ + BackwardEvent(); + return; +} + +void ForwardProc(object, user_data) + GtkObject *object; + gpointer user_data; +{ + ForwardEvent(); + return; +} + +void ToStartProc(object, user_data) + GtkObject *object; + gpointer user_data; +{ + ToStartEvent(); + return; +} + +void ToEndProc(object, user_data) + GtkObject *object; + gpointer user_data; +{ + ToEndEvent(); + return; +} + +void RevertProc(object, user_data) + GtkObject *object; + gpointer user_data; +{ + RevertEvent(); + return; +} + +void TruncateGameProc(object, user_data) + GtkObject *object; + gpointer user_data; +{ + TruncateGameEvent(); + return; +} + +void MoveNowProc(object, user_data) + GtkObject *object; + gpointer user_data; +{ + MoveNowEvent(); + return; +} + +void RetractMoveProc(object, user_data) + GtkObject *object; + gpointer user_data; +{ + RetractMoveEvent(); + return; +} + +/* Option Menu */ +void +AutocommProc(object, user_data) + GtkObject *object; + gpointer user_data; +{ + appData.autoComment = !appData.autoComment; + return; +} + +void +AutoflagProc(object, user_data) + GtkObject *object; + gpointer user_data; +{ + appData.autoCallFlag = !appData.autoCallFlag; + return; +} + +void +AutoflipProc(object, user_data) + GtkObject *object; + gpointer user_data; +{ + appData.autoFlipView = !appData.autoFlipView; + return; +} + +void +ShowThinkingProc(object, user_data) + GtkObject *object; + gpointer user_data; +{ + appData.showThinking = !appData.showThinking; + ShowThinkingEvent(); + + return; +} + +void +HideThinkingProc(object, user_data) + GtkObject *object; + gpointer user_data; +{ + appData.hideThinkingFromHuman = !appData.hideThinkingFromHuman; + ShowThinkingEvent(); + + return; +} + +void +FlipViewProc(object, user_data) + GtkObject *object; + gpointer user_data; +{ + flipView = !flipView; + DrawPosition(True, NULL); + return; +} + +void +AlwaysQueenProc(object, user_data) + GtkObject *object; + gpointer user_data; +{ + appData.alwaysPromoteToQueen = !appData.alwaysPromoteToQueen; + return; +} + +void +AnimateDraggingProc(object, user_data) + GtkObject *object; + gpointer user_data; +{ + appData.animateDragging = !appData.animateDragging; + + if (appData.animateDragging) + { + // TODO convert to gtk + // CreateAnimVars(); + }; + + return; +} + +void +AnimateMovingProc(object, user_data) + GtkObject *object; + gpointer user_data; +{ + appData.animate = !appData.animate; + + if (appData.animate) + { + // TODO convert to gtk + // CreateAnimVars(); + }; + + return; +} + +void +AutobsProc(object, user_data) + GtkObject *object; + gpointer user_data; +{ + appData.autoObserve = !appData.autoObserve; + return; +} + +void +AutoraiseProc(object, user_data) + GtkObject *object; + gpointer user_data; +{ + appData.autoRaiseBoard = !appData.autoRaiseBoard; + return; +} + +void +AutosaveProc(object, user_data) + GtkObject *object; + gpointer user_data; +{ + appData.autoSaveGames = !appData.autoSaveGames; + return; +} + +void +BlindfoldProc(object, user_data) + GtkObject *object; + gpointer user_data; +{ + appData.blindfold = !appData.blindfold; + DrawPosition(True, NULL); + return; +} + +void +TestLegalityProc(object, user_data) + GtkObject *object; + gpointer user_data; +{ + appData.testLegality = !appData.testLegality; + return; +} + +void +FlashMovesProc(object, user_data) + GtkObject *object; + gpointer user_data; +{ + if (appData.flashCount == 0) + { + appData.flashCount = 3; + } + else + { + appData.flashCount = -appData.flashCount; + }; + + // TODO: check if this is working correct*/ + return; +} + +#if HIGHDRAG +void +HighlightDraggingProc(object, user_data) + GtkObject *object; + gpointer user_data; +{ + /* TODO: connect to option menu */ + appData.highlightDragging = !appData.highlightDragging; + return; +} +#endif + +void +HighlightLastMoveProc(object, user_data) + GtkObject *object; + gpointer user_data; +{ + appData.highlightLastMove = !appData.highlightLastMove; + return; +} + +void +IcsAlarmProc(object, user_data) + GtkObject *object; + gpointer user_data; +{ + appData.icsAlarm = !appData.icsAlarm; + return; +} + +void +MoveSoundProc(object, user_data) + GtkObject *object; + gpointer user_data; +{ + appData.ringBellAfterMoves = !appData.ringBellAfterMoves; + return; +} + +void +OldSaveStyleProc(object, user_data) + GtkObject *object; + gpointer user_data; +{ + appData.oldSaveStyle = !appData.oldSaveStyle; + return; +} + +void +PeriodicUpdatesProc(object, user_data) + GtkObject *object; + gpointer user_data; +{ + PeriodicUpdatesEvent(!appData.periodicUpdates); + return; +} + +/* end option menu */ + +gboolean CloseWindowProc(GtkWidget *button) +{ + gtk_widget_destroy(gtk_widget_get_toplevel(button)); + return TRUE; +} + +void +ResetProc (object, user_data) + GtkObject *object; + gpointer user_data; +{ + ResetGameEvent(); - EngineOutputPopDown(); ++ return; +} + +void WhiteClockProc(object, user_data) + GtkObject *object; + gpointer user_data; +{ + if (gameMode == EditPosition || gameMode == IcsExamining) { + SetWhiteToPlayEvent(); + } else if (gameMode == IcsPlayingBlack || gameMode == MachinePlaysWhite) { + CallFlagEvent(); + } +} + +void BlackClockProc(object, user_data) + GtkObject *object; + gpointer user_data; +{ + if (gameMode == EditPosition || gameMode == IcsExamining) { + SetBlackToPlayEvent(); + } else if (gameMode == IcsPlayingWhite || gameMode == MachinePlaysBlack) { + CallFlagEvent(); + } +} + + +void ShowCoordsProc(object, user_data) + GtkObject *object; + gpointer user_data; +{ + appData.showCoords = !appData.showCoords; + + DrawPosition(True, NULL); +} + +void ErrorPopDownProc(object, user_data) + GtkObject *object; + gpointer user_data; +{ + gtk_widget_destroy(GTK_WIDGET(object)); + ErrorPopDown(); +} + +void PauseProc(object, user_data) + GtkObject *object; + gpointer user_data; +{ + // todo this toggling of the pause button doesn't seem to work? + // e.g. select pause from buttonbar doesn't activate menumode.pause + PauseEvent(); +} + + +void LoadGameProc(object, user_data) + GtkObject *object; + gpointer user_data; +{ + FileNamePopUp(_("Load game file name?"),"",LoadGamePopUp,"rb"); + return; +} + + +/************* + * EVENTS + *************/ + +void EventProc(window, event, data) + GtkWindow *window; + GdkEvent *event; + gpointer data; +{ + /* todo do we still need this? + if (!XtIsRealized(widget)) + return; + */ + + switch (event->type) { + case GDK_EXPOSE: + if (event->expose.count > 0) return; /* no clipping is done */ + DrawPosition(True, NULL); + break; + default: + return; + } +} + + +/* + * event handler for parsing user moves + */ +void UserMoveProc(window, event, data) + GtkWindow *window; + 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 (event->type == GDK_BUTTON_PRESS) + { + /* todo add promotionshellwidget + XtPopdown(promotionShell); + XtDestroyWidget(promotionShell); */ + promotionUp = False; + ClearHighlights(); + fromX = fromY = -1; + } + 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); + } + + return; +} + +void GetMoveListProc(object, user_data) + GtkObject *object; + gpointer user_data; +{ + appData.getMoveList = !appData.getMoveList; + + if (appData.getMoveList) + { + GetMoveListEvent(); + } + + // gets set automatically? if we set it with set_active we end up in an endless loop switching between 0 and 1 + // gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (object),(gboolean) appData.getMoveList ); + + return; +} diff --cc frontend.h index 29425f1,88a3e0d..66455aa --- a/frontend.h +++ b/frontend.h @@@ -116,9 -115,16 +116,16 @@@ void StartLoadGameTimer P((long millise void AutoSaveGame P((void)); typedef void (*DelayedEventCallback) P((void)); -void ScheduleDelayedEvent P((DelayedEventCallback cb, long millisec)); +void ScheduleDelayedEvent P((DelayedEventCallback cb, guint millisec)); DelayedEventCallback GetDelayedEvent P((void)); void CancelDelayedEvent P((void)); + // [HGM] mouse: next six used by mouse handler, which was moved to backend + extern int fromX, fromY, toX, toY; + typedef enum { Press, Release } ClickType; + void PromotionPopUp P((void)); + void DragPieceBegin P((int x, int y)); + void DragPieceEnd P((int x, int y)); + void LeftClick P((ClickType c, int x, int y)); int StartChildProcess P((char *cmdLine, char *dir, ProcRef *pr)); void DestroyChildProcess P((ProcRef pr, int/*boolean*/ signal)); diff --cc xboard.c index 2a31805,909ca85..d479ba3 --- a/xboard.c +++ b/xboard.c @@@ -1740,13 -1786,15 +1743,14 @@@ XrmOptionDescRec shellOptions[] = { "-keepAlive", "keepAlive", XrmoptionSepArg, NULL }, { "-forceIllegalMoves", "forceIllegalMoves", XrmoptionNoArg, "True" }, { "-keepLineBreaksICS", "keepLineBreaksICS", XrmoptionSepArg, NULL }, + { "-wrapContinuationSequence", "wrapContinuationSequence", XrmoptionSepArg, NULL }, + { "-useInternalWrap", "useInternalWrap", XrmoptionSepArg, NULL }, }; - XtActionsRec boardActions[] = { - { "DrawPosition", DrawPositionProc }, { "HandleUserMove", HandleUserMove }, { "AnimateUserMove", AnimateUserMove }, - { "FileNameAction", FileNameAction }, + // { "FileNameAction", FileNameAction }, { "AskQuestionProc", AskQuestionProc }, { "AskQuestionReplyAction", AskQuestionReplyAction }, { "PieceMenuPopup", PieceMenuPopup }, @@@ -1844,8 -1901,7 +1848,7 @@@ { "TagsPopDown", (XtActionProc) TagsPopDown }, { "ErrorPopDown", (XtActionProc) ErrorPopDown }, { "ICSInputBoxPopDown", (XtActionProc) ICSInputBoxPopDown }, - { "EngineOutputPopDown", (XtActionProc) EngineOutputPopDown }, - { "FileNamePopDown", (XtActionProc) FileNamePopDown }, + // { "FileNamePopDown", (XtActionProc) FileNamePopDown }, { "AskQuestionPopDown", (XtActionProc) AskQuestionPopDown }, { "GameListPopDown", (XtActionProc) GameListPopDown }, { "PromotionPopDown", (XtActionProc) PromotionPopDown }, @@@ -3973,48 -5129,12 +3979,12 @@@ void HandleUserMove(w, event, prms, npr String *prms; Cardinal *nprms; { - int x, y; - Boolean saveAnimate; - static int second = 0, promotionChoice = 0; - ChessMove moveType; - if (w != boardWidget || errorExitStatus != -1) return; - x = EventToSquare(event->xbutton.x, BOARD_WIDTH); - y = EventToSquare(event->xbutton.y, BOARD_HEIGHT); - if (!flipView && y >= 0) { - y = BOARD_HEIGHT - 1 - y; - } - if (flipView && x >= 0) { - x = BOARD_WIDTH - 1 - x; - } - - if(promotionChoice) { // we are waiting for a click to indicate promotion piece - if(event->type == ButtonRelease) return; // ignore upclick of click-click destination - promotionChoice = FALSE; // only one chance: if click not OK it is interpreted as cancel - if(appData.debugMode) fprintf(debugFP, "promotion click, x=%d, y=%d\n", x, y); - if(gameInfo.holdingsWidth && - (WhiteOnMove(currentMove) - ? x == BOARD_WIDTH-1 && y < gameInfo.holdingsSize && y > 0 - : x == 0 && y >= BOARD_HEIGHT - gameInfo.holdingsSize && y < BOARD_HEIGHT-1) ) { - // click in right holdings, for determining promotion piece - ChessSquare p = boards[currentMove][y][x]; - if(appData.debugMode) fprintf(debugFP, "square contains %d\n", (int)p); - if(p != EmptySquare) { - FinishMove(NormalMove, fromX, fromY, toX, toY, ToLower(PieceToChar(p))); - fromX = fromY = -1; - return; - } - } - DrawPosition(FALSE, boards[currentMove]); - return; - } - if (event->type == ButtonPress) ErrorPopDown(); - if (promotionUp) { if (event->type == ButtonPress) { - XtPopdown(promotionShell); - XtDestroyWidget(promotionShell); +// XtPopdown(promotionShell); +// XtDestroyWidget(promotionShell); promotionUp = False; ClearHighlights(); fromX = fromY = -1;