mirror of
https://github.com/AngelAuraMC/Amethyst-Android.git
synced 2025-09-15 23:59:21 -04:00
Fix: Ensure the mouse grab state.
This is also accompagnied with a slight optimisation of the updateGrabbingState function, since it will be called quite a high number of times
This commit is contained in:
parent
63e822325c
commit
e566dd143e
@ -409,6 +409,10 @@ public class MinecraftGLSurface extends View implements GrabListener{
|
||||
break;
|
||||
}
|
||||
if(mouseCursorIndex == -1) return false; // we cant consoom that, theres no mice!
|
||||
|
||||
// Make sure we grabbed the mouse if necessary
|
||||
updateGrabState(CallbackBridge.isGrabbing());
|
||||
|
||||
switch(event.getActionMasked()) {
|
||||
case MotionEvent.ACTION_HOVER_MOVE:
|
||||
CallbackBridge.mouseX = (event.getX(mouseCursorIndex) * mScaleFactor);
|
||||
@ -650,16 +654,20 @@ public class MinecraftGLSurface extends View implements GrabListener{
|
||||
}
|
||||
|
||||
private void updateGrabState(boolean isGrabbing) {
|
||||
if(MainActivity.isAndroid8OrHigher()) {
|
||||
if (isGrabbing && !hasPointerCapture()) {
|
||||
if(!MainActivity.isAndroid8OrHigher()) return;
|
||||
|
||||
boolean hasPointerCapture = hasPointerCapture();
|
||||
if(isGrabbing){
|
||||
if(!hasPointerCapture) {
|
||||
requestFocus();
|
||||
requestPointerCapture();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (!isGrabbing && hasPointerCapture()) {
|
||||
releasePointerCapture();
|
||||
clearFocus();
|
||||
}
|
||||
if(hasPointerCapture) {
|
||||
releasePointerCapture();
|
||||
clearFocus();
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user