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 4bcc019..0b4c346 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 @@ -76,14 +76,14 @@ public class GLFWMixin { } else { ConcentrationConstants.LOGGER.info("Trying to switch to borderless fullscreen mode"); - /*if (ConcentrationConfigFabric.getInstance().customized) { + if (ConcentrationConfigFabric.getInstance().customized) { ConcentrationConstants.LOGGER.info("Customization enabled, so replace the fullscreen size with customized size"); + finalMonitor = 0L; finalX = config.x + (config.related ? monitorInstance.getX() : 0); finalY = config.y - (config.height == height ? 1 : 0) + (config.related ? monitorInstance.getY() : 0); finalWidth = config.width; finalHeight = config.height + (config.height == height ? 1 : 0); - } else */ - { + } else { finalMonitor = monitor; finalX = monitorInstance.getX(); finalY = monitorInstance.getY(); @@ -165,6 +165,12 @@ public class GLFWMixin { } } } + } else { + if (windowInstance.isFullscreen() && Config.isBorderless() && Config.isCustomized()) { + GLFW.glfwSetWindowAttrib(window, GLFW.GLFW_DECORATED, GLFW.GLFW_FALSE); + } else { + GLFW.glfwSetWindowAttrib(window, GLFW.GLFW_DECORATED, GLFW.GLFW_TRUE); + } } ConcentrationConstants.LOGGER.info("================= [Concentration End] ================="); 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 abf9541..1bb4000 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 @@ -48,6 +48,8 @@ public abstract class WindowMixin { @Final private long window; + @Shadow public abstract boolean isFullscreen(); + @Inject(method = "onMove", at = @At("HEAD")) private void inject$onMove$head(long window, int x, int y, CallbackInfo ci) { if (!this.fullscreen) { @@ -114,16 +116,15 @@ public abstract class WindowMixin { } else { ConcentrationConstants.LOGGER.info("Trying to switch to borderless fullscreen mode"); - /*if (ConcentrationConfigFabric.getInstance().customized) { - GLFW.glfwSetWindowAttrib(window, GLFW.GLFW_DECORATED, GLFW.GLFW_FALSE); - finalMonitor = 0L; + if (ConcentrationConfigFabric.getInstance().customized) { ConcentrationConstants.LOGGER.info("Customization enabled, so replace the fullscreen size with customized size"); + + finalMonitor = 0L; finalX = config.x + (config.related ? monitorInstance.getX() : 0); finalY = config.y - (config.height == height ? 1 : 0) + (config.related ? monitorInstance.getY() : 0); finalWidth = config.width; finalHeight = config.height + (config.height == height ? 1 : 0); - } else */ - { + } else { finalMonitor = monitor; finalX = monitorInstance.getX(); finalY = monitorInstance.getY(); @@ -166,6 +167,7 @@ public abstract class WindowMixin { GLFW.glfwSetWindowMonitor(window, finalMonitor, finalX, finalY, finalWidth, finalHeight, -1); if (this.fullscreen && !(Config.isBorderless() && Config.isCustomized())) { + GLFW.glfwSetWindowAttrib(window, GLFW.GLFW_DECORATED, GLFW.GLFW_TRUE); GLFW.glfwSetWindowAttrib(this.window, 0x20006, 1); long hWnd = GLFWNativeWin32.glfwGetWin32Window(this.window); @@ -186,6 +188,12 @@ public abstract class WindowMixin { } } } + } else { + if (this.isFullscreen() && Config.isBorderless() && Config.isCustomized()) { + GLFW.glfwSetWindowAttrib(window, GLFW.GLFW_DECORATED, GLFW.GLFW_FALSE); + } else { + GLFW.glfwSetWindowAttrib(window, GLFW.GLFW_DECORATED, GLFW.GLFW_TRUE); + } } ConcentrationConstants.LOGGER.info("================= [Concentration End] ================="); 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 220bbd4..4e5a04f 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 @@ -47,6 +47,10 @@ public abstract class WindowMixin { @Shadow @Final private long window; + + @Shadow + public abstract boolean isFullscreen(); + @Unique private long concentration$lastMonitor = -1; @@ -131,7 +135,7 @@ public abstract class WindowMixin { } else { ConcentrationConstants.LOGGER.info("Trying to switch to borderless fullscreen mode"); - /*if (ConcentrationConfigForge.CUSTOMIZED.get()) { + if (ConcentrationConfigForge.CUSTOMIZED.get()) { final boolean related = ConcentrationConfigForge.RELATED.get(); final int configX = ConcentrationConfigForge.X.get(); final int configY = ConcentrationConfigForge.Y.get(); @@ -140,12 +144,12 @@ public abstract class WindowMixin { ConcentrationConstants.LOGGER.info("Customization enabled, so replace the fullscreen size with customized size"); + finalMonitor = 0L; finalX = configX + (related ? monitorInstance.getX() : 0); finalY = configY - (configHeight == height ? 1 : 0) + (related ? monitorInstance.getY() : 0); finalWidth = configWidth; finalHeight = configHeight + (configHeight == height ? 1 : 0); - } else */ - { + } else { finalMonitor = monitor; finalX = monitorInstance.getX(); finalY = monitorInstance.getY(); @@ -208,6 +212,12 @@ public abstract class WindowMixin { } } } + } else { + if (this.isFullscreen() && Config.isBorderless() && Config.isCustomized()) { + GLFW.glfwSetWindowAttrib(window, GLFW.GLFW_DECORATED, GLFW.GLFW_FALSE); + } else { + GLFW.glfwSetWindowAttrib(window, GLFW.GLFW_DECORATED, GLFW.GLFW_TRUE); + } } ConcentrationConstants.LOGGER.info("================= [Concentration End] ================="); 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 d19ca40..3c1b08f 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 @@ -47,6 +47,10 @@ public abstract class WindowMixin { @Shadow @Final private long window; + + @Shadow + public abstract boolean isFullscreen(); + @Unique private long concentration$lastMonitor = -1; @@ -131,21 +135,21 @@ public abstract class WindowMixin { } else { ConcentrationConstants.LOGGER.info("Trying to switch to borderless fullscreen mode"); - /*if (ConcentrationConfigForge.CUSTOMIZED.get()) { - final boolean related = ConcentrationConfigForge.RELATED.get(); - final int configX = ConcentrationConfigForge.X.get(); - final int configY = ConcentrationConfigForge.Y.get(); - final int configWidth = ConcentrationConfigForge.WIDTH.get(); - final int configHeight = ConcentrationConfigForge.HEIGHT.get(); + if (ConcentrationConfigNeoForge.CUSTOMIZED.get()) { + final boolean related = ConcentrationConfigNeoForge.RELATED.get(); + final int configX = ConcentrationConfigNeoForge.X.get(); + final int configY = ConcentrationConfigNeoForge.Y.get(); + final int configWidth = ConcentrationConfigNeoForge.WIDTH.get(); + final int configHeight = ConcentrationConfigNeoForge.HEIGHT.get(); ConcentrationConstants.LOGGER.info("Customization enabled, so replace the fullscreen size with customized size"); + finalMonitor = 0L; finalX = configX + (related ? monitorInstance.getX() : 0); finalY = configY - (configHeight == height ? 1 : 0) + (related ? monitorInstance.getY() : 0); finalWidth = configWidth; finalHeight = configHeight + (configHeight == height ? 1 : 0); - } else */ - { + } else { finalMonitor = monitor; finalX = monitorInstance.getX(); finalY = monitorInstance.getY(); @@ -208,6 +212,12 @@ public abstract class WindowMixin { } } } + } else { + if (this.isFullscreen() && Config.isBorderless() && Config.isCustomized()) { + GLFW.glfwSetWindowAttrib(window, GLFW.GLFW_DECORATED, GLFW.GLFW_FALSE); + } else { + GLFW.glfwSetWindowAttrib(window, GLFW.GLFW_DECORATED, GLFW.GLFW_TRUE); + } } ConcentrationConstants.LOGGER.info("================= [Concentration End] =================");