From 01758809b817f8e3fdf5aa4ee2a53d8657a29951 Mon Sep 17 00:00:00 2001 From: deechael Date: Fri, 11 Oct 2024 22:56:18 +0800 Subject: [PATCH] refactor: rename borderless mode to exclusive mode, re-added old borderless mode --- .../concentration/FullscreenMode.java | 5 +- .../deechael/concentration/config/Config.java | 4 + .../concentration/mixin/MainMixin.java | 1 - .../mixin/VideoSettingsScreenMixin.java | 1 - .../assets/concentration/lang/en_us.json | 1 + .../assets/concentration/lang/zh_cn.json | 1 + .../config/ConcentrationConfigFabric.java | 2 +- .../concentration/fabric/mixin/GLFWMixin.java | 79 ++++++++++--------- .../fabric/mixin/WindowMixin.java | 69 ++++++++-------- .../config/ConcentrationConfigForge.java | 2 +- .../forge/mixin/WindowMixin.java | 77 ++++++++++-------- gradle.properties | 2 +- .../config/ConcentrationConfigNeoForge.java | 2 +- .../neoforge/mixin/WindowMixin.java | 77 ++++++++++-------- 14 files changed, 178 insertions(+), 145 deletions(-) diff --git a/common/src/main/java/net/deechael/concentration/FullscreenMode.java b/common/src/main/java/net/deechael/concentration/FullscreenMode.java index 03dba70..d0646a9 100644 --- a/common/src/main/java/net/deechael/concentration/FullscreenMode.java +++ b/common/src/main/java/net/deechael/concentration/FullscreenMode.java @@ -10,8 +10,9 @@ import java.util.function.IntFunction; public enum FullscreenMode implements OptionEnum, StringRepresentable { - BORDERLESS(0, "borderless", "concentration.option.fullscreen_mode.borderless"), - NATIVE(1, "native", "concentration.option.fullscreen_mode.native"); + EXCLUSIVE(0, "exclusive", "concentration.option.fullscreen_mode.exclusive"), + NATIVE(1, "native", "concentration.option.fullscreen_mode.native"), + BORDERLESS(2, "borderless", "concentration.option.fullscreen_mode.borderless"); public static final Codec CODEC = StringRepresentable.fromEnum(FullscreenMode::values); public static final IntFunction BY_ID = ByIdMap.continuous(FullscreenMode::getId, values(), ByIdMap.OutOfBoundsStrategy.ZERO); diff --git a/common/src/main/java/net/deechael/concentration/config/Config.java b/common/src/main/java/net/deechael/concentration/config/Config.java index f08c345..8740664 100644 --- a/common/src/main/java/net/deechael/concentration/config/Config.java +++ b/common/src/main/java/net/deechael/concentration/config/Config.java @@ -12,6 +12,10 @@ public interface Config { void save(); + static boolean isExclusive() { + return ConfigProvider.INSTANCE.ensureLoaded().getFullscreenMode() == FullscreenMode.EXCLUSIVE; + } + static boolean isBorderless() { return ConfigProvider.INSTANCE.ensureLoaded().getFullscreenMode() == FullscreenMode.BORDERLESS; } diff --git a/common/src/main/java/net/deechael/concentration/mixin/MainMixin.java b/common/src/main/java/net/deechael/concentration/mixin/MainMixin.java index 4235ad5..fe3d1bf 100644 --- a/common/src/main/java/net/deechael/concentration/mixin/MainMixin.java +++ b/common/src/main/java/net/deechael/concentration/mixin/MainMixin.java @@ -7,5 +7,4 @@ import org.spongepowered.asm.mixin.Mixin; public class MainMixin { - } diff --git a/common/src/main/java/net/deechael/concentration/mixin/VideoSettingsScreenMixin.java b/common/src/main/java/net/deechael/concentration/mixin/VideoSettingsScreenMixin.java index f15e6cd..e0b035f 100644 --- a/common/src/main/java/net/deechael/concentration/mixin/VideoSettingsScreenMixin.java +++ b/common/src/main/java/net/deechael/concentration/mixin/VideoSettingsScreenMixin.java @@ -9,7 +9,6 @@ import net.minecraft.client.gui.screens.Screen; import net.minecraft.client.gui.screens.options.OptionsSubScreen; import net.minecraft.client.gui.screens.options.VideoSettingsScreen; import net.minecraft.network.chat.Component; -import net.minecraft.world.entity.HumanoidArm; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.Unique; diff --git a/common/src/main/resources/assets/concentration/lang/en_us.json b/common/src/main/resources/assets/concentration/lang/en_us.json index 0a8e188..0817883 100644 --- a/common/src/main/resources/assets/concentration/lang/en_us.json +++ b/common/src/main/resources/assets/concentration/lang/en_us.json @@ -9,5 +9,6 @@ "concentration.option.fullscreen_mode": "Fullscreen Mode", "concentration.option.fullscreen_mode.tooltip": "Fullscreen mode determines the fullscreen function using borderless fullscreen or native fullscreen.", "concentration.option.fullscreen_mode.borderless": "Borderless", + "concentration.option.fullscreen_mode.exclusive": "Exclusive", "concentration.option.fullscreen_mode.native": "Native" } \ No newline at end of file diff --git a/common/src/main/resources/assets/concentration/lang/zh_cn.json b/common/src/main/resources/assets/concentration/lang/zh_cn.json index a344086..0710208 100644 --- a/common/src/main/resources/assets/concentration/lang/zh_cn.json +++ b/common/src/main/resources/assets/concentration/lang/zh_cn.json @@ -9,5 +9,6 @@ "concentration.option.fullscreen_mode": "全屏模式", "concentration.option.fullscreen_mode.tooltip": "决定开启全屏后应使用无边框窗口全屏还是原生全屏。", "concentration.option.fullscreen_mode.borderless": "无边框", + "concentration.option.fullscreen_mode.exclusive": "独占", "concentration.option.fullscreen_mode.native": "原生" } \ No newline at end of file diff --git a/fabric/src/main/java/net/deechael/concentration/fabric/config/ConcentrationConfigFabric.java b/fabric/src/main/java/net/deechael/concentration/fabric/config/ConcentrationConfigFabric.java index a62b976..09a6f52 100644 --- a/fabric/src/main/java/net/deechael/concentration/fabric/config/ConcentrationConfigFabric.java +++ b/fabric/src/main/java/net/deechael/concentration/fabric/config/ConcentrationConfigFabric.java @@ -41,7 +41,7 @@ public class ConcentrationConfigFabric implements Config { public int y = 0; public int width = 800; public int height = 600; - public FullscreenMode fullscreen = FullscreenMode.BORDERLESS; + public FullscreenMode fullscreen = FullscreenMode.NATIVE; @Override public boolean customized() { 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 0b4c346..f203b19 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,19 +76,26 @@ public class GLFWMixin { } else { ConcentrationConstants.LOGGER.info("Trying to switch to borderless fullscreen mode"); - 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 { + if (Config.isExclusive()) { finalMonitor = monitor; finalX = monitorInstance.getX(); finalY = monitorInstance.getY(); finalWidth = currentMode.getWidth(); finalHeight = currentMode.getHeight(); + } else { + finalMonitor = 0L; + if (ConcentrationConfigFabric.getInstance().customized) { + ConcentrationConstants.LOGGER.info("Customization enabled, so replace the fullscreen size with customized size"); + 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 { + finalX = monitorInstance.getX(); + finalY = monitorInstance.getY() - 1; + finalWidth = width; + finalHeight = height + 1; + } } accessor.setX(finalX); @@ -128,49 +135,49 @@ public class GLFWMixin { ConcentrationConstants.LOGGER.info("Trying to resize and reposition the window"); finalExecute(window, finalMonitor, finalX, finalY, finalWidth, finalHeight, -1); - if (windowInstance.isFullscreen() && !(Config.isBorderless() && Config.isCustomized())) { + if (windowInstance.isFullscreen()) { GLFW.glfwSetWindowAttrib(windowInstance.getWindow(), 0x20006, 1); - - long hWnd = GLFWNativeWin32.glfwGetWin32Window(windowInstance.getWindow()); - if (hWnd != 0) { - User32.SetWindowPos( - hWnd, - User32.HWND_TOPMOST, - windowInstance.getX(), - windowInstance.getY(), - windowInstance.getScreenWidth(), - windowInstance.getScreenHeight(), - 1027 - ); - User32.SetWindowLongPtr(hWnd, -16, 0x960A0000L); - User32.SetWindowLongPtr(hWnd, -20, 0x40010L); - } - - if (Config.isBorderless()) { - GLFW.glfwSetWindowAttrib(windowInstance.getWindow(), 0x20006, 0); - + if (!Config.isBorderless()) { if (System.getProperty("os.name").contains("Windows")) { + long hWnd = GLFWNativeWin32.glfwGetWin32Window(windowInstance.getWindow()); if (hWnd != 0) { User32.SetWindowPos( hWnd, - User32.HWND_NOTOPMOST, + User32.HWND_TOPMOST, windowInstance.getX(), windowInstance.getY(), windowInstance.getScreenWidth(), windowInstance.getScreenHeight(), 1027 ); - User32.SetWindowLongPtr(hWnd, -16, 369229824); - User32.SetWindowLongPtr(hWnd, -20, 34340880); + User32.SetWindowLongPtr(hWnd, -16, 0x960A0000L); + User32.SetWindowLongPtr(hWnd, -20, 0x40010L); } } + if (Config.isExclusive()) { + 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_FALSE); } } 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); - } + 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 1bb4000..b519c1b 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,7 +48,8 @@ public abstract class WindowMixin { @Final private long window; - @Shadow public abstract boolean isFullscreen(); + @Shadow + public abstract boolean isFullscreen(); @Inject(method = "onMove", at = @At("HEAD")) private void inject$onMove$head(long window, int x, int y, CallbackInfo ci) { @@ -116,21 +117,28 @@ public abstract class WindowMixin { } else { ConcentrationConstants.LOGGER.info("Trying to switch to borderless fullscreen mode"); - 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 { + if (Config.isExclusive()) { finalMonitor = monitor; finalX = monitorInstance.getX(); finalY = monitorInstance.getY(); finalWidth = currentMode.getWidth(); finalHeight = currentMode.getHeight(); + } else { + finalMonitor = 0L; + if (ConcentrationConfigFabric.getInstance().customized) { + ConcentrationConstants.LOGGER.info("Customization enabled, so replace the fullscreen size with customized size"); + 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 { + finalX = monitorInstance.getX(); + finalY = monitorInstance.getY() - 1; + finalWidth = width; + finalHeight = height + 1; + } } + this.x = finalX; this.y = finalY; this.width = finalWidth; @@ -166,34 +174,33 @@ public abstract class WindowMixin { ConcentrationConstants.LOGGER.info("Trying to resize and reposition the window"); 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); + if (this.fullscreen) { GLFW.glfwSetWindowAttrib(this.window, 0x20006, 1); - - long hWnd = GLFWNativeWin32.glfwGetWin32Window(this.window); - if (hWnd != 0) { - User32.SetWindowPos(hWnd, User32.HWND_TOPMOST, this.x, this.y, this.width, this.height, 1027); - User32.SetWindowLongPtr(hWnd, -16, 0x960A0000L); - User32.SetWindowLongPtr(hWnd, -20, 0x40010L); - } - - if (Config.isBorderless()) { - GLFW.glfwSetWindowAttrib(this.window, 0x20006, 0); - + if (!Config.isBorderless()) { 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); + User32.SetWindowPos(hWnd, User32.HWND_TOPMOST, this.x, this.y, this.width, this.height, 1027); + User32.SetWindowLongPtr(hWnd, -16, 0x960A0000L); + User32.SetWindowLongPtr(hWnd, -20, 0x40010L); } } + if (Config.isExclusive()) { + 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_FALSE); } } 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); - } + 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/config/ConcentrationConfigForge.java b/forge/src/main/java/net/deechael/concentration/forge/config/ConcentrationConfigForge.java index a4fc8ce..19fd2cb 100644 --- a/forge/src/main/java/net/deechael/concentration/forge/config/ConcentrationConfigForge.java +++ b/forge/src/main/java/net/deechael/concentration/forge/config/ConcentrationConfigForge.java @@ -44,7 +44,7 @@ public final class ConcentrationConfigForge implements Config { HEIGHT = builder.comment("Height") .defineInRange("height", 600, 1, Integer.MAX_VALUE); FULLSCREEN = builder.comment("Fullscreen mode") - .defineEnum("fullscreen", FullscreenMode.BORDERLESS); + .defineEnum("fullscreen", FullscreenMode.NATIVE); builder.pop(); 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 4e5a04f..d71a795 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 @@ -135,27 +135,34 @@ 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(); - - 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 { + if (Config.isExclusive()) { finalMonitor = monitor; finalX = monitorInstance.getX(); finalY = monitorInstance.getY(); finalWidth = currentMode.getWidth(); finalHeight = currentMode.getHeight(); + } else { + finalMonitor = 0L; + 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(); + ConcentrationConstants.LOGGER.info("Customization enabled, so replace the fullscreen size with customized size"); + + 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 { + finalX = monitorInstance.getX(); + finalY = monitorInstance.getY() - 1; + finalWidth = width; + finalHeight = height + 1; + } } + this.x = finalX; this.y = finalY; this.width = finalWidth; @@ -191,33 +198,33 @@ public abstract class WindowMixin { ConcentrationConstants.LOGGER.info("Trying to resize and reposition the window"); GLFW.glfwSetWindowMonitor(window, finalMonitor, finalX, finalY, finalWidth, finalHeight, -1); - if (this.fullscreen && !(Config.isBorderless() && Config.isCustomized())) { + if (this.fullscreen) { GLFW.glfwSetWindowAttrib(this.window, 0x20006, 1); - - long hWnd = GLFWNativeWin32.glfwGetWin32Window(this.window); - if (hWnd != 0) { - User32.SetWindowPos(hWnd, User32.HWND_TOPMOST, this.x, this.y, this.width, this.height, 1027); - User32.SetWindowLongPtr(hWnd, -16, 0x960A0000L); - User32.SetWindowLongPtr(hWnd, -20, 0x40010L); - } - - if (Config.isBorderless()) { - GLFW.glfwSetWindowAttrib(this.window, 0x20006, 0); - + if (!Config.isBorderless()) { 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); + User32.SetWindowPos(hWnd, User32.HWND_TOPMOST, this.x, this.y, this.width, this.height, 1027); + User32.SetWindowLongPtr(hWnd, -16, 0x960A0000L); + User32.SetWindowLongPtr(hWnd, -20, 0x40010L); } } + if (Config.isExclusive()) { + 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_FALSE); } } 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); - } + GLFW.glfwSetWindowAttrib(window, GLFW.GLFW_DECORATED, GLFW.GLFW_TRUE); } ConcentrationConstants.LOGGER.info("================= [Concentration End] ================="); diff --git a/gradle.properties b/gradle.properties index 2f59036..79bb185 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ -version=2.1.1 +version=2.2.0 group=net.deechael.concentration java_version=21 diff --git a/neoforge/src/main/java/net/deechael/concentration/neoforge/config/ConcentrationConfigNeoForge.java b/neoforge/src/main/java/net/deechael/concentration/neoforge/config/ConcentrationConfigNeoForge.java index 1b64baf..2236cad 100644 --- a/neoforge/src/main/java/net/deechael/concentration/neoforge/config/ConcentrationConfigNeoForge.java +++ b/neoforge/src/main/java/net/deechael/concentration/neoforge/config/ConcentrationConfigNeoForge.java @@ -38,7 +38,7 @@ public final class ConcentrationConfigNeoForge implements Config { HEIGHT = builder.comment("Height") .defineInRange("height", 600, 1, Integer.MAX_VALUE); FULLSCREEN = builder.comment("Fullscreen mode") - .defineEnum("fullscreen", FullscreenMode.BORDERLESS); + .defineEnum("fullscreen", FullscreenMode.NATIVE); builder.pop(); 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 3c1b08f..90976e1 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 @@ -135,27 +135,34 @@ public abstract class WindowMixin { } else { ConcentrationConstants.LOGGER.info("Trying to switch to borderless fullscreen mode"); - 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 { + if (Config.isExclusive()) { finalMonitor = monitor; finalX = monitorInstance.getX(); finalY = monitorInstance.getY(); finalWidth = currentMode.getWidth(); finalHeight = currentMode.getHeight(); + } else { + finalMonitor = 0L; + 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"); + + 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 { + finalX = monitorInstance.getX(); + finalY = monitorInstance.getY() - 1; + finalWidth = width; + finalHeight = height + 1; + } } + this.x = finalX; this.y = finalY; this.width = finalWidth; @@ -191,33 +198,33 @@ public abstract class WindowMixin { ConcentrationConstants.LOGGER.info("Trying to resize and reposition the window"); GLFW.glfwSetWindowMonitor(window, finalMonitor, finalX, finalY, finalWidth, finalHeight, -1); - if (this.fullscreen && !(Config.isBorderless() && Config.isCustomized())) { + if (this.fullscreen) { GLFW.glfwSetWindowAttrib(this.window, 0x20006, 1); - - long hWnd = GLFWNativeWin32.glfwGetWin32Window(this.window); - if (hWnd != 0) { - User32.SetWindowPos(hWnd, User32.HWND_TOPMOST, this.x, this.y, this.width, this.height, 1027); - User32.SetWindowLongPtr(hWnd, -16, 0x960A0000L); - User32.SetWindowLongPtr(hWnd, -20, 0x40010L); - } - - if (Config.isBorderless()) { - GLFW.glfwSetWindowAttrib(this.window, 0x20006, 0); - + if (!Config.isBorderless()) { 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); + User32.SetWindowPos(hWnd, User32.HWND_TOPMOST, this.x, this.y, this.width, this.height, 1027); + User32.SetWindowLongPtr(hWnd, -16, 0x960A0000L); + User32.SetWindowLongPtr(hWnd, -20, 0x40010L); } } + if (Config.isExclusive()) { + 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_FALSE); } } 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); - } + GLFW.glfwSetWindowAttrib(window, GLFW.GLFW_DECORATED, GLFW.GLFW_TRUE); } ConcentrationConstants.LOGGER.info("================= [Concentration End] =================");