mirror of
https://github.com/yuzu-emu/yuzu.git
synced 2024-11-23 19:35:38 +01:00
Merge pull request #2831 from FearlessTobi/port-4914
Port citra-emu/citra#4914: "Fix to Windows sleep issues"
This commit is contained in:
commit
86b39e0677
@ -119,6 +119,7 @@ Q_IMPORT_PLUGIN(QWindowsIntegrationPlugin);
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
#include <windows.h>
|
||||||
extern "C" {
|
extern "C" {
|
||||||
// tells Nvidia and AMD drivers to use the dedicated GPU by default on laptops with switchable
|
// tells Nvidia and AMD drivers to use the dedicated GPU by default on laptops with switchable
|
||||||
// graphics
|
// graphics
|
||||||
@ -747,6 +748,18 @@ void GMainWindow::OnDisplayTitleBars(bool show) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GMainWindow::PreventOSSleep() {
|
||||||
|
#ifdef _WIN32
|
||||||
|
SetThreadExecutionState(ES_CONTINUOUS | ES_SYSTEM_REQUIRED | ES_DISPLAY_REQUIRED);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void GMainWindow::AllowOSSleep() {
|
||||||
|
#ifdef _WIN32
|
||||||
|
SetThreadExecutionState(ES_CONTINUOUS);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
QStringList GMainWindow::GetUnsupportedGLExtensions() {
|
QStringList GMainWindow::GetUnsupportedGLExtensions() {
|
||||||
QStringList unsupported_ext;
|
QStringList unsupported_ext;
|
||||||
|
|
||||||
@ -966,6 +979,8 @@ void GMainWindow::BootGame(const QString& filename) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void GMainWindow::ShutdownGame() {
|
void GMainWindow::ShutdownGame() {
|
||||||
|
AllowOSSleep();
|
||||||
|
|
||||||
discord_rpc->Pause();
|
discord_rpc->Pause();
|
||||||
emu_thread->RequestStop();
|
emu_thread->RequestStop();
|
||||||
|
|
||||||
@ -1567,6 +1582,8 @@ void GMainWindow::OnMenuRecentFile() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void GMainWindow::OnStartGame() {
|
void GMainWindow::OnStartGame() {
|
||||||
|
PreventOSSleep();
|
||||||
|
|
||||||
emu_thread->SetRunning(true);
|
emu_thread->SetRunning(true);
|
||||||
|
|
||||||
qRegisterMetaType<Core::Frontend::SoftwareKeyboardParameters>(
|
qRegisterMetaType<Core::Frontend::SoftwareKeyboardParameters>(
|
||||||
@ -1598,6 +1615,8 @@ void GMainWindow::OnPauseGame() {
|
|||||||
ui.action_Pause->setEnabled(false);
|
ui.action_Pause->setEnabled(false);
|
||||||
ui.action_Stop->setEnabled(true);
|
ui.action_Stop->setEnabled(true);
|
||||||
ui.action_Capture_Screenshot->setEnabled(false);
|
ui.action_Capture_Screenshot->setEnabled(false);
|
||||||
|
|
||||||
|
AllowOSSleep();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GMainWindow::OnStopGame() {
|
void GMainWindow::OnStopGame() {
|
||||||
|
@ -130,6 +130,9 @@ private:
|
|||||||
void ConnectWidgetEvents();
|
void ConnectWidgetEvents();
|
||||||
void ConnectMenuEvents();
|
void ConnectMenuEvents();
|
||||||
|
|
||||||
|
void PreventOSSleep();
|
||||||
|
void AllowOSSleep();
|
||||||
|
|
||||||
QStringList GetUnsupportedGLExtensions();
|
QStringList GetUnsupportedGLExtensions();
|
||||||
bool LoadROM(const QString& filename);
|
bool LoadROM(const QString& filename);
|
||||||
void BootGame(const QString& filename);
|
void BootGame(const QString& filename);
|
||||||
|
Loading…
Reference in New Issue
Block a user