Skip to content
This repository was archived by the owner on Mar 22, 2026. It is now read-only.

Commit 43c6b28

Browse files
committed
[build] 升级到 26.1-pre-2
1 parent 9b9aaca commit 43c6b28

28 files changed

Lines changed: 375 additions & 351 deletions

MODULE.bazel.lock

Lines changed: 20 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

blazesdl/BUILD.bazel

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ upload_modrinth(
6767
name = "upload_modrinth",
6868
file = ":blazesdl",
6969
file_name = "blazesdl-%s.jar" % blazesdl_version,
70-
game_versions = ["26.1-snapshot-11"],
70+
game_versions = ["26.1-pre-2"],
7171
loaders = ["fabric"],
7272
project_id = "QDgSARKw",
7373
token_secret_id = "modrinth_token",
@@ -89,7 +89,7 @@ java_binary(
8989
jvm_flags = [
9090
"-Dkotlinx.coroutines.debug=on",
9191
"-Dfabric.development=true",
92-
"-Ddev.launch.version=26.1-snapshot-11",
92+
"-Ddev.launch.version=26.1-pre-2",
9393
"-Ddev.launch.type=client",
9494
"-Ddev.launch.assetsVersion=$(rlocationpath //game/26.1:game_client_assets_version)",
9595
"-Ddev.launch.mainClass=net.fabricmc.loader.impl.launch.knot.KnotClient",

blazesdl/SDLTextInputManager.java

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package top.fifthlight.blazesdl;
2+
3+
import com.mojang.blaze3d.platform.TextInputManager;
4+
import org.lwjgl.sdl.SDLKeyboard;
5+
6+
public class SDLTextInputManager extends TextInputManager {
7+
private final SDLWindow window;
8+
9+
public SDLTextInputManager(SDLWindow window) {
10+
super(window);
11+
this.window = window;
12+
}
13+
14+
@Override
15+
public void setTextInputArea(int x0, int y0, int x1, int y1) {
16+
SDLUtil.updateTextInputAreaScaled(window, x0, y0, x1 - x0, y1 - y0, 0);
17+
}
18+
19+
@Override
20+
protected void setIMEInputMode(boolean value) {
21+
if (value) {
22+
SDLKeyboard.SDL_StartTextInput(window.handle());
23+
} else {
24+
SDLKeyboard.SDL_StopTextInput(window.handle());
25+
}
26+
}
27+
28+
@Override
29+
protected boolean getIMEStatus() {
30+
// SDL doesn't care whether IME is enabled
31+
return true;
32+
}
33+
}

blazesdl/SDLWindow.java

Lines changed: 32 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
import java.util.Locale;
1717

1818
public class SDLWindow extends Window {
19+
public static boolean useExclusiveFullscreen = false;
20+
1921
public SDLWindow(WindowEventHandler eventHandler,
2022
DisplayData displayData,
2123
@Nullable String fullscreenVideoModeString,
@@ -90,23 +92,14 @@ public void setTitle(@NonNull String title) {
9092
SDLVideo.SDL_SetWindowTitle(handle, title);
9193
}
9294

93-
@Override
94-
protected void setMode() {
95-
var wasFullscreen = (SDLVideo.SDL_GetWindowFlags(this.handle) & SDLVideo.SDL_WINDOW_FULLSCREEN) != 0;
96-
97-
if (this.fullscreen) {
95+
private boolean setupFullscreenVideoMode() {
96+
if (useExclusiveFullscreen || SDLUtil.IS_WAYLAND) { // Wayland doesn't have real exclusive fullscreen
9897
var monitor = this.screenManager.findBestMonitor(this);
9998
if (monitor == null) {
10099
LOGGER.warn("Failed to find suitable monitor for fullscreen mode");
101-
this.fullscreen = false;
100+
return false;
102101
} else {
103102
var videomode = monitor.getPreferredVidMode(this.preferredFullscreenVideoMode);
104-
if (!wasFullscreen) {
105-
this.windowedX = this.x;
106-
this.windowedY = this.y;
107-
this.windowedWidth = this.width;
108-
this.windowedHeight = this.height;
109-
}
110103

111104
this.x = 0;
112105
this.y = 0;
@@ -119,9 +112,33 @@ protected void setMode() {
119112
if (!JNI.invokePPZ(this.handle, displayMode.address(), SDL_SetWindowFullscreenMode)) {
120113
throw SDLError.handleError("SDL_SetWindowFullscreenMode");
121114
}
122-
if (!SDLVideo.SDL_SetWindowFullscreen(this.handle, true)) {
123-
throw SDLError.handleError("SDL_SetWindowFullscreen");
124-
}
115+
116+
return true;
117+
}
118+
} else {
119+
LOGGER.warn("BlazeSDL: Can't set resolution without exclusive fullscreen");
120+
return true;
121+
}
122+
}
123+
124+
@Override
125+
protected void setMode() {
126+
var wasFullscreen = (SDLVideo.SDL_GetWindowFlags(this.handle) & SDLVideo.SDL_WINDOW_FULLSCREEN) != 0;
127+
128+
if (this.fullscreen) {
129+
if (!setupFullscreenVideoMode()) {
130+
return;
131+
}
132+
133+
if (!wasFullscreen) {
134+
this.windowedX = this.x;
135+
this.windowedY = this.y;
136+
this.windowedWidth = this.width;
137+
this.windowedHeight = this.height;
138+
}
139+
140+
if (!SDLVideo.SDL_SetWindowFullscreen(this.handle, true)) {
141+
throw SDLError.handleError("SDL_SetWindowFullscreen");
125142
}
126143
} else {
127144
this.x = this.windowedX;
@@ -143,25 +160,6 @@ protected void setMode() {
143160
}
144161
}
145162

146-
private boolean imeEnabled = false;
147-
148-
@Override
149-
public void toggleIME(boolean enabled) {
150-
if (enabled == imeEnabled) {
151-
return;
152-
}
153-
imeEnabled = enabled;
154-
refreshIME();
155-
}
156-
157-
public void refreshIME() {
158-
if (imeEnabled) {
159-
SDLKeyboard.SDL_StartTextInput(handle);
160-
} else {
161-
SDLKeyboard.SDL_StopTextInput(handle);
162-
}
163-
}
164-
165163
@Override
166164
protected void setBootErrorCallback() {
167165
// no-op
@@ -172,11 +170,6 @@ public void setDefaultErrorCallback() {
172170
// no-op
173171
}
174172

175-
@Override
176-
public void setIMEPreeditArea(int x0, int y0, int x1, int y1) {
177-
SDLUtil.updateTextInputAreaScaled(this, x0, y0, x1 - x0, y1 - y0, 0);
178-
}
179-
180173
public boolean shouldClose = false;
181174

182175
@Override

blazesdl/mixin/EditBoxMixin.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import com.llamalad7.mixinextras.sugar.Local;
44
import net.minecraft.client.Minecraft;
5-
import net.minecraft.client.gui.GuiGraphics;
5+
import net.minecraft.client.gui.GuiGraphicsExtractor;
66
import net.minecraft.client.gui.components.EditBox;
77
import org.spongepowered.asm.mixin.Mixin;
88
import org.spongepowered.asm.mixin.injection.At;
@@ -12,8 +12,9 @@
1212

1313
@Mixin(EditBox.class)
1414
public class EditBoxMixin {
15-
@Inject(method = "renderWidget", at = @At(value = "TAIL"))
16-
private void updateTextPos(GuiGraphics graphics, int mouseX, int mouseY, float a, CallbackInfo ci, @Local(name = "cursorX") int cursorX) {
15+
@Inject(method = "extractWidgetRenderState", at = @At(value = "TAIL"))
16+
private void updateTextPos(GuiGraphicsExtractor graphics, int mouseX, int mouseY, float a, CallbackInfo ci,
17+
@Local(name = "cursorX") int cursorX) {
1718
var editBox = (EditBox) (Object) this;
1819
if (!editBox.isVisible()) {
1920
return;
@@ -23,7 +24,8 @@ private void updateTextPos(GuiGraphics graphics, int mouseX, int mouseY, float a
2324
}
2425
if (editBox.preeditOverlay == null) {
2526
var window = Minecraft.getInstance().getWindow();
26-
SDLUtil.updateTextInputAreaScaled(window, editBox.getX(), editBox.getY(), editBox.getWidth(), editBox.getHeight(), cursorX - editBox.getX());
27+
SDLUtil.updateTextInputAreaScaled(window, editBox.getX(), editBox.getY(), editBox.getWidth(),
28+
editBox.getHeight(), cursorX - editBox.getX());
2729
}
2830
}
2931
}

blazesdl/mixin/MinecraftMixin.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import com.mojang.blaze3d.opengl.GlBackend;
44
import com.mojang.blaze3d.platform.DisplayData;
5+
import com.mojang.blaze3d.platform.TextInputManager;
56
import com.mojang.blaze3d.platform.Window;
67
import com.mojang.blaze3d.platform.WindowEventHandler;
78
import com.mojang.blaze3d.shaders.GpuDebugOptions;
@@ -20,6 +21,7 @@
2021
import org.spongepowered.asm.mixin.injection.Redirect;
2122
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
2223
import top.fifthlight.blazesdl.SDLGlBackend;
24+
import top.fifthlight.blazesdl.SDLTextInputManager;
2325
import top.fifthlight.blazesdl.SDLWindow;
2426

2527
@Mixin(Minecraft.class)
@@ -34,14 +36,16 @@ private static void useExplicitInit(GameConfig gameConfig, CallbackInfo ci) {
3436
}
3537

3638
@Redirect(method = "<init>", at = @At(value = "NEW", target = "Lcom/mojang/blaze3d/platform/Window;"))
37-
private Window createWindow(WindowEventHandler eventHandler,
38-
DisplayData displayData,
39-
String fullscreenVideoModeString,
40-
String title,
41-
GpuBackend backend) throws BackendCreationException {
39+
private Window createWindow(WindowEventHandler eventHandler, DisplayData displayData,
40+
String fullscreenVideoModeString, String title, GpuBackend backend) throws BackendCreationException {
4241
return new SDLWindow(eventHandler, displayData, fullscreenVideoModeString, title, backend);
4342
}
4443

44+
@Redirect(method = "<init>", at = @At(value = "NEW", target = "Lcom/mojang/blaze3d/platform/TextInputManager;"))
45+
private TextInputManager createTextInputManager(Window window) {
46+
return new SDLTextInputManager((SDLWindow) window);
47+
}
48+
4549
@Redirect(method = "<init>", at = @At(value = "NEW", target = "Lcom/mojang/blaze3d/opengl/GlBackend;"))
4650
private GlBackend replaceGlBackend() {
4751
LOGGER.info("BlazeSDL: Replacing GlBackend to SDLGlBackend!");

blazesdl/mixin/MultiLineEditBoxMixin.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import com.llamalad7.mixinextras.sugar.Local;
44
import net.minecraft.client.Minecraft;
5-
import net.minecraft.client.gui.GuiGraphics;
5+
import net.minecraft.client.gui.GuiGraphicsExtractor;
66
import net.minecraft.client.gui.components.IMEPreeditOverlay;
77
import net.minecraft.client.gui.components.MultiLineEditBox;
88
import org.spongepowered.asm.mixin.Mixin;
@@ -17,8 +17,8 @@ public abstract class MultiLineEditBoxMixin {
1717
@Shadow
1818
private IMEPreeditOverlay preeditOverlay;
1919

20-
@Inject(method = "renderContents", at = @At(value = "TAIL"))
21-
private void updateTextPos(GuiGraphics graphics, int mouseX, int mouseY, float a, CallbackInfo ci, @Local(name = "cursorX") int cursorX, @Local(name = "hasDrawnCursor") boolean hasDrawnCursor) {
20+
@Inject(method = "extractContents", at = @At(value = "TAIL"))
21+
private void updateTextPos(GuiGraphicsExtractor graphics, int mouseX, int mouseY, float a, CallbackInfo ci, @Local(name = "cursorX") int cursorX, @Local(name = "hasDrawnCursor") boolean hasDrawnCursor) {
2222
var editBox = (MultiLineEditBox) (Object) this;
2323
if (!editBox.visible) {
2424
return;

0 commit comments

Comments
 (0)