From: H.G. Muller Date: Tue, 11 Jan 2011 10:18:15 +0000 (+0100) Subject: Fix logo repainting X-Git-Url: http://winboard.nl/cgi-bin?a=commitdiff_plain;h=c6338f2b9f9b3191ab810791de54826faf01bc7f;p=xboard.git Fix logo repainting The logos were not repainted when the main window was moved out of the display area, and then back into view. The reason for this is unknown, as the PaintProc calls HDCDrawPosition, which was calling DrawLogoOnDC. But the logos were not drawn, (or on an expose event sometimes half drawn!) despite the fact that the rest of the board was. The drawing of logos now has been decoupled from drawing the board, and has been moved to a separate routine DisplayLogos() (in analogy to DisplayBothClocks()). This is cleaner anyway, as the logos usually do not change when the board does. So apart from in PaintProc, it has only to be called when the mode changes (ModeHighlight()) or on swap clocks. This seems to fix the problem. --- diff --git a/winboard/winboard.c b/winboard/winboard.c index 4f0fc10..5cf1712 100644 --- a/winboard/winboard.c +++ b/winboard/winboard.c @@ -3394,6 +3394,48 @@ DrawLogoOnDC(HDC hdc, RECT logoRect, HBITMAP logo) DeleteDC(tmphdc); } +VOID +DisplayLogos() +{ + if(logoHeight) { + HDC hdc = GetDC(hwndMain); + HBITMAP whiteLogo = (HBITMAP) first.programLogo, blackLogo = (HBITMAP) second.programLogo; + if(appData.autoLogo) { + + switch(gameMode) { // pick logos based on game mode + case IcsObserving: + whiteLogo = second.programLogo; // ICS logo + blackLogo = second.programLogo; + default: + break; + case IcsPlayingWhite: + if(!appData.zippyPlay) whiteLogo = userLogo; + blackLogo = second.programLogo; // ICS logo + break; + case IcsPlayingBlack: + whiteLogo = second.programLogo; // ICS logo + blackLogo = appData.zippyPlay ? first.programLogo : userLogo; + break; + case TwoMachinesPlay: + if(first.twoMachinesColor[0] == 'b') { + whiteLogo = second.programLogo; + blackLogo = first.programLogo; + } + break; + case MachinePlaysWhite: + blackLogo = userLogo; + break; + case MachinePlaysBlack: + whiteLogo = userLogo; + blackLogo = first.programLogo; + } + } + DrawLogoOnDC(hdc, leftLogoRect, flipClock ? blackLogo : whiteLogo); + DrawLogoOnDC(hdc, rightLogoRect, flipClock ? whiteLogo : blackLogo); + ReleaseDC(hwndMain, hdc); + } +} + static HDC hdcSeek; // [HGM] seekgraph @@ -3732,41 +3774,6 @@ HDCDrawPosition(HDC hdc, BOOLEAN repaint, Board board) } } } - if(logoHeight) { - HBITMAP whiteLogo = (HBITMAP) first.programLogo, blackLogo = (HBITMAP) second.programLogo; - if(appData.autoLogo) { - - switch(gameMode) { // pick logos based on game mode - case IcsObserving: - whiteLogo = second.programLogo; // ICS logo - blackLogo = second.programLogo; - default: - break; - case IcsPlayingWhite: - if(!appData.zippyPlay) whiteLogo = userLogo; - blackLogo = second.programLogo; // ICS logo - break; - case IcsPlayingBlack: - whiteLogo = second.programLogo; // ICS logo - blackLogo = appData.zippyPlay ? first.programLogo : userLogo; - break; - case TwoMachinesPlay: - if(first.twoMachinesColor[0] == 'b') { - whiteLogo = second.programLogo; - blackLogo = first.programLogo; - } - break; - case MachinePlaysWhite: - blackLogo = userLogo; - break; - case MachinePlaysBlack: - whiteLogo = userLogo; - blackLogo = first.programLogo; - } - } - DrawLogoOnDC(hdc, leftLogoRect, flipClock ? blackLogo : whiteLogo); - DrawLogoOnDC(hdc, rightLogoRect, flipClock ? whiteLogo : blackLogo); - } if( appData.highlightMoveWithArrow ) { DrawArrowHighlight(hdcmem); @@ -3981,6 +3988,7 @@ PaintProc(HWND hwnd) &messageRect, messageText, strlen(messageText), NULL); SelectObject(hdc, oldFont); DisplayBothClocks(); + DisplayLogos(); } EndPaint(hwnd,&ps); } @@ -5068,7 +5076,7 @@ WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) case IDM_FlipClock: flipClock = !flipClock; DisplayBothClocks(); - DrawPosition(FALSE, NULL); + DisplayLogos(); break; case IDM_MuteSounds: @@ -8020,6 +8028,7 @@ ModeHighlight() MF_BYCOMMAND|MF_UNCHECKED); } } + DisplayLogos(); // [HGM] logos: mode change could have altered logos } VOID