diff --git a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/MinecraftGLSurface.java b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/MinecraftGLSurface.java index 177265ca5..61b03d9da 100644 --- a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/MinecraftGLSurface.java +++ b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/MinecraftGLSurface.java @@ -624,7 +624,8 @@ public class MinecraftGLSurface extends View implements GrabListener { if(isGrabbing){ if(!hasPointerCapture) { requestFocus(); - requestPointerCapture(); + if(hasWindowFocus()) requestPointerCapture(); + // Otherwise, onWindowFocusChanged() would get called. } return; } @@ -635,6 +636,13 @@ public class MinecraftGLSurface extends View implements GrabListener { } } + @Override + public void onWindowFocusChanged(boolean hasWindowFocus) { + super.onWindowFocusChanged(hasWindowFocus); + if(hasWindowFocus && CallbackBridge.isGrabbing() && + MainActivity.isAndroid8OrHigher()) requestPointerCapture(); + } + /** A small interface called when the listener is ready for the first time */ public interface SurfaceReadyListener { void isReady();