summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar lat9nq2021-10-30 01:21:26 -0400
committerGravatar lat9nq2021-10-30 01:23:52 -0400
commit604b6d121010aa3badbf40d09db4a26d0c963c5f (patch)
tree9640ef26287b60c6b9d10a04891672bcf4e58629 /src
parentMerge pull request #7186 from MightyCreak/fix-crash-configure-window (diff)
downloadyuzu-604b6d121010aa3badbf40d09db4a26d0c963c5f.tar.gz
yuzu-604b6d121010aa3badbf40d09db4a26d0c963c5f.tar.xz
yuzu-604b6d121010aa3badbf40d09db4a26d0c963c5f.zip
yuzu qt: Disable the screensaver with SDL2
Disables the screen saver when a game boots using SDL2 so that it works on any supported platform.
Diffstat (limited to 'src')
-rw-r--r--src/yuzu/CMakeLists.txt5
-rw-r--r--src/yuzu/main.cpp19
2 files changed, 23 insertions, 1 deletions
diff --git a/src/yuzu/CMakeLists.txt b/src/yuzu/CMakeLists.txt
index 402be6a78..d62fd566f 100644
--- a/src/yuzu/CMakeLists.txt
+++ b/src/yuzu/CMakeLists.txt
@@ -299,6 +299,11 @@ if (YUZU_USE_BUNDLED_QT)
299 copy_yuzu_Qt5_deps(yuzu) 299 copy_yuzu_Qt5_deps(yuzu)
300endif() 300endif()
301 301
302if (ENABLE_SDL2)
303 target_link_libraries(yuzu PRIVATE SDL2)
304 target_compile_definitions(yuzu PRIVATE HAVE_SDL2)
305endif()
306
302if (MSVC) 307if (MSVC)
303 include(CopyYuzuSDLDeps) 308 include(CopyYuzuSDLDeps)
304 include(CopyYuzuFFmpegDeps) 309 include(CopyYuzuFFmpegDeps)
diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp
index 2af582fe5..e871fee36 100644
--- a/src/yuzu/main.cpp
+++ b/src/yuzu/main.cpp
@@ -66,6 +66,10 @@ static FileSys::VirtualFile VfsDirectoryCreateFileWrapper(const FileSys::Virtual
66#include <QUrl> 66#include <QUrl>
67#include <QtConcurrent/QtConcurrent> 67#include <QtConcurrent/QtConcurrent>
68 68
69#ifdef HAVE_SDL2
70#include <SDL.h> // For SDL ScreenSaver functions
71#endif
72
69#include <fmt/format.h> 73#include <fmt/format.h>
70#include "common/detached_tasks.h" 74#include "common/detached_tasks.h"
71#include "common/fs/fs.h" 75#include "common/fs/fs.h"
@@ -287,6 +291,14 @@ GMainWindow::GMainWindow()
287 291
288 ui->action_Fullscreen->setChecked(false); 292 ui->action_Fullscreen->setChecked(false);
289 293
294#if defined(HAVE_SDL2) && !defined(_WIN32)
295 SDL_InitSubSystem(SDL_INIT_VIDEO);
296 // SDL disables the screen saver by default, and setting the hint
297 // SDL_HINT_VIDEO_ALLOW_SCREENSAVER doesn't seem to work, so we just enable the screen saver
298 // for now.
299 SDL_EnableScreenSaver();
300#endif
301
290 QStringList args = QApplication::arguments(); 302 QStringList args = QApplication::arguments();
291 303
292 if (args.size() < 2) { 304 if (args.size() < 2) {
@@ -357,8 +369,9 @@ GMainWindow::GMainWindow()
357 369
358GMainWindow::~GMainWindow() { 370GMainWindow::~GMainWindow() {
359 // will get automatically deleted otherwise 371 // will get automatically deleted otherwise
360 if (render_window->parent() == nullptr) 372 if (render_window->parent() == nullptr) {
361 delete render_window; 373 delete render_window;
374 }
362} 375}
363 376
364void GMainWindow::RegisterMetaTypes() { 377void GMainWindow::RegisterMetaTypes() {
@@ -1223,12 +1236,16 @@ void GMainWindow::OnDisplayTitleBars(bool show) {
1223void GMainWindow::PreventOSSleep() { 1236void GMainWindow::PreventOSSleep() {
1224#ifdef _WIN32 1237#ifdef _WIN32
1225 SetThreadExecutionState(ES_CONTINUOUS | ES_SYSTEM_REQUIRED | ES_DISPLAY_REQUIRED); 1238 SetThreadExecutionState(ES_CONTINUOUS | ES_SYSTEM_REQUIRED | ES_DISPLAY_REQUIRED);
1239#elif defined(HAVE_SDL2)
1240 SDL_DisableScreenSaver();
1226#endif 1241#endif
1227} 1242}
1228 1243
1229void GMainWindow::AllowOSSleep() { 1244void GMainWindow::AllowOSSleep() {
1230#ifdef _WIN32 1245#ifdef _WIN32
1231 SetThreadExecutionState(ES_CONTINUOUS); 1246 SetThreadExecutionState(ES_CONTINUOUS);
1247#elif defined(HAVE_SDL2)
1248 SDL_EnableScreenSaver();
1232#endif 1249#endif
1233} 1250}
1234 1251