Skip to content
This repository was archived by the owner on Nov 28, 2025. It is now read-only.

Commit 24dcee0

Browse files
committed
(1.8.9) fix retrieving the glfw window handle
1 parent ec3969c commit 24dcee0

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

1.8.9/src/main/java/io/github/axolotlclient/config/AxolotlClientConfig.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,9 @@ public void init() {
123123
AxolotlClient.modules.add(new Module() {
124124
@Override
125125
public void lateInit() {
126+
if (System.getProperty("org.lwjgl.input.Mouse.disableRawInput") == null) {
127+
System.setProperty("org.lwjgl.input.Mouse.disableRawInput", "true");
128+
}
126129
GLFWUtil.runUsingGlfwHandle(h -> GLFW.glfwSetInputMode(h, GLFW.GLFW_RAW_MOUSE_MOTION, rawMouseInput.get() ? 1 : 0));
127130
}
128131
});

1.8.9/src/main/java/io/github/axolotlclient/util/GLFWUtil.java

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import java.lang.invoke.MethodType;
2828
import java.util.function.Consumer;
2929

30+
import net.ornithemc.osl.lifecycle.api.client.MinecraftClientEvents;
3031
import org.lwjgl.opengl.Display;
3132

3233
public class GLFWUtil {
@@ -35,16 +36,15 @@ public class GLFWUtil {
3536

3637
static {
3738
try {
38-
getHandle = MethodHandles.lookup().findVirtual(Display.class, "getHandle", MethodType.methodType(Long.class));
39+
getHandle = MethodHandles.lookup().findStatic(Class.forName("org.lwjgl.opengl.Display"), "getHandle", MethodType.methodType(long.class));
3940
} catch (Throwable ignored) {
4041
}
4142
}
4243

4344
private static long windowHandle = -1;
4445

45-
public static long getWindowHandle(){
46-
if (windowHandle == -1){
47-
46+
public static long getWindowHandle() {
47+
if (windowHandle == -1) {
4848
try {
4949
windowHandle = (long) getHandle.invoke();
5050
} catch (Throwable ignored) {
@@ -60,7 +60,13 @@ public static boolean isHandleAvailable() {
6060
}
6161

6262
public static void runUsingGlfwHandle(Consumer<Long> action) {
63-
if (isHandleAvailable()) {
63+
if (!Display.isCreated()) {
64+
MinecraftClientEvents.READY.register(mc -> {
65+
if (isHandleAvailable()) {
66+
action.accept(getWindowHandle());
67+
}
68+
});
69+
} else if (isHandleAvailable()) {
6470
action.accept(getWindowHandle());
6571
}
6672
}

0 commit comments

Comments
 (0)