Skip to content

Commit

Permalink
Try to use the GLFW ime status
Browse files Browse the repository at this point in the history
  • Loading branch information
kappa-maintainer committed Dec 18, 2024
1 parent 119c4e9 commit 9cc9a50
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 6 deletions.
25 changes: 25 additions & 0 deletions src/main/java/net/minecraftforge/client/ForgeClientHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,17 @@

package net.minecraftforge.client;

import net.minecraft.client.gui.GuiChat;
import net.minecraft.client.gui.GuiScreenBook;
import net.minecraft.client.gui.inventory.GuiEditSign;
import net.minecraftforge.client.event.ColorHandlerEvent;
import net.minecraftforge.client.event.GuiOpenEvent;
import net.minecraftforge.client.event.ModelRegistryEvent;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.common.ForgeModContainer;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import org.lwjglx.opengl.Display;

public class ForgeClientHandler
{
Expand All @@ -46,4 +51,24 @@ public static void registerItemHandlers(ColorHandlerEvent.Item event)
event.getItemColors().registerItemColorHandler(new FluidContainerColorer(), ForgeModContainer.getInstance().universalBucket);
}
}

@SubscribeEvent
public static void didChangeGui(GuiOpenEvent event) {
boolean canInput;
if (event.getGui() == null) {
// Ignore null GuiScreens
canInput = false;
} else if (event.getGui() instanceof GuiChat) {
// Skip, this should be handled by Focus
return;
} else {
// Vanilla GuiScreens
canInput = event.getGui() instanceof GuiScreenBook
|| event.getGui() instanceof GuiEditSign;

// TODO: Force enable map
}

Display.setIME(canInput);
}
}
11 changes: 5 additions & 6 deletions src/main/java/org/lwjglx/opengl/Display.java
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,7 @@ public static void create(PixelFormat pixel_format, ContextAttribs attribs) {

public static void create(PixelFormat pixel_format) {
System.out.println("TODO: Implement Display.create(PixelFormat)"); // TODO
try {
create();
} catch (Throwable t) {
FMLLog.log.info(t.getCause().getMessage());
Arrays.stream(t.getStackTrace()).forEach(FMLLog.log::info);
}
create();
}

public static void create() {
Expand Down Expand Up @@ -797,6 +792,10 @@ public static Drawable getDrawable() {
return drawable;
}

public static void setIME(boolean active) {
org.lwjgl.glfw.GLFW.glfwSetInputMode(Window.handle, GLFW_IME, active ? GLFW_TRUE : GLFW_FALSE);
}

static DisplayImplementation getImplementation() {
return null;
}
Expand Down

0 comments on commit 9cc9a50

Please sign in to comment.