Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Qt: Disable Display Sleep when game is running (Windows) #3008

Merged
merged 1 commit into from
Sep 12, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 18 additions & 3 deletions Source/Core/DolphinQt/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,27 @@ void DMainWindow::StartGame(const QString filename)
}
else
{
// TODO: Disable screensaver!
DisableScreensaver();
emit CoreStateChanged(Core::CORE_RUN);
}
}

void DMainWindow::DisableScreensaver()
{
#ifdef Q_OS_WIN
// Prevents Windows from sleeping or turning off the display
SetThreadExecutionState(ES_CONTINUOUS | ES_DISPLAY_REQUIRED);

This comment was marked as off-topic.

#endif
}

void DMainWindow::EnableScreensaver()
{
#ifdef Q_OS_WIN
// Allows Windows to sleep and turn off the display
SetThreadExecutionState(ES_CONTINUOUS);
#endif
}

QString DMainWindow::RequestBootFilename()
{
// If a game is already selected, just return the filename
Expand Down Expand Up @@ -263,8 +279,7 @@ bool DMainWindow::Stop()
// TODO: Show the author/description dialog here

BootManager::Stop();

// TODO: Allow screensaver again
EnableScreensaver();
// TODO: Restore original window title

// TODO:
Expand Down
3 changes: 3 additions & 0 deletions Source/Core/DolphinQt/MainWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ private slots:
std::unique_ptr<Ui::DMainWindow> m_ui;
DGameTracker* m_game_tracker;

// Misc.
void DisableScreensaver();
void EnableScreensaver();
// Emulation
QString RequestBootFilename();
QString ShowFileDialog();
Expand Down