mirror of
https://github.com/ZDoom/gzdoom.git
synced 2025-04-07 02:22:58 +00:00
- revamp priority changing on windows, add cvar i_allowprioritychange
to disallow priority changing entirely, allowing batch scripts to dictate GZDoom's process priority
This commit is contained in:
parent
59ac494c19
commit
f21b68c8f6
2 changed files with 14 additions and 7 deletions
|
@ -128,6 +128,7 @@ EXTERN_CVAR(Bool, i_pauseinbackground);
|
|||
|
||||
|
||||
CVAR (Bool, k_allowfullscreentoggle, true, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
|
||||
CVAR (Bool, i_allowprioritychange, true, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
|
||||
|
||||
static void I_CheckGUICapture ()
|
||||
{
|
||||
|
@ -485,13 +486,16 @@ LRESULT CALLBACK WndProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
|||
|
||||
case WM_ACTIVATEAPP:
|
||||
AppActive = (wParam == TRUE);
|
||||
if (wParam || !i_pauseinbackground)
|
||||
if (!i_pauseinbackground && i_allowprioritychange)
|
||||
{
|
||||
SetPriorityClass (GetCurrentProcess (), INGAME_PRIORITY_CLASS);
|
||||
}
|
||||
else if (!noidle && !(sysCallbacks.NetGame && sysCallbacks.NetGame()))
|
||||
{
|
||||
SetPriorityClass (GetCurrentProcess (), IDLE_PRIORITY_CLASS);
|
||||
if (wParam)
|
||||
{
|
||||
SetPriorityClass (GetCurrentProcess (), INGAME_PRIORITY_CLASS);
|
||||
}
|
||||
else if (!noidle && !(sysCallbacks.NetGame && sysCallbacks.NetGame()))
|
||||
{
|
||||
SetPriorityClass (GetCurrentProcess (), IDLE_PRIORITY_CLASS);
|
||||
}
|
||||
}
|
||||
S_SetSoundPaused (wParam);
|
||||
break;
|
||||
|
|
|
@ -244,6 +244,9 @@ void CalculateCPUSpeed()
|
|||
// probably never use the performance statistics.
|
||||
min_diff = freq.LowPart * 11 / 200;
|
||||
|
||||
// just in case we were launched with a custom priority class, keep it
|
||||
DWORD OldPriorityClass = GetPriorityClass(GetCurrentProcess());
|
||||
|
||||
// Minimize the chance of task switching during the testing by going very
|
||||
// high priority. This is another reason to avoid timing for too long.
|
||||
SetPriorityClass(GetCurrentProcess(), REALTIME_PRIORITY_CLASS);
|
||||
|
@ -258,7 +261,7 @@ void CalculateCPUSpeed()
|
|||
do { QueryPerformanceCounter(&count1); } while ((count1.QuadPart - count2.QuadPart) < min_diff);
|
||||
ClockCalibration.Unclock();
|
||||
|
||||
SetPriorityClass(GetCurrentProcess(), NORMAL_PRIORITY_CLASS);
|
||||
SetPriorityClass(GetCurrentProcess(), OldPriorityClass);
|
||||
SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_NORMAL);
|
||||
|
||||
PerfToSec = double(count1.QuadPart - count2.QuadPart) / (double(ClockCalibration.GetRawCounter()) * freq.QuadPart);
|
||||
|
|
Loading…
Reference in a new issue