Fix handling of screen saver after fa4c0e82bde20b8d5b652c81842bda11a692538a and reset background events hint for UI after streaming

This commit is contained in:
Cameron Gutman 2019-03-26 21:11:24 -07:00
parent 26bdc3e1d5
commit 50f47f1ed5
2 changed files with 21 additions and 12 deletions

View File

@ -311,6 +311,11 @@ int main(int argc, char *argv[])
// Register custom metatypes for use in signals
qRegisterMetaType<NvApp>("NvApp");
// Allow the display to sleep by default. We will manually use SDL_DisableScreenSaver()
// and SDL_EnableScreenSaver() when appropriate. This hint must be set before
// initializing the SDL video subsystem to have any effect.
SDL_SetHint(SDL_HINT_VIDEO_ALLOW_SCREENSAVER, "1");
// Steam Link requires that we initialize video before creating our
// QGuiApplication in order to configure the framebuffer correctly.
// It's fine to do on other platforms too, and it can save some time
@ -319,8 +324,21 @@ int main(int argc, char *argv[])
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
"SDL_InitSubSystem(SDL_INIT_VIDEO | SDL_INIT_TIMER) failed: %s",
SDL_GetError());
return -1;
}
// Use atexit() to ensure SDL_Quit() is called. This avoids
// racing with object destruction where SDL may be used.
atexit(SDL_Quit);
// Avoid the default behavior of changing the timer resolution to 1 ms.
// We don't want this all the time that Moonlight is open. We will set
// it manually when we start streaming.
SDL_SetHint(SDL_HINT_TIMER_RESOLUTION, "0");
// Disable minimize on focus loss by default. Users seem to want this off by default.
SDL_SetHint(SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS, "0");
QGuiApplication app(argc, argv);
// Override the default palette to fix dialog rendering on Linux
@ -441,18 +459,6 @@ int main(int argc, char *argv[])
if (engine.rootObjects().isEmpty())
return -1;
// Use atexit() to ensure SDL_Quit() is called. This avoids
// racing with object destruction where SDL may be used.
atexit(SDL_Quit);
// Avoid the default behavior of changing the timer resolution to 1 ms.
// We don't want this all the time that Moonlight is open. We will set
// it manually when we start streaming.
SDL_SetHint(SDL_HINT_TIMER_RESOLUTION, "0");
// Disable minimize on focus loss by default. Users seem to want this off by default.
SDL_SetHintWithPriority(SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS, "0", SDL_HINT_DEFAULT);
int err = app.exec();
// Give worker tasks time to properly exit. Fixes PendingQuitTask

View File

@ -128,6 +128,9 @@ SdlInputHandler::~SdlInputHandler()
SDL_QuitSubSystem(SDL_INIT_JOYSTICK);
SDL_assert(!SDL_WasInit(SDL_INIT_JOYSTICK));
// Return background event handling to off
SDL_SetHint(SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS, "0");
}
void SdlInputHandler::handleKeyEvent(SDL_KeyboardEvent* event)