mirror of
https://git.h3cjp.net/H3cJP/citra.git
synced 2024-11-23 21:52:45 +00:00
implement pause on system suspend (#8585)
This commit is contained in:
parent
ea861cc1c4
commit
b7642cff36
|
@ -386,6 +386,8 @@ GMainWindow::GMainWindow(bool has_broken_vulkan)
|
||||||
SDL_EnableScreenSaver();
|
SDL_EnableScreenSaver();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
SetupPrepareForSleep();
|
||||||
|
|
||||||
Common::Log::Start();
|
Common::Log::Start();
|
||||||
|
|
||||||
QStringList args = QApplication::arguments();
|
QStringList args = QApplication::arguments();
|
||||||
|
@ -1327,6 +1329,43 @@ void GMainWindow::OnDisplayTitleBars(bool show) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GMainWindow::SetupPrepareForSleep() {
|
||||||
|
#ifdef __linux__
|
||||||
|
auto bus = QDBusConnection::systemBus();
|
||||||
|
if (bus.isConnected()) {
|
||||||
|
const bool success = bus.connect(
|
||||||
|
QStringLiteral("org.freedesktop.login1"), QStringLiteral("/org/freedesktop/login1"),
|
||||||
|
QStringLiteral("org.freedesktop.login1.Manager"), QStringLiteral("PrepareForSleep"),
|
||||||
|
QStringLiteral("b"), this, SLOT(OnPrepareForSleep(bool)));
|
||||||
|
|
||||||
|
if (!success) {
|
||||||
|
LOG_WARNING(Frontend, "Couldn't register PrepareForSleep signal");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
LOG_WARNING(Frontend, "QDBusConnection system bus is not connected");
|
||||||
|
}
|
||||||
|
#endif // __linux__
|
||||||
|
}
|
||||||
|
|
||||||
|
void GMainWindow::OnPrepareForSleep(bool prepare_sleep) {
|
||||||
|
if (emu_thread == nullptr) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (prepare_sleep) {
|
||||||
|
if (emu_thread->IsRunning()) {
|
||||||
|
auto_paused = true;
|
||||||
|
OnPauseGame();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (!emu_thread->IsRunning() && auto_paused) {
|
||||||
|
auto_paused = false;
|
||||||
|
RequestGameResume();
|
||||||
|
OnStartGame();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
static std::optional<QDBusObjectPath> HoldWakeLockLinux(u32 window_id = 0) {
|
static std::optional<QDBusObjectPath> HoldWakeLockLinux(u32 window_id = 0) {
|
||||||
if (!QDBusConnection::sessionBus().isConnected()) {
|
if (!QDBusConnection::sessionBus().isConnected()) {
|
||||||
|
|
|
@ -204,7 +204,7 @@ private:
|
||||||
void ConnectMenuEvents();
|
void ConnectMenuEvents();
|
||||||
void UpdateMenuState();
|
void UpdateMenuState();
|
||||||
|
|
||||||
MultiplayerState* multiplayer_state = nullptr;
|
void SetupPrepareForSleep();
|
||||||
|
|
||||||
void PreventOSSleep();
|
void PreventOSSleep();
|
||||||
void AllowOSSleep();
|
void AllowOSSleep();
|
||||||
|
@ -265,6 +265,7 @@ private slots:
|
||||||
void OnPauseGame();
|
void OnPauseGame();
|
||||||
void OnPauseContinueGame();
|
void OnPauseContinueGame();
|
||||||
void OnStopGame();
|
void OnStopGame();
|
||||||
|
void OnPrepareForSleep(bool prepare_sleep);
|
||||||
void OnMenuReportCompatibility();
|
void OnMenuReportCompatibility();
|
||||||
void OnOpenModsPage();
|
void OnOpenModsPage();
|
||||||
void OnOpenQuickstartGuide();
|
void OnOpenQuickstartGuide();
|
||||||
|
@ -355,6 +356,8 @@ private:
|
||||||
std::unique_ptr<DiscordRPC::DiscordInterface> discord_rpc;
|
std::unique_ptr<DiscordRPC::DiscordInterface> discord_rpc;
|
||||||
std::shared_ptr<InputCommon::InputSubsystem> input_subsystem;
|
std::shared_ptr<InputCommon::InputSubsystem> input_subsystem;
|
||||||
|
|
||||||
|
MultiplayerState* multiplayer_state = nullptr;
|
||||||
|
|
||||||
GRenderWindow* render_window;
|
GRenderWindow* render_window;
|
||||||
GameList* game_list;
|
GameList* game_list;
|
||||||
LoadingScreen* loading_screen;
|
LoadingScreen* loading_screen;
|
||||||
|
|
Loading…
Reference in a new issue