fix: windowed mode size not saved in borderless fullscreen mode
This commit is contained in:
parent
7daed8f7d1
commit
27b5414d48
@ -1,10 +0,0 @@
|
|||||||
package net.deechael.concentration.mixin;
|
|
||||||
|
|
||||||
import net.minecraft.client.main.Main;
|
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
|
||||||
|
|
||||||
@Mixin(Main.class)
|
|
||||||
public class MainMixin {
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
@ -89,7 +89,11 @@ public abstract class VideoSettingsScreenMixin extends OptionsSubScreen {
|
|||||||
@Unique
|
@Unique
|
||||||
private static OptionInstance<Boolean> concentration$wrapperFullscreen(Options options) {
|
private static OptionInstance<Boolean> concentration$wrapperFullscreen(Options options) {
|
||||||
// Don't put a constant to the second parameter, or else whatever fullscreen you are, when you open video settings page, the value shown is always the same
|
// Don't put a constant to the second parameter, or else whatever fullscreen you are, when you open video settings page, the value shown is always the same
|
||||||
return OptionInstance.createBoolean("options.fullscreen", options.fullscreen().get(), (value) -> Concentration.toggleFullScreenMode(options, value));
|
return OptionInstance.createBoolean(
|
||||||
|
"options.fullscreen",
|
||||||
|
options.fullscreen().get(),
|
||||||
|
(value) -> Concentration.toggleFullScreenMode(options, value)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Shadow
|
@Shadow
|
||||||
|
@ -7,7 +7,6 @@
|
|||||||
"mixins": [],
|
"mixins": [],
|
||||||
"client": [
|
"client": [
|
||||||
"KeyboardHandlerMixin",
|
"KeyboardHandlerMixin",
|
||||||
"MainMixin",
|
|
||||||
"VideoSettingsScreenMixin",
|
"VideoSettingsScreenMixin",
|
||||||
"accessor.WindowAccessor"
|
"accessor.WindowAccessor"
|
||||||
],
|
],
|
||||||
|
@ -19,8 +19,8 @@ dependencies {
|
|||||||
modImplementation "net.fabricmc.fabric-api:fabric-api:${fabric_version}"
|
modImplementation "net.fabricmc.fabric-api:fabric-api:${fabric_version}"
|
||||||
|
|
||||||
modImplementation "maven.modrinth:modmenu:11.0.0"
|
modImplementation "maven.modrinth:modmenu:11.0.0"
|
||||||
modImplementation "maven.modrinth:sodium:mc1.21-0.5.11"
|
|
||||||
modImplementation "maven.modrinth:sodium:mc1.21-0.6.0-beta.2-fabric"
|
modImplementation "maven.modrinth:sodium:mc1.21-0.6.0-beta.2-fabric"
|
||||||
|
modImplementation "maven.modrinth:sodium-extra:mc1.21.1-0.6.0-beta.3+fabric"
|
||||||
modImplementation "maven.modrinth:vulkanmod:0.4.9-fabric,1.21"
|
modImplementation "maven.modrinth:vulkanmod:0.4.9-fabric,1.21"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ public class ConcentrationFabricCaching {
|
|||||||
|
|
||||||
public static boolean cachedSize = false;
|
public static boolean cachedSize = false;
|
||||||
public static boolean cachedPos = false;
|
public static boolean cachedPos = false;
|
||||||
public static boolean cacheSizeLock = false;
|
public static boolean cacheSizeLock = true;
|
||||||
|
|
||||||
public static int cachedX = 0;
|
public static int cachedX = 0;
|
||||||
public static int cachedY = 0;
|
public static int cachedY = 0;
|
||||||
|
@ -0,0 +1,21 @@
|
|||||||
|
package net.deechael.concentration.fabric.compat;
|
||||||
|
|
||||||
|
import me.flashyreese.mods.sodiumextra.client.SodiumExtraClientMod;
|
||||||
|
import net.fabricmc.loader.api.FabricLoader;
|
||||||
|
|
||||||
|
public class SodiumExtraCompat {
|
||||||
|
|
||||||
|
public static boolean checkMacReduceResolution() {
|
||||||
|
if (!FabricLoader.getInstance().isModLoaded("sodium-extra"))
|
||||||
|
return false;
|
||||||
|
String os = System.getProperty("os.name").toLowerCase();
|
||||||
|
if (!(os.contains("mac") || os.contains("darwin")))
|
||||||
|
return false;
|
||||||
|
return checkMacReduceResolution0();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean checkMacReduceResolution0() {
|
||||||
|
return SodiumExtraClientMod.options().extraSettings.reduceResolutionOnMac;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -28,12 +28,13 @@ public class GLFWMixin {
|
|||||||
|
|
||||||
@Inject(method = "glfwSetWindowMonitor", at = @At("HEAD"), cancellable = true)
|
@Inject(method = "glfwSetWindowMonitor", at = @At("HEAD"), cancellable = true)
|
||||||
private static void inject$glfwSetWindowMonitor(long window, long monitor, int xpos, int ypos, int width, int height, int refreshRate, CallbackInfo ci) {
|
private static void inject$glfwSetWindowMonitor(long window, long monitor, int xpos, int ypos, int width, int height, int refreshRate, CallbackInfo ci) {
|
||||||
ConcentrationConstants.LOGGER.info("================= [Concentration Start] =================");
|
|
||||||
ConcentrationConstants.LOGGER.info("Trying to modify window monitor");
|
|
||||||
|
|
||||||
Window windowInstance = Minecraft.getInstance().getWindow();
|
Window windowInstance = Minecraft.getInstance().getWindow();
|
||||||
if (windowInstance == null)
|
if (windowInstance == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
ConcentrationConstants.LOGGER.info("================= [Concentration Start] =================");
|
||||||
|
ConcentrationConstants.LOGGER.info("Trying to modify window monitor");
|
||||||
|
|
||||||
WindowAccessor accessor = (WindowAccessor) (Object) windowInstance;
|
WindowAccessor accessor = (WindowAccessor) (Object) windowInstance;
|
||||||
|
|
||||||
if (windowInstance.isFullscreen())
|
if (windowInstance.isFullscreen())
|
||||||
@ -94,7 +95,7 @@ public class GLFWMixin {
|
|||||||
finalHeight = config.height + (config.height == height ? 1 : 0);
|
finalHeight = config.height + (config.height == height ? 1 : 0);
|
||||||
} else {
|
} else {
|
||||||
finalX = monitorInstance.getX();
|
finalX = monitorInstance.getX();
|
||||||
finalY = monitorInstance.getY() - 1;
|
finalY = monitorInstance.getY();
|
||||||
finalWidth = width;
|
finalWidth = width;
|
||||||
finalHeight = height + 1;
|
finalHeight = height + 1;
|
||||||
}
|
}
|
||||||
@ -132,6 +133,10 @@ public class GLFWMixin {
|
|||||||
ConcentrationConstants.LOGGER.info("Unlocked size caching");
|
ConcentrationConstants.LOGGER.info("Unlocked size caching");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (monitor != 0L) {
|
||||||
|
ConcentrationFabricCaching.lastMonitor = monitor;
|
||||||
|
}
|
||||||
|
|
||||||
ConcentrationConstants.LOGGER.info("Window size: {}, {}, position: {}, {}", finalWidth, finalHeight, finalX, finalY);
|
ConcentrationConstants.LOGGER.info("Window size: {}, {}, position: {}, {}", finalWidth, finalHeight, finalX, finalY);
|
||||||
|
|
||||||
ConcentrationConstants.LOGGER.info("Trying to resize and reposition the window");
|
ConcentrationConstants.LOGGER.info("Trying to resize and reposition the window");
|
||||||
|
@ -1,13 +1,12 @@
|
|||||||
package net.deechael.concentration.fabric.mixin;
|
package net.deechael.concentration.fabric.mixin;
|
||||||
|
|
||||||
import com.mojang.blaze3d.platform.Monitor;
|
import com.mojang.blaze3d.platform.*;
|
||||||
import com.mojang.blaze3d.platform.ScreenManager;
|
|
||||||
import com.mojang.blaze3d.platform.VideoMode;
|
|
||||||
import com.mojang.blaze3d.platform.Window;
|
|
||||||
import net.deechael.concentration.ConcentrationConstants;
|
import net.deechael.concentration.ConcentrationConstants;
|
||||||
import net.deechael.concentration.FullscreenMode;
|
import net.deechael.concentration.FullscreenMode;
|
||||||
import net.deechael.concentration.config.Config;
|
import net.deechael.concentration.config.Config;
|
||||||
|
import net.deechael.concentration.config.ConfigProvider;
|
||||||
import net.deechael.concentration.fabric.ConcentrationFabricCaching;
|
import net.deechael.concentration.fabric.ConcentrationFabricCaching;
|
||||||
|
import net.deechael.concentration.fabric.compat.SodiumExtraCompat;
|
||||||
import net.deechael.concentration.fabric.config.ConcentrationConfigFabric;
|
import net.deechael.concentration.fabric.config.ConcentrationConfigFabric;
|
||||||
import org.lwjgl.glfw.GLFW;
|
import org.lwjgl.glfw.GLFW;
|
||||||
import org.lwjgl.glfw.GLFWNativeWin32;
|
import org.lwjgl.glfw.GLFWNativeWin32;
|
||||||
@ -48,12 +47,20 @@ public abstract class WindowMixin {
|
|||||||
@Final
|
@Final
|
||||||
private long window;
|
private long window;
|
||||||
|
|
||||||
@Shadow
|
@Inject(method = "<init>", at = @At("RETURN"))
|
||||||
public abstract boolean isFullscreen();
|
private void inject$init(WindowEventHandler eventHandler, ScreenManager screenManager, DisplayData displayData, String preferredFullscreenVideoMode, String title, CallbackInfo ci) {
|
||||||
|
ConcentrationConstants.LOGGER.info(" =============================================");
|
||||||
@Shadow public abstract int getScreenWidth();
|
String osName = System.getProperty("os.name").toLowerCase();
|
||||||
|
if (osName.contains("windows")) {
|
||||||
@Shadow public abstract int getScreenHeight();
|
ConcentrationConstants.LOGGER.info(" == System: Windows ==");
|
||||||
|
} else if (osName.contains("darwin") || osName.contains("mac")) {
|
||||||
|
ConcentrationConstants.LOGGER.info(" == System: macOS ==");
|
||||||
|
} else {
|
||||||
|
ConcentrationConstants.LOGGER.info(" == System: Linux ==");
|
||||||
|
}
|
||||||
|
// ConcentrationConstants.LOGGER.info(" == ==");
|
||||||
|
ConcentrationConstants.LOGGER.info(" =============================================");
|
||||||
|
}
|
||||||
|
|
||||||
@Inject(method = "onMove", at = @At("HEAD"))
|
@Inject(method = "onMove", at = @At("HEAD"))
|
||||||
private void inject$onMove$head(long window, int x, int y, CallbackInfo ci) {
|
private void inject$onMove$head(long window, int x, int y, CallbackInfo ci) {
|
||||||
@ -86,6 +93,7 @@ public abstract class WindowMixin {
|
|||||||
|
|
||||||
Monitor monitorInstance = this.screenManager.getMonitor(monitor);
|
Monitor monitorInstance = this.screenManager.getMonitor(monitor);
|
||||||
ConcentrationConstants.LOGGER.info("Current fullscreen monitor is {}", monitor);
|
ConcentrationConstants.LOGGER.info("Current fullscreen monitor is {}", monitor);
|
||||||
|
ConcentrationConstants.LOGGER.info("Current fullscreen mode is {}", ConfigProvider.INSTANCE.ensureLoaded().getFullscreenMode());
|
||||||
|
|
||||||
if (monitor != 0L) {
|
if (monitor != 0L) {
|
||||||
VideoMode currentMode = monitorInstance.getCurrentMode();
|
VideoMode currentMode = monitorInstance.getCurrentMode();
|
||||||
@ -137,17 +145,20 @@ public abstract class WindowMixin {
|
|||||||
finalHeight = config.height + (config.height == height ? 1 : 0);
|
finalHeight = config.height + (config.height == height ? 1 : 0);
|
||||||
} else {
|
} else {
|
||||||
finalX = monitorInstance.getX();
|
finalX = monitorInstance.getX();
|
||||||
finalY = monitorInstance.getY() - 1;
|
finalY = monitorInstance.getY();
|
||||||
finalWidth = ignored$width;
|
finalWidth = ignored$width;
|
||||||
finalHeight = ignored$height + 1;
|
finalHeight = ignored$height + 1;
|
||||||
}
|
}
|
||||||
|
if (SodiumExtraCompat.checkMacReduceResolution()) {
|
||||||
|
ConcentrationConstants.LOGGER.info("On macOS and reduce resolution in Sodium Extra enabled, reduce the resolution");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.x = finalX;
|
this.x = finalX;
|
||||||
this.y = finalY;
|
this.y = finalY;
|
||||||
this.width = finalWidth;
|
this.width = finalWidth;
|
||||||
this.height = finalHeight;
|
this.height = finalHeight;
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
ConcentrationConstants.LOGGER.info("Trying to switch to windowed mode");
|
ConcentrationConstants.LOGGER.info("Trying to switch to windowed mode");
|
||||||
finalMonitor = 0L;
|
finalMonitor = 0L;
|
||||||
@ -173,6 +184,10 @@ public abstract class WindowMixin {
|
|||||||
ConcentrationConstants.LOGGER.info("Unlocked size caching");
|
ConcentrationConstants.LOGGER.info("Unlocked size caching");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (monitor != 0L) {
|
||||||
|
ConcentrationFabricCaching.lastMonitor = monitor;
|
||||||
|
}
|
||||||
|
|
||||||
ConcentrationConstants.LOGGER.info("Window size: {}, {}, position: {}, {}", finalWidth, finalHeight, finalX, finalY);
|
ConcentrationConstants.LOGGER.info("Window size: {}, {}, position: {}, {}", finalWidth, finalHeight, finalX, finalY);
|
||||||
|
|
||||||
ConcentrationConstants.LOGGER.info("Trying to resize and reposition the window");
|
ConcentrationConstants.LOGGER.info("Trying to resize and reposition the window");
|
||||||
@ -202,7 +217,7 @@ public abstract class WindowMixin {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
GLFW.glfwSetWindowAttrib(window, GLFW.GLFW_DECORATED, GLFW.GLFW_FALSE);
|
GLFW.glfwSetWindowAttrib(window, GLFW.GLFW_DECORATED, GLFW.GLFW_FALSE);
|
||||||
GLFW.glfwSetWindowAttrib(this.window, 0x20006, 0);
|
GLFW.glfwSetWindowAttrib(this.window, 0x20006, 1);
|
||||||
if (System.getProperty("os.name").contains("Windows")) {
|
if (System.getProperty("os.name").contains("Windows")) {
|
||||||
long hWnd = GLFWNativeWin32.glfwGetWin32Window(this.window);
|
long hWnd = GLFWNativeWin32.glfwGetWin32Window(this.window);
|
||||||
if (hWnd != 0) {
|
if (hWnd != 0) {
|
||||||
|
@ -48,9 +48,6 @@ public abstract class WindowMixin {
|
|||||||
@Final
|
@Final
|
||||||
private long window;
|
private long window;
|
||||||
|
|
||||||
@Shadow
|
|
||||||
public abstract boolean isFullscreen();
|
|
||||||
|
|
||||||
@Unique
|
@Unique
|
||||||
private long concentration$lastMonitor = -1;
|
private long concentration$lastMonitor = -1;
|
||||||
|
|
||||||
@ -59,7 +56,7 @@ public abstract class WindowMixin {
|
|||||||
@Unique
|
@Unique
|
||||||
private boolean concentration$cachedPos = false;
|
private boolean concentration$cachedPos = false;
|
||||||
@Unique
|
@Unique
|
||||||
private boolean concentration$cacheSizeLock = false;
|
private boolean concentration$cacheSizeLock = true;
|
||||||
|
|
||||||
@Unique
|
@Unique
|
||||||
private int concentration$cachedX = 0;
|
private int concentration$cachedX = 0;
|
||||||
@ -157,7 +154,7 @@ public abstract class WindowMixin {
|
|||||||
finalHeight = configHeight + (configHeight == height ? 1 : 0);
|
finalHeight = configHeight + (configHeight == height ? 1 : 0);
|
||||||
} else {
|
} else {
|
||||||
finalX = monitorInstance.getX();
|
finalX = monitorInstance.getX();
|
||||||
finalY = monitorInstance.getY() - 1;
|
finalY = monitorInstance.getY();
|
||||||
finalWidth = width;
|
finalWidth = width;
|
||||||
finalHeight = height + 1;
|
finalHeight = height + 1;
|
||||||
}
|
}
|
||||||
@ -193,6 +190,10 @@ public abstract class WindowMixin {
|
|||||||
ConcentrationConstants.LOGGER.info("Unlocked size caching");
|
ConcentrationConstants.LOGGER.info("Unlocked size caching");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (monitor != 0L) {
|
||||||
|
this.concentration$lastMonitor = monitor;
|
||||||
|
}
|
||||||
|
|
||||||
ConcentrationConstants.LOGGER.info("Window size: {}, {}, position: {}, {}", finalWidth, finalHeight, finalX, finalY);
|
ConcentrationConstants.LOGGER.info("Window size: {}, {}, position: {}, {}", finalWidth, finalHeight, finalX, finalY);
|
||||||
|
|
||||||
ConcentrationConstants.LOGGER.info("Trying to resize and reposition the window");
|
ConcentrationConstants.LOGGER.info("Trying to resize and reposition the window");
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
version=2.2.2
|
version=2.2.3
|
||||||
group=net.deechael.concentration
|
group=net.deechael.concentration
|
||||||
java_version=21
|
java_version=21
|
||||||
|
|
||||||
|
@ -48,9 +48,6 @@ public abstract class WindowMixin {
|
|||||||
@Final
|
@Final
|
||||||
private long window;
|
private long window;
|
||||||
|
|
||||||
@Shadow
|
|
||||||
public abstract boolean isFullscreen();
|
|
||||||
|
|
||||||
@Unique
|
@Unique
|
||||||
private long concentration$lastMonitor = -1;
|
private long concentration$lastMonitor = -1;
|
||||||
|
|
||||||
@ -59,7 +56,7 @@ public abstract class WindowMixin {
|
|||||||
@Unique
|
@Unique
|
||||||
private boolean concentration$cachedPos = false;
|
private boolean concentration$cachedPos = false;
|
||||||
@Unique
|
@Unique
|
||||||
private boolean concentration$cacheSizeLock = false;
|
private boolean concentration$cacheSizeLock = true;
|
||||||
|
|
||||||
@Unique
|
@Unique
|
||||||
private int concentration$cachedX = 0;
|
private int concentration$cachedX = 0;
|
||||||
@ -157,12 +154,16 @@ public abstract class WindowMixin {
|
|||||||
finalHeight = configHeight + (configHeight == height ? 1 : 0);
|
finalHeight = configHeight + (configHeight == height ? 1 : 0);
|
||||||
} else {
|
} else {
|
||||||
finalX = monitorInstance.getX();
|
finalX = monitorInstance.getX();
|
||||||
finalY = monitorInstance.getY() - 1;
|
finalY = monitorInstance.getY();
|
||||||
finalWidth = width;
|
finalWidth = width;
|
||||||
finalHeight = height + 1;
|
finalHeight = height + 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (monitor != 0L) {
|
||||||
|
this.concentration$lastMonitor = monitor;
|
||||||
|
}
|
||||||
|
|
||||||
this.x = finalX;
|
this.x = finalX;
|
||||||
this.y = finalY;
|
this.y = finalY;
|
||||||
this.width = finalWidth;
|
this.width = finalWidth;
|
||||||
|
Loading…
Reference in New Issue
Block a user