From 37f266f35f0c6e5e0d69c741398f95011124ed32 Mon Sep 17 00:00:00 2001 From: deechael Date: Sat, 12 Oct 2024 14:23:47 +0800 Subject: [PATCH] fix: crash with vulkanmod --- .../concentration/fabric/mixin/GLFWMixin.java | 19 +++++++++++++++++++ .../fabric/mixin/WindowMixin.java | 9 +++++++++ .../forge/mixin/WindowMixin.java | 9 +++++++++ .../neoforge/mixin/WindowMixin.java | 9 +++++++++ 4 files changed, 46 insertions(+) diff --git a/fabric/src/main/java/net/deechael/concentration/fabric/mixin/GLFWMixin.java b/fabric/src/main/java/net/deechael/concentration/fabric/mixin/GLFWMixin.java index f203b19..32e4cce 100644 --- a/fabric/src/main/java/net/deechael/concentration/fabric/mixin/GLFWMixin.java +++ b/fabric/src/main/java/net/deechael/concentration/fabric/mixin/GLFWMixin.java @@ -32,6 +32,8 @@ public class GLFWMixin { ConcentrationConstants.LOGGER.info("Trying to modify window monitor"); Window windowInstance = Minecraft.getInstance().getWindow(); + if (windowInstance == null) + return; WindowAccessor accessor = (WindowAccessor) (Object) windowInstance; if (windowInstance.isFullscreen()) @@ -175,6 +177,23 @@ public class GLFWMixin { } } else { GLFW.glfwSetWindowAttrib(window, GLFW.GLFW_DECORATED, GLFW.GLFW_FALSE); + GLFW.glfwSetWindowAttrib(windowInstance.getWindow(), 0x20006, 0); + if (System.getProperty("os.name").contains("Windows")) { + long hWnd = GLFWNativeWin32.glfwGetWin32Window(windowInstance.getWindow()); + if (hWnd != 0) { + User32.SetWindowPos( + hWnd, + User32.HWND_NOTOPMOST, + windowInstance.getX(), + windowInstance.getY(), + windowInstance.getScreenWidth(), + windowInstance.getScreenHeight(), + 1027 + ); + User32.SetWindowLongPtr(hWnd, -16, 369229824); + User32.SetWindowLongPtr(hWnd, -20, 34340880); + } + } } } else { GLFW.glfwSetWindowAttrib(window, GLFW.GLFW_DECORATED, GLFW.GLFW_TRUE); diff --git a/fabric/src/main/java/net/deechael/concentration/fabric/mixin/WindowMixin.java b/fabric/src/main/java/net/deechael/concentration/fabric/mixin/WindowMixin.java index a2ba428..2131804 100644 --- a/fabric/src/main/java/net/deechael/concentration/fabric/mixin/WindowMixin.java +++ b/fabric/src/main/java/net/deechael/concentration/fabric/mixin/WindowMixin.java @@ -202,6 +202,15 @@ public abstract class WindowMixin { } } else { GLFW.glfwSetWindowAttrib(window, GLFW.GLFW_DECORATED, GLFW.GLFW_FALSE); + GLFW.glfwSetWindowAttrib(this.window, 0x20006, 0); + if (System.getProperty("os.name").contains("Windows")) { + long hWnd = GLFWNativeWin32.glfwGetWin32Window(this.window); + if (hWnd != 0) { + User32.SetWindowPos(hWnd, User32.HWND_NOTOPMOST, this.x, this.y, this.width, this.height, 1027); + User32.SetWindowLongPtr(hWnd, -16, 369229824); + User32.SetWindowLongPtr(hWnd, -20, 34340880); + } + } } } else { GLFW.glfwSetWindowAttrib(window, GLFW.GLFW_DECORATED, GLFW.GLFW_TRUE); diff --git a/forge/src/main/java/net/deechael/concentration/forge/mixin/WindowMixin.java b/forge/src/main/java/net/deechael/concentration/forge/mixin/WindowMixin.java index d71a795..7f81c18 100644 --- a/forge/src/main/java/net/deechael/concentration/forge/mixin/WindowMixin.java +++ b/forge/src/main/java/net/deechael/concentration/forge/mixin/WindowMixin.java @@ -222,6 +222,15 @@ public abstract class WindowMixin { } } else { GLFW.glfwSetWindowAttrib(window, GLFW.GLFW_DECORATED, GLFW.GLFW_FALSE); + GLFW.glfwSetWindowAttrib(this.window, 0x20006, 0); + if (System.getProperty("os.name").contains("Windows")) { + long hWnd = GLFWNativeWin32.glfwGetWin32Window(this.window); + if (hWnd != 0) { + User32.SetWindowPos(hWnd, User32.HWND_NOTOPMOST, this.x, this.y, this.width, this.height, 1027); + User32.SetWindowLongPtr(hWnd, -16, 369229824); + User32.SetWindowLongPtr(hWnd, -20, 34340880); + } + } } } else { GLFW.glfwSetWindowAttrib(window, GLFW.GLFW_DECORATED, GLFW.GLFW_TRUE); diff --git a/neoforge/src/main/java/net/deechael/concentration/neoforge/mixin/WindowMixin.java b/neoforge/src/main/java/net/deechael/concentration/neoforge/mixin/WindowMixin.java index 90976e1..044754d 100644 --- a/neoforge/src/main/java/net/deechael/concentration/neoforge/mixin/WindowMixin.java +++ b/neoforge/src/main/java/net/deechael/concentration/neoforge/mixin/WindowMixin.java @@ -222,6 +222,15 @@ public abstract class WindowMixin { } } else { GLFW.glfwSetWindowAttrib(window, GLFW.GLFW_DECORATED, GLFW.GLFW_FALSE); + GLFW.glfwSetWindowAttrib(this.window, 0x20006, 0); + if (System.getProperty("os.name").contains("Windows")) { + long hWnd = GLFWNativeWin32.glfwGetWin32Window(this.window); + if (hWnd != 0) { + User32.SetWindowPos(hWnd, User32.HWND_NOTOPMOST, this.x, this.y, this.width, this.height, 1027); + User32.SetWindowLongPtr(hWnd, -16, 369229824); + User32.SetWindowLongPtr(hWnd, -20, 34340880); + } + } } } else { GLFW.glfwSetWindowAttrib(window, GLFW.GLFW_DECORATED, GLFW.GLFW_TRUE);