diff --git a/platforms/common/src/main/java/dynamic_fps/impl/DynamicFPSMod.java b/platforms/common/src/main/java/dynamic_fps/impl/DynamicFPSMod.java index 78d40a90..74eed317 100644 --- a/platforms/common/src/main/java/dynamic_fps/impl/DynamicFPSMod.java +++ b/platforms/common/src/main/java/dynamic_fps/impl/DynamicFPSMod.java @@ -140,6 +140,7 @@ public static void setWindow(long address) { window = new WindowObserver(address); initClickHandler(); + checkForStateChanges(); } static boolean renderedCurrentFrame = true; diff --git a/platforms/common/src/main/java/dynamic_fps/impl/feature/state/WindowObserver.java b/platforms/common/src/main/java/dynamic_fps/impl/feature/state/WindowObserver.java index 7f272c90..b6aa73b2 100644 --- a/platforms/common/src/main/java/dynamic_fps/impl/feature/state/WindowObserver.java +++ b/platforms/common/src/main/java/dynamic_fps/impl/feature/state/WindowObserver.java @@ -12,22 +12,26 @@ public class WindowObserver { private final long address; - private boolean isFocused = true; + private boolean isFocused; private final GLFWWindowFocusCallback previousFocusCallback; - private boolean isHovered = true; + private boolean isHovered; private final GLFWCursorEnterCallback previousMouseCallback; - private boolean isIconified = false; + private boolean isIconified; private final GLFWWindowIconifyCallback previousIconifyCallback; public WindowObserver(long address) { this.address = address; + this.isFocused = GLFW.glfwGetWindowAttrib(this.address, GLFW.GLFW_FOCUSED) != 0; this.previousFocusCallback = GLFW.glfwSetWindowFocusCallback(this.address, this::onFocusChanged); + + this.isHovered = GLFW.glfwGetWindowAttrib(this.address, GLFW.GLFW_HOVERED) != 0; this.previousMouseCallback = GLFW.glfwSetCursorEnterCallback(this.address, this::onMouseChanged); // Vanilla doesn't use this (currently), other mods might register this callback though ... + this.isIconified = GLFW.glfwGetWindowAttrib(this.address, GLFW.GLFW_ICONIFIED) != 0; this.previousIconifyCallback = GLFW.glfwSetWindowIconifyCallback(this.address, this::onIconifyChanged); }