1
0
mirror of https://github.com/narzoul/DDrawCompat synced 2024-12-30 08:55:36 +01:00

Eliminated flickering in popup menus

DC redirection for popup menus is suppressed unless requested from WM_PAINT.
This commit is contained in:
narzoul 2016-03-28 17:14:47 +02:00
parent 460433c858
commit 0c030f8d57
3 changed files with 14 additions and 8 deletions

View File

@ -5,6 +5,7 @@
#include "CompatGdiDc.h"
#include "CompatGdiDcCache.h"
#include "DDrawLog.h"
#include "Hook.h"
namespace
{
@ -126,11 +127,8 @@ namespace
}
}
void setClippingRegion(HDC compatDc, HDC origDc, const POINT& origin)
void setClippingRegion(HDC compatDc, HDC origDc, HWND hwnd, bool isMenuWindow, const POINT& origin)
{
const HWND hwnd = WindowFromDC(origDc);
const bool isMenuWindow = hwnd && 0x8000 == GetClassLongPtr(hwnd, GCW_ATOM);
if (isMenuWindow)
{
RECT windowRect = {};
@ -165,7 +163,7 @@ namespace
namespace CompatGdiDc
{
HDC getDc(HDC origDc)
HDC getDc(HDC origDc, bool isMenuPaintDc)
{
if (!origDc || OBJ_DC != GetObjectType(origDc) || DT_RASDISPLAY != GetDeviceCaps(origDc, TECHNOLOGY))
{
@ -181,6 +179,13 @@ namespace CompatGdiDc
return it->second.dc;
}
const HWND hwnd = CALL_ORIG_FUNC(WindowFromDC)(origDc);
const bool isMenuWindow = hwnd && 0x8000 == GetClassLongPtr(hwnd, GCW_ATOM);
if (isMenuWindow && !isMenuPaintDc)
{
return nullptr;
}
CompatDc compatDc(CompatGdiDcCache::getDc());
if (!compatDc.dc)
{
@ -191,7 +196,7 @@ namespace CompatGdiDc
GetDCOrgEx(origDc, &origin);
copyDcAttributes(compatDc, origDc, origin);
setClippingRegion(compatDc.dc, origDc, origin);
setClippingRegion(compatDc.dc, origDc, hwnd, isMenuWindow, origin);
compatDc.refCount = 1;
compatDc.origDc = origDc;

View File

@ -6,7 +6,7 @@
namespace CompatGdiDc
{
HDC getDc(HDC origDc);
HDC getDc(HDC origDc, bool isMenuPaintDc = false);
HDC getOrigDc(HDC dc);
void releaseDc(HDC origDc);
}

View File

@ -197,7 +197,8 @@ namespace
}
HDC dc = GetWindowDC(hwnd);
HDC compatDc = CompatGdiDc::getDc(dc);
const bool isMenuPaintDc = true;
HDC compatDc = CompatGdiDc::getDc(dc, isMenuPaintDc);
if (compatDc)
{
origWndProc(hwnd, WM_PRINT, reinterpret_cast<WPARAM>(compatDc),