diff --git a/src/d_main.cpp b/src/d_main.cpp index 76b31ba82..dc9f2e27f 100644 --- a/src/d_main.cpp +++ b/src/d_main.cpp @@ -250,6 +250,7 @@ FStartupInfo DoomStartupInfo; FString lastIWAD; int restart = 0; bool batchrun; // just run the startup and collect all error messages in a logfile, then quit without any interaction +bool AppActive = true; cycle_t FrameCycles; @@ -658,6 +659,8 @@ CVAR (Flag, compat_multiexit, compatflags2, COMPATF2_MULTIEXIT); CVAR (Flag, compat_teleport, compatflags2, COMPATF2_TELEPORT); CVAR (Flag, compat_pushwindow, compatflags2, COMPATF2_PUSHWINDOW); +CVAR(Bool, vid_activeinbackground, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) + //========================================================================== // // D_Display @@ -674,6 +677,11 @@ void D_Display () if (nodrawers || screen == NULL) return; // for comparative timing / profiling + if (!AppActive && (screen->IsFullscreen() || !vid_activeinbackground)) + { + return; + } + cycle_t cycles; cycles.Reset(); diff --git a/src/gl/system/gl_framebuffer.cpp b/src/gl/system/gl_framebuffer.cpp index 8549abb7e..ea59da031 100644 --- a/src/gl/system/gl_framebuffer.cpp +++ b/src/gl/system/gl_framebuffer.cpp @@ -166,12 +166,6 @@ void OpenGLFrameBuffer::InitializeState() void OpenGLFrameBuffer::Update() { - if (!CanUpdate()) - { - GLRenderer->Flush(); - return; - } - Begin2D(false); DrawRateStuff(); diff --git a/src/posix/cocoa/i_main.mm b/src/posix/cocoa/i_main.mm index d528a0f72..0bca80885 100644 --- a/src/posix/cocoa/i_main.mm +++ b/src/posix/cocoa/i_main.mm @@ -302,18 +302,24 @@ ApplicationController* appCtrl; } +extern bool AppActive; + - (void)applicationDidBecomeActive:(NSNotification*)aNotification { ZD_UNUSED(aNotification); S_SetSoundPaused(1); + + AppActive = true; } - (void)applicationWillResignActive:(NSNotification*)aNotification { ZD_UNUSED(aNotification); - S_SetSoundPaused((!!i_soundinbackground) || 0); + S_SetSoundPaused(i_soundinbackground); + + AppActive = false; } diff --git a/src/posix/cocoa/i_video.mm b/src/posix/cocoa/i_video.mm index caf5292e4..6c731ddc2 100644 --- a/src/posix/cocoa/i_video.mm +++ b/src/posix/cocoa/i_video.mm @@ -1122,22 +1122,6 @@ void SDLGLFB::InitializeState() { } -bool SDLGLFB::CanUpdate() -{ - if (m_Lock != 1) - { - if (m_Lock > 0) - { - UpdatePending = true; - --m_Lock; - } - - return false; - } - - return true; -} - void SDLGLFB::SwapBuffers() { [[NSOpenGLContext currentContext] flushBuffer]; diff --git a/src/posix/cocoa/sdlglvideo.h b/src/posix/cocoa/sdlglvideo.h index 55e08c583..7e98d956d 100644 --- a/src/posix/cocoa/sdlglvideo.h +++ b/src/posix/cocoa/sdlglvideo.h @@ -81,7 +81,6 @@ protected: void InitializeState(); - bool CanUpdate(); void SwapBuffers(); void SetGammaTable(uint16_t* table); diff --git a/src/posix/sdl/i_input.cpp b/src/posix/sdl/i_input.cpp index 338b343d5..40a3329ec 100644 --- a/src/posix/sdl/i_input.cpp +++ b/src/posix/sdl/i_input.cpp @@ -311,9 +311,16 @@ void MessagePump (const SDL_Event &sev) case SDL_WINDOWEVENT: switch (sev.window.event) { + extern bool AppActive; + case SDL_WINDOWEVENT_FOCUS_GAINED: + S_SetSoundPaused(1); + AppActive = true; + break; + case SDL_WINDOWEVENT_FOCUS_LOST: - S_SetSoundPaused((!!i_soundinbackground) || sev.window.event == SDL_WINDOWEVENT_FOCUS_GAINED); + S_SetSoundPaused(i_soundinbackground); + AppActive = false; break; } break; diff --git a/src/posix/sdl/sdlglvideo.cpp b/src/posix/sdl/sdlglvideo.cpp index bb8b40dec..663947ae7 100644 --- a/src/posix/sdl/sdlglvideo.cpp +++ b/src/posix/sdl/sdlglvideo.cpp @@ -405,20 +405,6 @@ void SDLGLFB::InitializeState() { } -bool SDLGLFB::CanUpdate () -{ - if (m_Lock != 1) - { - if (m_Lock > 0) - { - UpdatePending = true; - --m_Lock; - } - return false; - } - return true; -} - void SDLGLFB::SetGammaTable(uint16_t *tbl) { if (m_supportsGamma) diff --git a/src/posix/sdl/sdlglvideo.h b/src/posix/sdl/sdlglvideo.h index 2dce3aeed..3be296b66 100644 --- a/src/posix/sdl/sdlglvideo.h +++ b/src/posix/sdl/sdlglvideo.h @@ -77,7 +77,6 @@ public: virtual int GetTrueHeight() { return GetClientHeight(); } protected: - bool CanUpdate(); void SetGammaTable(uint16_t *tbl); void ResetGammaTable(); void InitializeState(); diff --git a/src/win32/i_input.cpp b/src/win32/i_input.cpp index 84ab3ff84..c67dc3d6b 100644 --- a/src/win32/i_input.cpp +++ b/src/win32/i_input.cpp @@ -156,7 +156,7 @@ LPDIRECTINPUT8 g_pdi; LPDIRECTINPUT g_pdi3; -BOOL AppActive = TRUE; +extern bool AppActive; int SessionState = 0; int BlockMouseMove; @@ -543,7 +543,7 @@ LRESULT CALLBACK WndProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) break; case WM_ACTIVATEAPP: - AppActive = wParam; + AppActive = wParam == TRUE; if (wParam) { SetPriorityClass (GetCurrentProcess (), INGAME_PRIORITY_CLASS); diff --git a/src/win32/win32gliface.cpp b/src/win32/win32gliface.cpp index 71369690c..471fc4c53 100644 --- a/src/win32/win32gliface.cpp +++ b/src/win32/win32gliface.cpp @@ -63,7 +63,6 @@ #include "gl/system/gl_swframebuffer.h" extern HWND Window; -extern BOOL AppActive; extern "C" { __declspec(dllexport) DWORD NvOptimusEnablement = 0x00000001; @@ -80,8 +79,6 @@ PFNWGLSWAPINTERVALEXTPROC myWglSwapIntervalExtProc; -CVAR(Bool, vid_activeinbackground, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) - CUSTOM_CVAR(Bool, gl_debug, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL) { Printf("This won't take effect until " GAMENAME " is restarted.\n"); @@ -1143,18 +1140,6 @@ void Win32GLFrameBuffer::InitializeState() // //========================================================================== -bool Win32GLFrameBuffer::CanUpdate() -{ - if (!AppActive && (IsFullscreen() || !vid_activeinbackground)) return false; - return true; -} - -//========================================================================== -// -// -// -//========================================================================== - void Win32GLFrameBuffer::ResetGammaTable() { if (m_supportsGamma) diff --git a/src/win32/win32gliface.h b/src/win32/win32gliface.h index 09e9e5642..e0878a96a 100644 --- a/src/win32/win32gliface.h +++ b/src/win32/win32gliface.h @@ -67,8 +67,6 @@ public: void InitializeState(); protected: - - bool CanUpdate(); void ResetGammaTable(); void SetGammaTable(uint16_t * tbl);