fix: re-added customization mode

This commit is contained in:
deechael 2024-10-07 15:33:02 +08:00
parent 87f924ce8e
commit 950880fdbc
4 changed files with 53 additions and 19 deletions

View File

@ -76,14 +76,14 @@ public class GLFWMixin {
} else { } else {
ConcentrationConstants.LOGGER.info("Trying to switch to borderless fullscreen mode"); 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"); ConcentrationConstants.LOGGER.info("Customization enabled, so replace the fullscreen size with customized size");
finalMonitor = 0L;
finalX = config.x + (config.related ? monitorInstance.getX() : 0); finalX = config.x + (config.related ? monitorInstance.getX() : 0);
finalY = config.y - (config.height == height ? 1 : 0) + (config.related ? monitorInstance.getY() : 0); finalY = config.y - (config.height == height ? 1 : 0) + (config.related ? monitorInstance.getY() : 0);
finalWidth = config.width; finalWidth = config.width;
finalHeight = config.height + (config.height == height ? 1 : 0); finalHeight = config.height + (config.height == height ? 1 : 0);
} else */ } else {
{
finalMonitor = monitor; finalMonitor = monitor;
finalX = monitorInstance.getX(); finalX = monitorInstance.getX();
finalY = monitorInstance.getY(); 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] ================="); ConcentrationConstants.LOGGER.info("================= [Concentration End] =================");

View File

@ -48,6 +48,8 @@ public abstract class WindowMixin {
@Final @Final
private long window; private long window;
@Shadow public abstract boolean isFullscreen();
@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) {
if (!this.fullscreen) { if (!this.fullscreen) {
@ -114,16 +116,15 @@ public abstract class WindowMixin {
} else { } else {
ConcentrationConstants.LOGGER.info("Trying to switch to borderless fullscreen mode"); ConcentrationConstants.LOGGER.info("Trying to switch to borderless fullscreen mode");
/*if (ConcentrationConfigFabric.getInstance().customized) { if (ConcentrationConfigFabric.getInstance().customized) {
GLFW.glfwSetWindowAttrib(window, GLFW.GLFW_DECORATED, GLFW.GLFW_FALSE);
finalMonitor = 0L;
ConcentrationConstants.LOGGER.info("Customization enabled, so replace the fullscreen size with customized size"); ConcentrationConstants.LOGGER.info("Customization enabled, so replace the fullscreen size with customized size");
finalMonitor = 0L;
finalX = config.x + (config.related ? monitorInstance.getX() : 0); finalX = config.x + (config.related ? monitorInstance.getX() : 0);
finalY = config.y - (config.height == height ? 1 : 0) + (config.related ? monitorInstance.getY() : 0); finalY = config.y - (config.height == height ? 1 : 0) + (config.related ? monitorInstance.getY() : 0);
finalWidth = config.width; finalWidth = config.width;
finalHeight = config.height + (config.height == height ? 1 : 0); finalHeight = config.height + (config.height == height ? 1 : 0);
} else */ } else {
{
finalMonitor = monitor; finalMonitor = monitor;
finalX = monitorInstance.getX(); finalX = monitorInstance.getX();
finalY = monitorInstance.getY(); finalY = monitorInstance.getY();
@ -166,6 +167,7 @@ public abstract class WindowMixin {
GLFW.glfwSetWindowMonitor(window, finalMonitor, finalX, finalY, finalWidth, finalHeight, -1); GLFW.glfwSetWindowMonitor(window, finalMonitor, finalX, finalY, finalWidth, finalHeight, -1);
if (this.fullscreen && !(Config.isBorderless() && Config.isCustomized())) { if (this.fullscreen && !(Config.isBorderless() && Config.isCustomized())) {
GLFW.glfwSetWindowAttrib(window, GLFW.GLFW_DECORATED, GLFW.GLFW_TRUE);
GLFW.glfwSetWindowAttrib(this.window, 0x20006, 1); GLFW.glfwSetWindowAttrib(this.window, 0x20006, 1);
long hWnd = GLFWNativeWin32.glfwGetWin32Window(this.window); 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] ================="); ConcentrationConstants.LOGGER.info("================= [Concentration End] =================");

View File

@ -47,6 +47,10 @@ public abstract class WindowMixin {
@Shadow @Shadow
@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;
@ -131,7 +135,7 @@ public abstract class WindowMixin {
} else { } else {
ConcentrationConstants.LOGGER.info("Trying to switch to borderless fullscreen mode"); 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 boolean related = ConcentrationConfigForge.RELATED.get();
final int configX = ConcentrationConfigForge.X.get(); final int configX = ConcentrationConfigForge.X.get();
final int configY = ConcentrationConfigForge.Y.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"); ConcentrationConstants.LOGGER.info("Customization enabled, so replace the fullscreen size with customized size");
finalMonitor = 0L;
finalX = configX + (related ? monitorInstance.getX() : 0); finalX = configX + (related ? monitorInstance.getX() : 0);
finalY = configY - (configHeight == height ? 1 : 0) + (related ? monitorInstance.getY() : 0); finalY = configY - (configHeight == height ? 1 : 0) + (related ? monitorInstance.getY() : 0);
finalWidth = configWidth; finalWidth = configWidth;
finalHeight = configHeight + (configHeight == height ? 1 : 0); finalHeight = configHeight + (configHeight == height ? 1 : 0);
} else */ } else {
{
finalMonitor = monitor; finalMonitor = monitor;
finalX = monitorInstance.getX(); finalX = monitorInstance.getX();
finalY = monitorInstance.getY(); 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] ================="); ConcentrationConstants.LOGGER.info("================= [Concentration End] =================");

View File

@ -47,6 +47,10 @@ public abstract class WindowMixin {
@Shadow @Shadow
@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;
@ -131,21 +135,21 @@ public abstract class WindowMixin {
} else { } else {
ConcentrationConstants.LOGGER.info("Trying to switch to borderless fullscreen mode"); ConcentrationConstants.LOGGER.info("Trying to switch to borderless fullscreen mode");
/*if (ConcentrationConfigForge.CUSTOMIZED.get()) { if (ConcentrationConfigNeoForge.CUSTOMIZED.get()) {
final boolean related = ConcentrationConfigForge.RELATED.get(); final boolean related = ConcentrationConfigNeoForge.RELATED.get();
final int configX = ConcentrationConfigForge.X.get(); final int configX = ConcentrationConfigNeoForge.X.get();
final int configY = ConcentrationConfigForge.Y.get(); final int configY = ConcentrationConfigNeoForge.Y.get();
final int configWidth = ConcentrationConfigForge.WIDTH.get(); final int configWidth = ConcentrationConfigNeoForge.WIDTH.get();
final int configHeight = ConcentrationConfigForge.HEIGHT.get(); final int configHeight = ConcentrationConfigNeoForge.HEIGHT.get();
ConcentrationConstants.LOGGER.info("Customization enabled, so replace the fullscreen size with customized size"); ConcentrationConstants.LOGGER.info("Customization enabled, so replace the fullscreen size with customized size");
finalMonitor = 0L;
finalX = configX + (related ? monitorInstance.getX() : 0); finalX = configX + (related ? monitorInstance.getX() : 0);
finalY = configY - (configHeight == height ? 1 : 0) + (related ? monitorInstance.getY() : 0); finalY = configY - (configHeight == height ? 1 : 0) + (related ? monitorInstance.getY() : 0);
finalWidth = configWidth; finalWidth = configWidth;
finalHeight = configHeight + (configHeight == height ? 1 : 0); finalHeight = configHeight + (configHeight == height ? 1 : 0);
} else */ } else {
{
finalMonitor = monitor; finalMonitor = monitor;
finalX = monitorInstance.getX(); finalX = monitorInstance.getX();
finalY = monitorInstance.getY(); 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] ================="); ConcentrationConstants.LOGGER.info("================= [Concentration End] =================");