summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorlat9nq <lat9nq@gmail.com>2021-10-30 07:21:26 +0200
committerlat9nq <lat9nq@gmail.com>2021-10-30 07:23:52 +0200
commit604b6d121010aa3badbf40d09db4a26d0c963c5f (patch)
tree9640ef26287b60c6b9d10a04891672bcf4e58629 /src
parentMerge pull request #7186 from MightyCreak/fix-crash-configure-window (diff)
downloadyuzu-604b6d121010aa3badbf40d09db4a26d0c963c5f.tar
yuzu-604b6d121010aa3badbf40d09db4a26d0c963c5f.tar.gz
yuzu-604b6d121010aa3badbf40d09db4a26d0c963c5f.tar.bz2
yuzu-604b6d121010aa3badbf40d09db4a26d0c963c5f.tar.lz
yuzu-604b6d121010aa3badbf40d09db4a26d0c963c5f.tar.xz
yuzu-604b6d121010aa3badbf40d09db4a26d0c963c5f.tar.zst
yuzu-604b6d121010aa3badbf40d09db4a26d0c963c5f.zip
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)
copy_yuzu_Qt5_deps(yuzu)
endif()
+if (ENABLE_SDL2)
+ target_link_libraries(yuzu PRIVATE SDL2)
+ target_compile_definitions(yuzu PRIVATE HAVE_SDL2)
+endif()
+
if (MSVC)
include(CopyYuzuSDLDeps)
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
#include <QUrl>
#include <QtConcurrent/QtConcurrent>
+#ifdef HAVE_SDL2
+#include <SDL.h> // For SDL ScreenSaver functions
+#endif
+
#include <fmt/format.h>
#include "common/detached_tasks.h"
#include "common/fs/fs.h"
@@ -287,6 +291,14 @@ GMainWindow::GMainWindow()
ui->action_Fullscreen->setChecked(false);
+#if defined(HAVE_SDL2) && !defined(_WIN32)
+ SDL_InitSubSystem(SDL_INIT_VIDEO);
+ // SDL disables the screen saver by default, and setting the hint
+ // SDL_HINT_VIDEO_ALLOW_SCREENSAVER doesn't seem to work, so we just enable the screen saver
+ // for now.
+ SDL_EnableScreenSaver();
+#endif
+
QStringList args = QApplication::arguments();
if (args.size() < 2) {
@@ -357,8 +369,9 @@ GMainWindow::GMainWindow()
GMainWindow::~GMainWindow() {
// will get automatically deleted otherwise
- if (render_window->parent() == nullptr)
+ if (render_window->parent() == nullptr) {
delete render_window;
+ }
}
void GMainWindow::RegisterMetaTypes() {
@@ -1223,12 +1236,16 @@ void GMainWindow::OnDisplayTitleBars(bool show) {
void GMainWindow::PreventOSSleep() {
#ifdef _WIN32
SetThreadExecutionState(ES_CONTINUOUS | ES_SYSTEM_REQUIRED | ES_DISPLAY_REQUIRED);
+#elif defined(HAVE_SDL2)
+ SDL_DisableScreenSaver();
#endif
}
void GMainWindow::AllowOSSleep() {
#ifdef _WIN32
SetThreadExecutionState(ES_CONTINUOUS);
+#elif defined(HAVE_SDL2)
+ SDL_EnableScreenSaver();
#endif
}