From 5cb748f018a80d22ef6cd98e3521c43fd98102a3 Mon Sep 17 00:00:00 2001 From: H.G.Muller Date: Wed, 2 Jul 2014 14:04:22 +0200 Subject: [PATCH] Fix adjusting clocks in Xaw version The handler attached to Label options failed to flip the sign of the option number when a button other than Button1 was pressed, so that time would always be subtracted on Shift + ClockClick and never added. Shift now also suppresses interpretation as null move when playing. (In Analyze / EditGame mode it is still null move starting a variation.) --- backend.c | 4 ++-- xaw/xoptions.c | 14 +++++++++++--- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/backend.c b/backend.c index 3d9f020..b269bf3 100644 --- a/backend.c +++ b/backend.c @@ -15295,7 +15295,7 @@ ClockClick (int which) if(!appData.pieceMenu && blackPlaysFirst) EditPositionMenuEvent(ClearBoard, 0, 0); SetBlackToPlayEvent(); } else if ((gameMode == AnalyzeMode || gameMode == EditGame || - gameMode == MachinePlaysBlack && PosFlags(0) & F_NULL_MOVE && !blackFlag) && WhiteOnMove(currentMove)) { + gameMode == MachinePlaysBlack && PosFlags(0) & F_NULL_MOVE && !blackFlag && !shiftKey) && WhiteOnMove(currentMove)) { UserMoveEvent((int)EmptySquare, DROP_RANK, 0, 0, 0); // [HGM] multi-move: if not out of time, enters null move } else if (shiftKey) { AdjustClock(which, -1); @@ -15308,7 +15308,7 @@ ClockClick (int which) if(!appData.pieceMenu && !blackPlaysFirst) EditPositionMenuEvent(ClearBoard, 0, 0); SetWhiteToPlayEvent(); } else if ((gameMode == AnalyzeMode || gameMode == EditGame || - gameMode == MachinePlaysWhite && PosFlags(0) & F_NULL_MOVE && !whiteFlag) && !WhiteOnMove(currentMove)) { + gameMode == MachinePlaysWhite && PosFlags(0) & F_NULL_MOVE && !whiteFlag && !shiftKey) && !WhiteOnMove(currentMove)) { UserMoveEvent((int)EmptySquare, DROP_RANK, 0, 0, 0); // [HGM] multi-move } else if (shiftKey) { AdjustClock(which, -1); diff --git a/xaw/xoptions.c b/xaw/xoptions.c index 1eb4965..5caa95a 100644 --- a/xaw/xoptions.c +++ b/xaw/xoptions.c @@ -308,13 +308,21 @@ SetIconName (DialogClass dlg, char *name) } static void +LabelCallback (Widget ww, XtPointer client_data, XEvent *event, Boolean *b) +{ // called on ButtonPress in label widgets with attached user handler (clocks!) + int s, data = (intptr_t) client_data; + Option *opt = dialogOptions[data >> 8] + (s = data & 255); + + if(((XButtonEvent*)event)->button != Button1) s = -s; + ((ButtonCallback*) opt->target) (s); +} + +static void CheckCallback (Widget ww, XtPointer client_data, XEvent *event, Boolean *b) { int s, data = (intptr_t) client_data; Option *opt = dialogOptions[data >> 8] + (data & 255); - if(opt->type == Label) { ((ButtonCallback*) opt->target)(data&255); return; } - GetWidgetState(opt, &s); SetWidgetState(opt, !s); } @@ -1093,7 +1101,7 @@ GenericPopUp (Option *option, char *title, DialogClass dlgNr, DialogClass parent XtSetArg(args[j], XtNlabel, _(msg)); j++; option[i].handle = (void*) (last = XtCreateManagedWidget("label", labelWidgetClass, form, args, j)); if(option[i].target) // allow user to specify event handler for button presses - XtAddEventHandler(last, ButtonPressMask, False, CheckCallback, (XtPointer)(intptr_t) i + 256*dlgNr); + XtAddEventHandler(last, ButtonPressMask, False, LabelCallback, (XtPointer)(intptr_t) i + 256*dlgNr); break; case SaveButton: case Button: -- 1.7.0.4