From: H.G. Muller Date: Wed, 19 Jan 2011 10:10:59 +0000 (+0100) Subject: Move clock-click code to back-end X-Git-Url: http://winboard.nl/cgi-bin?a=commitdiff_plain;h=ed8c91aad1e9649a417feb5ef3d3637595ddbbfb;p=xboard.git Move clock-click code to back-end Some duplicated (or should-be-duplicated) code for handling clicks on the clocks from the XBoard and WinBoard front-ends was merged and relocated to the back-end, so it can be shared. Noticeable was that XBoard allowed turn change in ICS examine mode by clock clicking, while WinBoard did not. WB, on the other hand, allowed clock adjustment. --- diff --git a/backend.c b/backend.c index 89089f1..92873a9 100644 --- a/backend.c +++ b/backend.c @@ -12616,6 +12616,30 @@ CallFlagEvent() } void +ClockClick(int which) +{ // [HGM] code moved to back-end from winboard.c + if(which) { // black clock + if (gameMode == EditPosition || gameMode == IcsExamining) { + SetBlackToPlayEvent(); + } else if (gameMode == EditGame || shiftKey) { + AdjustClock(which, -1); + } else if (gameMode == IcsPlayingWhite || + gameMode == MachinePlaysBlack) { + CallFlagEvent(); + } + } else { // white clock + if (gameMode == EditPosition || gameMode == IcsExamining) { + SetWhiteToPlayEvent(); + } else if (gameMode == EditGame || shiftKey) { + AdjustClock(which, -1); + } else if (gameMode == IcsPlayingBlack || + gameMode == MachinePlaysWhite) { + CallFlagEvent(); + } + } +} + +void DrawEvent() { /* Offer draw or accept pending draw offer from opponent */ diff --git a/backend.h b/backend.h index 7e5accd..bbce7ed 100644 --- a/backend.h +++ b/backend.h @@ -162,6 +162,7 @@ void MoveNowEvent P((void)); void TruncateGameEvent P((void)); void PauseEvent P((void)); void CallFlagEvent P((void)); +void ClockClick P((int which)); void AcceptEvent P((void)); void DeclineEvent P((void)); void RematchEvent P((void)); diff --git a/winboard/winboard.c b/winboard/winboard.c index a04d77f..5e2ee81 100644 --- a/winboard/winboard.c +++ b/winboard/winboard.c @@ -4112,23 +4112,9 @@ MouseEvent(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) switch (message) { case WM_LBUTTONDOWN: if (PtInRect((LPRECT) &whiteRect, pt)) { - if (gameMode == EditPosition) { - SetWhiteToPlayEvent(); - } else if (gameMode == EditGame || GetKeyState(VK_SHIFT) < 0) { - AdjustClock(flipClock, -1); - } else if (gameMode == IcsPlayingBlack || - gameMode == MachinePlaysWhite) { - CallFlagEvent(); - } + ClockClick(flipClock); } else if (PtInRect((LPRECT) &blackRect, pt)) { - if (gameMode == EditPosition) { - SetBlackToPlayEvent(); - } else if (gameMode == EditGame || GetKeyState(VK_SHIFT) < 0) { - AdjustClock(!flipClock, -1); - } else if (gameMode == IcsPlayingWhite || - gameMode == MachinePlaysBlack) { - CallFlagEvent(); - } + ClockClick(!flipClock); } dragInfo.start.x = dragInfo.start.y = -1; dragInfo.from = dragInfo.start; diff --git a/xboard.c b/xboard.c index d618be4..76c3b77 100644 --- a/xboard.c +++ b/xboard.c @@ -3955,11 +3955,7 @@ void WhiteClock(w, event, prms, nprms) String *prms; Cardinal *nprms; { - if (gameMode == EditPosition || gameMode == IcsExamining) { - SetWhiteToPlayEvent(); - } else if (gameMode == IcsPlayingBlack || gameMode == MachinePlaysWhite) { - CallFlagEvent(); - } + ClockClick(0); } void BlackClock(w, event, prms, nprms) @@ -3968,11 +3964,7 @@ void BlackClock(w, event, prms, nprms) String *prms; Cardinal *nprms; { - if (gameMode == EditPosition || gameMode == IcsExamining) { - SetBlackToPlayEvent(); - } else if (gameMode == IcsPlayingWhite || gameMode == MachinePlaysBlack) { - CallFlagEvent(); - } + ClockClick(1); }