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

[BUG] Pause on Lost Focus setting is ignored #6196

Open
ItsJustSomeDude opened this issue Oct 24, 2024 · 3 comments
Open

[BUG] Pause on Lost Focus setting is ignored #6196

ItsJustSomeDude opened this issue Oct 24, 2024 · 3 comments
Labels
bug Something isn't working help wanted Extra attention is needed well written Tag for issues which are well explained, making it easier for people to understand

Comments

@ItsJustSomeDude
Copy link

Describe the bug

The vanilla "pause on lost focus" setting is ignored when the app is backgrounded. This means things like AFK farms that require a button to be held down (such as Tree farms or AFK Fish farms, or walking while AFK) cannot be done in the background. A key can be held in the background either with a toggleable button, or with the F3+T trick. However, the actions stop as soon as the activity is in the background.

The log file and images/videos

latest.log

Steps To Reproduce

1. Launch a 1.21.1 instance
2. Enter a singleplayer world
3. Disable Pause on Lost Focus (F3+P)
4. Background the app (without pausing or opening your inventory)
5. Return to the app, see that it is now paused.
6. You can also place down, say, a Noteblock and Button, toggle Right-click, and hear that the dinging stops in the background.

Expected Behavior

The app should be able to enter the background without an Escape key event being sent to the game.

Platform

- Device model: moto G(7)
- CPU architecture: arm64
- Android version: 13
- PojavLauncher version: foxglove-20240922-a6a6a29-v3_openjdk

Anything else?

No response

@ItsJustSomeDude ItsJustSomeDude added the bug Something isn't working label Oct 24, 2024
@artdeell
Copy link
Member

not all versions of the game pause on focus loss, so it is simply easier to send the escape event so that it works uniformly across everything that pojav can run

and i dont feel like making a button to turn that off yet

@ItsJustSomeDude
Copy link
Author

Apologies for immediately adding a comment.

It seems the Escape key is being sent during onPause() lifecycle hook right here:
https://github.com/PojavLauncherTeam/PojavLauncher/blob/v3_openjdk/app_pojavlauncher%2Fsrc%2Fmain%2Fjava%2Fnet%2Fkdt%2Fpojavlaunch%2FMainActivity.java#L271

It seems to me that instead of sending ESC, the game window can simply be informed that it is in the background (like it looks like is being done onStop several lines below that), and will thus let Pause on Lost Focus pause the game, if the user hasn't disabled that.

I'll try building a version with this line removed to see if there are any unforseen consequences. (Perhaps a "cursor release" has to be sent instead?) If everything still works I'll be happy to PR this!

@artdeell
Copy link
Member

The problem is that (iirc) older versions dont care about window focus, which is why this was initially implemented as an esc keypress.

@GaucovyAero GaucovyAero added help wanted Extra attention is needed well written Tag for issues which are well explained, making it easier for people to understand labels Oct 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed well written Tag for issues which are well explained, making it easier for people to understand
Projects
None yet
Development

No branches or pull requests

3 participants