From: H.G.Muller Date: Thu, 13 Nov 2014 17:33:42 +0000 (+0100) Subject: Implement -monoMouse option (XB) X-Git-Url: http://winboard.nl/cgi-bin?a=commitdiff_plain;h=c7f63aacef9cbcd5b46d6d7693d95d9584786106;p=xboard.git Implement -monoMouse option (XB) With the monoMouse option button-3 is no longer needed in Edit-Position mode, but a button-1 click on an empty square will automatically behave as if it was button 3. It can only be used with -pieceMenu false, as it does not communicate the coordinates of the clicked square. --- diff --git a/args.h b/args.h index 1ceb1a4..270baf5 100644 --- a/args.h +++ b/args.h @@ -230,6 +230,7 @@ ArgDescriptor argDescriptors[] = { { "dropMenu", ArgBoolean, (void *) &appData.dropMenu, TRUE, (ArgIniType) FALSE }, { "pieceMenu", ArgBoolean, (void *) &appData.pieceMenu, TRUE, (ArgIniType) TRUE }, { "sweepPromotions", ArgBoolean, (void *) &appData.sweepSelect, TRUE, (ArgIniType) FALSE }, + { "monoMouse", ArgBoolean, (void *) &appData.monoMouse, XBOARD, (ArgIniType) FALSE }, { "remoteShell", ArgFilename, (void *) &appData.remoteShell, FALSE, (ArgIniType) REMOTE_SHELL }, { "rsh", ArgFilename, (void *) &appData.remoteShell, FALSE, INVALID }, { "remoteUser", ArgString, (void *) &appData.remoteUser, FALSE, (ArgIniType) "" }, diff --git a/backend.c b/backend.c index 0b4ad84..c4c5bf3 100644 --- a/backend.c +++ b/backend.c @@ -7367,6 +7367,8 @@ void ReportClick(char *action, int x, int y) SendToProgram(buf, &first); } +Boolean right; // instructs front-end to use button-1 events as if they were button 3 + void LeftClick (ClickType clickType, int xPix, int yPix) { @@ -7377,13 +7379,6 @@ LeftClick (ClickType clickType, int xPix, int yPix) ChessSquare piece; static TimeMark lastClickTime, prevClickTime; - if(SeekGraphClick(clickType, xPix, yPix, 0)) return; - - prevClickTime = lastClickTime; GetTimeMark(&lastClickTime); - - if (clickType == Press) ErrorPopDown(); - lastClickType = clickType, lastLeftX = xPix, lastLeftY = yPix; // [HGM] alien: remember state - x = EventToSquare(xPix, BOARD_WIDTH); y = EventToSquare(yPix, BOARD_HEIGHT); if (!flipView && y >= 0) { @@ -7393,6 +7388,20 @@ LeftClick (ClickType clickType, int xPix, int yPix) x = BOARD_WIDTH - 1 - x; } + if(appData.monoMouse && gameMode == EditPosition && clickType == Press && boards[currentMove][y][x] == EmptySquare) { + static int dummy; + RightClick(clickType, xPix, yPix, &dummy, &dummy); + right = TRUE; + return; + } + + if(SeekGraphClick(clickType, xPix, yPix, 0)) return; + + prevClickTime = lastClickTime; GetTimeMark(&lastClickTime); + + if (clickType == Press) ErrorPopDown(); + lastClickType = clickType, lastLeftX = xPix, lastLeftY = yPix; // [HGM] alien: remember state + if(promoSweep != EmptySquare) { // up-click during sweep-select of promo-piece defaultPromoChoice = promoSweep; promoSweep = EmptySquare; // terminate sweep diff --git a/common.h b/common.h index 2b0ddf0..a082aa2 100644 --- a/common.h +++ b/common.h @@ -777,6 +777,7 @@ typedef struct { Boolean autoCopyPV; Boolean pieceMenu; Boolean sweepSelect; + Boolean monoMouse; Boolean whitePOV; Boolean scoreWhite; Boolean pvSAN[ENGINES]; diff --git a/dialogs.c b/dialogs.c index 2e63442..29003f5 100644 --- a/dialogs.c +++ b/dialogs.c @@ -2544,6 +2544,12 @@ Exp (int n, int x, int y) static int but1, but3, oldW, oldH; int menuNr = -3, sizing, f, r; TimeMark now; + extern Boolean right; + + if(right) { // kludgy way to let button 1 double as button 3 when back-end requests this + if(but1 && n == 0) but1 = 0, but3 = 1; + else if(n == -1) n = -3, right = FALSE; + } if(n == 0) { // motion if(SeekGraphClick(Press, x, y, 1)) return NULL;