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

Reduced cursor flickering during temporary mode changes

This commit is contained in:
narzoul 2023-11-04 13:46:05 +01:00
parent 0a67b4aa00
commit 439750e174
5 changed files with 36 additions and 16 deletions

View File

@ -1412,7 +1412,8 @@ namespace D3dDdi
}
Gdi::Cursor::setMonitorClipRect(clipRect);
Gdi::Cursor::setEmulated(mi.isEmulated);
DDraw::RealPrimarySurface::setEmulatedCursor(0 != g_presentationRect.left || 0 != g_presentationRect.top ||
Rect::getSize(mi.rcEmulated) != Rect::getSize(g_presentationRect));
Gdi::VirtualScreen::setFullscreenMode(m_origData.Flags.MatchGdiPrimary);
}
else
@ -1421,7 +1422,7 @@ namespace D3dDdi
g_presentationRect = {};
Gdi::VirtualScreen::setFullscreenMode(false);
Gdi::Cursor::setEmulated(false);
DDraw::RealPrimarySurface::setEmulatedCursor(false);
Gdi::Cursor::setMonitorClipRect({});
}
}

View File

@ -58,6 +58,7 @@ namespace
DDSURFACEDESC2 g_surfaceDesc = {};
DDraw::IReleaseNotifier g_releaseNotifier(onRelease);
bool g_emulatedCursor = false;
bool g_isFullscreen = false;
bool g_isExclusiveFullscreen = false;
DDraw::Surface* g_lastFlipSurface = nullptr;
@ -478,6 +479,11 @@ namespace
}
}
prevFullscreenWindow = fullscreenWindow;
if (Gdi::Cursor::isEmulated() != g_emulatedCursor)
{
Gdi::Cursor::setEmulated(g_emulatedCursor);
}
}
unsigned WINAPI updateThreadProc(LPVOID /*lpParameter*/)
@ -827,6 +833,11 @@ namespace DDraw
g_qpcUpdatePresentationWindow = Time::queryPerformanceCounter() + Time::g_qpcFrequency / 5;
}
void RealPrimarySurface::setEmulatedCursor(bool emulated)
{
g_emulatedCursor = emulated;
}
HRESULT RealPrimarySurface::setGammaRamp(DDGAMMARAMP* rampData)
{
DDraw::ScopedThreadLock lock;

View File

@ -29,6 +29,7 @@ namespace DDraw
static void scheduleOverlayUpdate();
static void scheduleUpdate();
static void schedulePresentationWindowUpdate();
static void setEmulatedCursor(bool emulated);
static HRESULT setGammaRamp(DDGAMMARAMP* rampData);
static void setPresentationWindowTopmost();
static void setUpdateReady();

View File

@ -319,6 +319,11 @@ namespace
void fixPopupMenuPosition(WINDOWPOS& wp)
{
RECT mr = DDraw::PrimarySurface::getMonitorRect();
if (IsRectEmpty(&mr))
{
return;
}
if (wp.flags & SWP_NOSIZE)
{
RECT r = {};
@ -433,7 +438,7 @@ namespace
{
LRESULT result = CallWindowProc(origWndProc, hwnd, msg, wParam, lParam);
auto& wp = *reinterpret_cast<WINDOWPOS*>(lParam);
if (Gdi::Cursor::isEmulated() && !(wp.flags & SWP_NOMOVE))
if (!(wp.flags & SWP_NOMOVE))
{
fixPopupMenuPosition(wp);
}

View File

@ -516,21 +516,23 @@ namespace
void onInitMenuPopup(HMENU menu)
{
if (Gdi::Cursor::isEmulated())
RECT mr = DDraw::PrimarySurface::getMonitorRect();
if (IsRectEmpty(&mr))
{
MENUINFO mi = {};
mi.cbSize = sizeof(mi);
mi.fMask = MIM_MAXHEIGHT;
GetMenuInfo(menu, &mi);
return;
}
RECT mr = DDraw::PrimarySurface::getMonitorRect();
UINT maxHeight = mr.bottom - mr.top;
if (0 == mi.cyMax || mi.cyMax > maxHeight)
{
g_menuMaxHeight[menu] = mi.cyMax;
mi.cyMax = maxHeight;
SetMenuInfo(menu, &mi);
}
MENUINFO mi = {};
mi.cbSize = sizeof(mi);
mi.fMask = MIM_MAXHEIGHT;
GetMenuInfo(menu, &mi);
UINT maxHeight = mr.bottom - mr.top;
if (0 == mi.cyMax || mi.cyMax > maxHeight)
{
g_menuMaxHeight[menu] = mi.cyMax;
mi.cyMax = maxHeight;
SetMenuInfo(menu, &mi);
}
}