Skip to content

Commit

Permalink
Reintroduced the Windows-specific fix
Browse files Browse the repository at this point in the history
Note to self: never trust Windows users ever again when they report performance degradations. It’s never you. It’s always Windows.

Fixes #4
Fixes #10
Fixes #12
Fixes #14
  • Loading branch information
Kir-Antipov committed Jun 14, 2024
1 parent 3a86c11 commit b38306b
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/main/java/dev/kir/cubeswithoutborders/mixin/WindowMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
import com.mojang.blaze3d.systems.RenderSystem;
import dev.kir.cubeswithoutborders.client.BorderlessWindowState;
import dev.kir.cubeswithoutborders.util.SystemUtil;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.util.*;
Expand Down Expand Up @@ -119,10 +120,19 @@ private void updateBorderlessWindowRegion(CallbackInfo ci) {
// which resets values of `width` and `height`.
GLFW.glfwSetWindowAttrib(this.handle, GLFW.GLFW_DECORATED, GLFW.GLFW_FALSE);

// There's a bug that causes a fullscreen window to flicker when it loses focus.
// As far as I know, this is relevant for Windows and X11 desktops.
// Fuck X11 - it's a perpetually broken piece of legacy.
// However, we do need to implement a fix for Windows desktops, as they
// are not going anywhere in the foreseeable future (sadly enough).
// This "fix" involves not bringing a window into a "proper" fullscreen mode,
// but rather stretching it 1 pixel beyond the screen's supported resolution.
int heightOffset = SystemUtil.isWindows() ? 1 : 0;

this.x = 0;
this.y = 0;
this.width = videoMode.getWidth();
this.height = videoMode.getHeight();
this.height = videoMode.getHeight() + heightOffset;
GLFW.glfwSetWindowMonitor(this.handle, 0L, this.x, this.y, this.width, this.height, -1);

this.currentBorderless = true;
Expand Down
15 changes: 15 additions & 0 deletions src/main/java/dev/kir/cubeswithoutborders/util/SystemUtil.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package dev.kir.cubeswithoutborders.util;

import java.util.Locale;

public final class SystemUtil {
public static String getSystemName() {
return System.getProperty("os.name").toLowerCase(Locale.ROOT);
}

public static boolean isWindows() {
return SystemUtil.getSystemName().contains("win");
}

private SystemUtil() { }
}

0 comments on commit b38306b

Please sign in to comment.