diff options
| author | 2021-10-30 01:21:26 -0400 | |
|---|---|---|
| committer | 2021-10-30 01:23:52 -0400 | |
| commit | 604b6d121010aa3badbf40d09db4a26d0c963c5f (patch) | |
| tree | 9640ef26287b60c6b9d10a04891672bcf4e58629 /src | |
| parent | Merge pull request #7186 from MightyCreak/fix-crash-configure-window (diff) | |
| download | yuzu-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.txt | 5 | ||||
| -rw-r--r-- | src/yuzu/main.cpp | 19 |
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) |
| 300 | endif() | 300 | endif() |
| 301 | 301 | ||
| 302 | if (ENABLE_SDL2) | ||
| 303 | target_link_libraries(yuzu PRIVATE SDL2) | ||
| 304 | target_compile_definitions(yuzu PRIVATE HAVE_SDL2) | ||
| 305 | endif() | ||
| 306 | |||
| 302 | if (MSVC) | 307 | if (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 | ||
| 358 | GMainWindow::~GMainWindow() { | 370 | GMainWindow::~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 | ||
| 364 | void GMainWindow::RegisterMetaTypes() { | 377 | void GMainWindow::RegisterMetaTypes() { |
| @@ -1223,12 +1236,16 @@ void GMainWindow::OnDisplayTitleBars(bool show) { | |||
| 1223 | void GMainWindow::PreventOSSleep() { | 1236 | void 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 | ||
| 1229 | void GMainWindow::AllowOSSleep() { | 1244 | void 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 | ||