From 47026bf0114befed90c65907963de05c0efce248 Mon Sep 17 00:00:00 2001 From: FunkyFr3sh Date: Mon, 19 Mar 2018 02:27:55 +0100 Subject: [PATCH] fix for alt+tab freeze (carmageddon) --- ddraw.rc | 8 ++++---- inc/main.h | 1 + src/main.c | 15 ++++++++++++++- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/ddraw.rc b/ddraw.rc index 5a2db92..ca947dc 100644 --- a/ddraw.rc +++ b/ddraw.rc @@ -1,6 +1,6 @@ 1 VERSIONINFO -FILEVERSION 1,1,5,8 -PRODUCTVERSION 1,1,5,8 +FILEVERSION 1,1,5,9 +PRODUCTVERSION 1,1,5,9 { BLOCK "StringFileInfo" { @@ -8,13 +8,13 @@ PRODUCTVERSION 1,1,5,8 { VALUE "CompanyName", "cncnet.org" VALUE "FileDescription", "DirectDraw replacement for C&C95 and Red Alert" - VALUE "FileVersion", "1.1.5.8" + VALUE "FileVersion", "1.1.5.9" VALUE "InternalName", "ddraw" VALUE "LegalCopyright", "Copyright (c) 2010-2018" VALUE "LegalTrademarks", "" VALUE "OriginalFileName", "ddraw.dll" VALUE "ProductName", "DirectDraw replacement for C&C95 and Red Alert" - VALUE "ProductVersion", "1.1.5.8" + VALUE "ProductVersion", "1.1.5.9" VALUE "Comments", "https://cncnet.org" } } diff --git a/inc/main.h b/inc/main.h index fb730f7..6192389 100644 --- a/inc/main.h +++ b/inc/main.h @@ -87,6 +87,7 @@ typedef struct IDirectDrawImpl BOOL fullscreen; BOOL maintas; BOOL fakecursorpos; + BOOL noactivateapp; } IDirectDrawImpl; diff --git a/src/main.c b/src/main.c index 2457301..e5c23e1 100644 --- a/src/main.c +++ b/src/main.c @@ -593,7 +593,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) case WM_ACTIVATEAPP: /* C&C and RA stop drawing when they receive this with FALSE wParam, disable in windowed mode */ - if (ddraw->windowed) + if (ddraw->windowed || ddraw->noactivateapp) { return 0; } @@ -983,6 +983,9 @@ HRESULT WINAPI DirectDrawCreate(GUID FAR* lpGUID, LPDIRECTDRAW FAR* lplpDD, IUnk "opengl_pbo=false\n" "; Fake cursor position for games that use GetCursorPos and expect to be in fullscreen\n" "fakecursorpos=true\n" + "; Hide WM_ACTIVATEAPP messages to prevent freezing on alt+tab (Carmageddon)\n" + "noactivateapp=false\n" + , fh); fclose(fh); } @@ -1114,6 +1117,16 @@ HRESULT WINAPI DirectDrawCreate(GUID FAR* lpGUID, LPDIRECTDRAW FAR* lplpDD, IUnk This->fakecursorpos = FALSE; } + GetPrivateProfileStringA("ddraw", "noactivateapp", "FALSE", tmp, sizeof(tmp), SettingsIniPath); + if (tolower(tmp[0]) == 'y' || tolower(tmp[0]) == 't' || tolower(tmp[0]) == 'e' || tmp[0] == '1') + { + This->noactivateapp = TRUE; + } + else + { + This->noactivateapp = FALSE; + } + GetPrivateProfileStringA("ddraw", "vhack", "false", tmp, sizeof(tmp), SettingsIniPath); if (tolower(tmp[0]) == 'y' || tolower(tmp[0]) == 't' || tolower(tmp[0]) == 'e' || tmp[0] == '1') {