mirror of
https://github.com/AngelAuraMC/Amethyst-Android.git
synced 2025-09-14 15:17:02 -04:00
Update GLFW window state (hover, visibility)
This fixes DynamicFPS mod being broken
This commit is contained in:
parent
b0af8e43f4
commit
a0262bd08b
@ -1 +1 @@
|
||||
20220228
|
||||
20220304
|
||||
|
@ -152,6 +152,7 @@ public class BaseMainActivity extends BaseActivity {
|
||||
final int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
|
||||
final View decorView = getWindow().getDecorView();
|
||||
decorView.setSystemUiVisibility(uiOptions);
|
||||
CallbackBridge.nativeSetWindowAttrib(LWJGLGLFWKeycode.GLFW_HOVERED, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -159,10 +160,23 @@ public class BaseMainActivity extends BaseActivity {
|
||||
if (CallbackBridge.isGrabbing()){
|
||||
sendKeyPress(LWJGLGLFWKeycode.GLFW_KEY_ESCAPE);
|
||||
}
|
||||
CallbackBridge.nativeSetWindowAttrib(LWJGLGLFWKeycode.GLFW_HOVERED, 0);
|
||||
mIsResuming = false;
|
||||
super.onPause();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStart() {
|
||||
super.onStart();
|
||||
CallbackBridge.nativeSetWindowAttrib(LWJGLGLFWKeycode.GLFW_VISIBLE, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStop() {
|
||||
CallbackBridge.nativeSetWindowAttrib(LWJGLGLFWKeycode.GLFW_VISIBLE, 0);
|
||||
super.onStop();
|
||||
}
|
||||
|
||||
public static void fullyExit() {
|
||||
android.os.Process.killProcess(android.os.Process.myPid());
|
||||
}
|
||||
|
@ -195,5 +195,8 @@ public class LWJGLGLFWKeycode
|
||||
GLFW_MOUSE_BUTTON_LEFT = GLFW_MOUSE_BUTTON_1,
|
||||
GLFW_MOUSE_BUTTON_RIGHT = GLFW_MOUSE_BUTTON_2,
|
||||
GLFW_MOUSE_BUTTON_MIDDLE = GLFW_MOUSE_BUTTON_3;
|
||||
|
||||
|
||||
public static final int
|
||||
GLFW_VISIBLE = 0x20004,
|
||||
GLFW_HOVERED = 0x2000B;
|
||||
}
|
||||
|
@ -211,7 +211,8 @@ public class CallbackBridge {
|
||||
private static native void nativeSendMouseButton(int button, int action, int mods);
|
||||
private static native void nativeSendScroll(double xoffset, double yoffset);
|
||||
private static native void nativeSendScreenSize(int width, int height);
|
||||
|
||||
public static native void nativeSetWindowAttrib(int attrib, int value);
|
||||
|
||||
public static native boolean nativeIsGrabbing();
|
||||
static {
|
||||
System.loadLibrary("pojavexec");
|
||||
|
@ -363,3 +363,21 @@ JNIEXPORT void JNICALL Java_org_lwjgl_glfw_CallbackBridge_nativeSendScroll(JNIEn
|
||||
JNIEXPORT void JNICALL Java_org_lwjgl_glfw_GLFW_nglfwSetShowingWindow(JNIEnv* env, jclass clazz, jlong window) {
|
||||
showingWindow = (long) window;
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_lwjgl_glfw_CallbackBridge_nativeSetWindowAttrib(JNIEnv* env, jclass clazz, jint attrib, jint value) {
|
||||
if (!showingWindow) {
|
||||
return; // nothing to do yet
|
||||
}
|
||||
|
||||
jclass glfwClazz = (*runtimeJNIEnvPtr_JRE)->FindClass(runtimeJNIEnvPtr_JRE, "org/lwjgl/glfw/GLFW");
|
||||
assert(glfwClazz != NULL);
|
||||
jmethodID glfwMethod = (*runtimeJNIEnvPtr_JRE)->GetStaticMethodID(runtimeJNIEnvPtr_JRE, glfwMethod, "glfwSetWindowAttrib", "(JII)V");
|
||||
assert(glfwMethod != NULL);
|
||||
|
||||
(*runtimeJNIEnvPtr_JRE)->CallStaticVoidMethod(
|
||||
runtimeJNIEnvPtr_JRE,
|
||||
glfwClazz, glfwMethod,
|
||||
(jlong) showingWindow, attrib, value
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -995,9 +995,11 @@ public class GLFW
|
||||
|
||||
win.width = mGLFWWindowWidth;
|
||||
win.height = mGLFWWindowHeight;
|
||||
|
||||
win.title = title;
|
||||
|
||||
win.windowAttribs.put(GLFW_HOVERED, 1);
|
||||
win.windowAttribs.put(GLFW_VISIBLE, 1);
|
||||
|
||||
mGLFWWindowMap.put(ptr, win);
|
||||
mainContext = ptr;
|
||||
return ptr;
|
||||
|
Loading…
x
Reference in New Issue
Block a user