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

Fixed fullscreen mode detection in SetCooperativeLevel

See issue #225.
This commit is contained in:
narzoul 2023-05-14 14:56:09 +02:00
parent c7702913db
commit 7ec4d076f6

View File

@ -119,13 +119,13 @@ namespace
HRESULT STDMETHODCALLTYPE SetCooperativeLevel(TDirectDraw* This, HWND hWnd, DWORD dwFlags) HRESULT STDMETHODCALLTYPE SetCooperativeLevel(TDirectDraw* This, HWND hWnd, DWORD dwFlags)
{ {
HRESULT result = getOrigVtable(This).SetCooperativeLevel(This, hWnd, dwFlags); HRESULT result = getOrigVtable(This).SetCooperativeLevel(This, hWnd, dwFlags);
if (SUCCEEDED(result) && (dwFlags & (DDSCL_FULLSCREEN | DDSCL_NORMAL))) const bool isFullscreen = (dwFlags & DDSCL_FULLSCREEN) && (dwFlags & DDSCL_EXCLUSIVE);
if (SUCCEEDED(result) && (isFullscreen || (dwFlags & DDSCL_NORMAL)))
{ {
auto tagSurface = DDraw::TagSurface::get(*CompatPtr<IDirectDraw>::from(This)); auto tagSurface = DDraw::TagSurface::get(*CompatPtr<IDirectDraw>::from(This));
if (tagSurface) if (tagSurface)
{ {
const bool wasFullscreen = tagSurface->isFullscreen(); const bool wasFullscreen = tagSurface->isFullscreen();
const bool isFullscreen = dwFlags & DDSCL_FULLSCREEN;
if (wasFullscreen != isFullscreen) if (wasFullscreen != isFullscreen)
{ {
tagSurface->setFullscreenWindow(isFullscreen ? hWnd : nullptr); tagSurface->setFullscreenWindow(isFullscreen ? hWnd : nullptr);