mirror of
https://github.com/yuzu-emu/yuzu.git
synced 2024-07-04 23:31:19 +01:00
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.
This commit is contained in:
parent
40c8a8c627
commit
604b6d1210
2 changed files with 23 additions and 1 deletions
|
@ -299,6 +299,11 @@ if (YUZU_USE_BUNDLED_QT)
|
||||||
copy_yuzu_Qt5_deps(yuzu)
|
copy_yuzu_Qt5_deps(yuzu)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if (ENABLE_SDL2)
|
||||||
|
target_link_libraries(yuzu PRIVATE SDL2)
|
||||||
|
target_compile_definitions(yuzu PRIVATE HAVE_SDL2)
|
||||||
|
endif()
|
||||||
|
|
||||||
if (MSVC)
|
if (MSVC)
|
||||||
include(CopyYuzuSDLDeps)
|
include(CopyYuzuSDLDeps)
|
||||||
include(CopyYuzuFFmpegDeps)
|
include(CopyYuzuFFmpegDeps)
|
||||||
|
|
|
@ -66,6 +66,10 @@ static FileSys::VirtualFile VfsDirectoryCreateFileWrapper(const FileSys::Virtual
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
#include <QtConcurrent/QtConcurrent>
|
#include <QtConcurrent/QtConcurrent>
|
||||||
|
|
||||||
|
#ifdef HAVE_SDL2
|
||||||
|
#include <SDL.h> // For SDL ScreenSaver functions
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <fmt/format.h>
|
#include <fmt/format.h>
|
||||||
#include "common/detached_tasks.h"
|
#include "common/detached_tasks.h"
|
||||||
#include "common/fs/fs.h"
|
#include "common/fs/fs.h"
|
||||||
|
@ -287,6 +291,14 @@ GMainWindow::GMainWindow()
|
||||||
|
|
||||||
ui->action_Fullscreen->setChecked(false);
|
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();
|
QStringList args = QApplication::arguments();
|
||||||
|
|
||||||
if (args.size() < 2) {
|
if (args.size() < 2) {
|
||||||
|
@ -357,8 +369,9 @@ GMainWindow::GMainWindow()
|
||||||
|
|
||||||
GMainWindow::~GMainWindow() {
|
GMainWindow::~GMainWindow() {
|
||||||
// will get automatically deleted otherwise
|
// will get automatically deleted otherwise
|
||||||
if (render_window->parent() == nullptr)
|
if (render_window->parent() == nullptr) {
|
||||||
delete render_window;
|
delete render_window;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GMainWindow::RegisterMetaTypes() {
|
void GMainWindow::RegisterMetaTypes() {
|
||||||
|
@ -1223,12 +1236,16 @@ void GMainWindow::OnDisplayTitleBars(bool show) {
|
||||||
void GMainWindow::PreventOSSleep() {
|
void GMainWindow::PreventOSSleep() {
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
SetThreadExecutionState(ES_CONTINUOUS | ES_SYSTEM_REQUIRED | ES_DISPLAY_REQUIRED);
|
SetThreadExecutionState(ES_CONTINUOUS | ES_SYSTEM_REQUIRED | ES_DISPLAY_REQUIRED);
|
||||||
|
#elif defined(HAVE_SDL2)
|
||||||
|
SDL_DisableScreenSaver();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void GMainWindow::AllowOSSleep() {
|
void GMainWindow::AllowOSSleep() {
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
SetThreadExecutionState(ES_CONTINUOUS);
|
SetThreadExecutionState(ES_CONTINUOUS);
|
||||||
|
#elif defined(HAVE_SDL2)
|
||||||
|
SDL_EnableScreenSaver();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue