mirror of
https://github.com/narzoul/DDrawCompat
synced 2024-12-30 08:55:36 +01:00
Disabled GDI emulation while the app is inactive
This commit is contained in:
parent
fe8abe9d5a
commit
c647f4b2ef
@ -1,6 +1,7 @@
|
||||
#include "CompatActivateAppHandler.h"
|
||||
#include "CompatDirectDraw.h"
|
||||
#include "CompatDirectDrawSurface.h"
|
||||
#include "CompatGdi.h"
|
||||
#include "CompatPrimarySurface.h"
|
||||
#include "DDrawLog.h"
|
||||
#include "RealPrimarySurface.h"
|
||||
@ -54,9 +55,11 @@ namespace
|
||||
CompatDirectDraw<IDirectDraw7>::s_origVtable.SetDisplayMode(
|
||||
dd, dm.width, dm.height, 32, dm.refreshRate, 0);
|
||||
}
|
||||
CompatGdi::enableEmulation();
|
||||
}
|
||||
else
|
||||
{
|
||||
CompatGdi::disableEmulation();
|
||||
if (CompatPrimarySurface::isDisplayModeChanged)
|
||||
{
|
||||
CompatDirectDraw<IDirectDraw7>::s_origVtable.RestoreDisplayMode(dd);
|
||||
|
@ -1,3 +1,5 @@
|
||||
#include <atomic>
|
||||
|
||||
#include "CompatDirectDrawPalette.h"
|
||||
#include "CompatDirectDrawSurface.h"
|
||||
#include "CompatGdi.h"
|
||||
@ -15,6 +17,7 @@
|
||||
|
||||
namespace
|
||||
{
|
||||
std::atomic<int> g_disableEmulationCount = 0;
|
||||
DWORD g_renderingRefCount = 0;
|
||||
DWORD g_ddLockThreadRenderingRefCount = 0;
|
||||
DWORD g_ddLockThreadId = 0;
|
||||
@ -154,6 +157,16 @@ namespace CompatGdi
|
||||
}
|
||||
}
|
||||
|
||||
void disableEmulation()
|
||||
{
|
||||
++g_disableEmulationCount;
|
||||
}
|
||||
|
||||
void enableEmulation()
|
||||
{
|
||||
--g_disableEmulationCount;
|
||||
}
|
||||
|
||||
void hookWndProc(LPCSTR className, WNDPROC &oldWndProc, WNDPROC newWndProc)
|
||||
{
|
||||
HWND hwnd = CreateWindow(className, nullptr, 0, 0, 0, 0, 0, nullptr, nullptr, nullptr, 0);
|
||||
@ -193,7 +206,7 @@ namespace CompatGdi
|
||||
|
||||
bool isEmulationEnabled()
|
||||
{
|
||||
return RealPrimarySurface::isFullScreen();
|
||||
return g_disableEmulationCount <= 0 && RealPrimarySurface::isFullScreen();
|
||||
}
|
||||
|
||||
void unhookWndProc(LPCSTR className, WNDPROC oldWndProc)
|
||||
|
@ -9,6 +9,9 @@ namespace CompatGdi
|
||||
bool beginGdiRendering();
|
||||
void endGdiRendering();
|
||||
|
||||
void disableEmulation();
|
||||
void enableEmulation();
|
||||
|
||||
void hookWndProc(LPCSTR className, WNDPROC &oldWndProc, WNDPROC newWndProc);
|
||||
void installHooks();
|
||||
void invalidate(const RECT* rect);
|
||||
|
Loading…
x
Reference in New Issue
Block a user