From 6dd8e2a822d5b6872812effea917963211e3572e Mon Sep 17 00:00:00 2001
From: Oliver Behnke <oliver.behnke@aei.mpg.de>
Date: Mon, 7 Dec 2020 11:44:08 +0100
Subject: [PATCH] Set screensaver hint before video initialization

* Avoids changing the mode from the default to the disired state
* Doesn't trigger powerd on macOS (no issue, just optimizing)
---
 src/framework/WindowManager.cpp | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/src/framework/WindowManager.cpp b/src/framework/WindowManager.cpp
index dfbcd83..8e363ad 100644
--- a/src/framework/WindowManager.cpp
+++ b/src/framework/WindowManager.cpp
@@ -37,6 +37,9 @@ WindowManager::~WindowManager()
 
 bool WindowManager::initialize(const int width, const int height, const int frameRate)
 {
+	// allow screensaver (or we might block BOINC's own, our parent)
+	SDL_SetHint(SDL_HINT_VIDEO_ALLOW_SCREENSAVER, "1");
+
 	if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER) < 0) {
 		cerr << "Window system could not be initalized: " << SDL_GetError() << endl;
 		return false;
@@ -44,12 +47,6 @@ bool WindowManager::initialize(const int width, const int height, const int fram
 
 	atexit(SDL_Quit);
 
-	// allow screensaver (or we might block BOINC's own, our parent)
-	SDL_EnableScreenSaver();
-	if (SDL_IsScreenSaverEnabled() == SDL_FALSE) {
-		cerr << "Screensavers couldn't be enabled! This might break usage as BOINC screensaver..." << endl;
-	}
-
 	// retrieve current video settings (of the primary display)
 	SDL_DisplayMode mode;
 	if (!SDL_GetDesktopDisplayMode(0, &mode)) {
-- 
GitLab