popsUlfr / SDH-PauseGames

Decky Loader Plugin for Steam Deck to Pause and Resume games
GNU General Public License v3.0
76 stars 8 forks source link

Fix suspend useless when enabling 'Pause on force loss' #9

Closed xzzpig closed 1 year ago

xzzpig commented 1 year ago

I'm trying to fix #8 . It seems because suspend will change force to another app then back to current app, which match the conditions of here https://github.com/popsUlfr/SDH-PauseGames/blob/c549c66b2eb33003c2ddbd87cc683404b822f74f/src/backend.ts#L395 So I added a judgment that if the app is paused because system suspending, the app will not resume when it gets the focus.

popsUlfr commented 1 year ago

Thanks for the pull request. I'm not sure about adding a per app metadata field for this. The system suspend more like a global effect on all apps.

Maybe the same can be achieved with just a global variable that short circuits the focus change event handler ? Like the variable appIsStartingUp does ? (maybe even reusing it for both by changing its name and making it global) When the system suspend handler is triggered it sets the variable and the focus change handler becomes a no-op. On system resume the variable is unset and the focus change handler can resume.

xzzpig commented 1 year ago

Thank you very much for reviewing my code and providing valuable feedback. I will make the necessary adjustments and resubmit the PR as soon as possible to meet your requirements. Regarding the use of global variables, I believe it's a good idea to add another one. Although its purpose is similar to appIsStartingUp, reusing that variable could complicate things and make it harder to maintain and expand over time. Therefore, adding a new global variable would be a better choice, and it would also help with future maintenance.

popsUlfr commented 1 year ago

No, thank you very very much for taking the time to contribute code :) I completely agree with your reasoning. I'll test the changes and push a new version as soon as possible.