Skip to content

Commit 895db5b

Browse files
committed
SetThreadExecutionState for windows and SPI_SETSCREENSAVEACTIVE for WINE
1 parent 7505295 commit 895db5b

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/dllmain.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,10 @@ BOOL WINAPI DllMain(HANDLE hDll, DWORD dwReason, LPVOID lpReserved)
132132
set_aware();
133133
}
134134

135+
/* Make sure screensaver will stay off and monitors will stay on */
136+
SetThreadExecutionState(ES_CONTINUOUS | ES_DISPLAY_REQUIRED);
137+
138+
/* WINE does not support SetThreadExecutionState so we'll have to use SPI_SETSCREENSAVEACTIVE instead */
135139
BOOL screensaver_enabled = FALSE;
136140
SystemParametersInfoA(SPI_GETSCREENSAVEACTIVE, 0, &screensaver_enabled, 0);
137141

@@ -161,6 +165,8 @@ BOOL WINAPI DllMain(HANDLE hDll, DWORD dwReason, LPVOID lpReserved)
161165
dinput_hook_exit();
162166
hook_exit();
163167

168+
SetThreadExecutionState(ES_CONTINUOUS);
169+
164170
if (g_screensaver_disabled)
165171
{
166172
SystemParametersInfoA(SPI_SETSCREENSAVEACTIVE, TRUE, NULL, 0);

0 commit comments

Comments
 (0)