X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=backend.c;h=e0e1ab2297f35007cee99f748599454438350c98;hb=99567fe1b4652cd8b448638817090158773280be;hp=a9b29e49d15d56a42923ebccc1651e1b22bd18f1;hpb=85e09fb8d532d31848d6785dc43b6f9ee56e009a;p=xboard.git diff --git a/backend.c b/backend.c index a9b29e4..e0e1ab2 100644 --- a/backend.c +++ b/backend.c @@ -5941,6 +5941,57 @@ void LeftClick(ClickType clickType, int xPix, int yPix) } } +int RightClick(ClickType action, int x, int y, int *fromX, int *fromY) +{ // front-end-free part taken out of PieceMenuPopup + int whichMenu; + + if (action == Release) UnLoadPV(); // [HGM] pv + if (action != Press) return -2; + switch (gameMode) { + case EditPosition: + case IcsExamining: + whichMenu = 0; + break; + case IcsObserving: + if(!appData.icsEngineAnalyze) return -1; + case IcsPlayingWhite: + case IcsPlayingBlack: + if(!appData.zippyPlay) goto noZip; + case AnalyzeMode: + case AnalyzeFile: + case MachinePlaysWhite: + case MachinePlaysBlack: + case TwoMachinesPlay: // [HGM] pv: use for showing PV + if (!appData.dropMenu) { + LoadPV(x, y); + return -1; + } + if(gameMode == TwoMachinesPlay || gameMode == AnalyzeMode || + gameMode == AnalyzeFile || gameMode == IcsObserving) return -1; + case EditGame: + noZip: + if (!appData.dropMenu || appData.testLegality && + gameInfo.variant != VariantBughouse && + gameInfo.variant != VariantCrazyhouse) return -1; + whichMenu = 1; + break; + default: + return -1; + } + + if (((*fromX = EventToSquare(x, BOARD_WIDTH)) < 0) || + ((*fromY = EventToSquare(y, BOARD_HEIGHT)) < 0)) { + *fromX = *fromY = -1; + return -1; + } + if (flipView) + *fromX = BOARD_WIDTH - 1 - *fromX; + else + *fromY = BOARD_HEIGHT - 1 - *fromY; + + return whichMenu; +} + void SendProgramStatsToFrontend( ChessProgramState * cps, ChessProgramStats * cpstats ) { // char * hint = lastHint;