Don't prevent windows Display Sleep while paused #6704
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #6703
I have not tested that this actually sleeps correctly, or that ryujinx can be restored correctly.
I just debugged and queried that the thread execution state is set correctly via
SetThreadExecutionState(0)
.Please leave a comment if you test it and it works as intended (Can sleep and wake up fine while paused).
Ran into an issue since AppHost.cs Pause/Resume are called from the "Main Thread" (The one running Program.Main and the WndProc) and the thread that currently calls DisplayState Restore/Prevent is another one (The one running AppHost.MainLoop).
I just put all DisplayState calls within a
Dispatcher.UIThread.Post
delegate (It was not needed for the ones called from Resume/Pause in my tests but I added them just in case).I considered adding a private method on AppHost that handles that but since it's only used twice per method I wasn't sure if it was worth it.