Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix X11 controller crash/not working #24

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,14 @@ Fortunately, there are third-party mods available to address this issue.

**WayGL:** [Modrinth](https://modrinth.com/mod/waygl), [Github](https://github.com/wired-tomato/WayGL)

## 🛠️ Troubleshooting (Linux Fcitx5)

Fcitx5 may not work without using the "On The Spot" style.

1. Assuming your configuration program is `fcitx5-config-qt`, Head to `Fcitx Configuration -> Addons`, find `X Input Method Frontend` and click the cog button in its row.
2. Enable the `Use On The Spot Style (Needs restarting)` option then reboot.
3. It should be working now.

## 🚀️ Contributing
All contributions are welcome regardless of Native or Java.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,38 @@ public final class X11Controller implements IController {

private final Driver_X11 driver;

@SuppressWarnings("FieldCanBeLocal")
private final Driver_X11.DrawCallback drawCallback = (caret, chg_first, chg_length, length, iswstring, rawstring, rawwstring, primary, secondary, tertiary) -> {
ModLogger.debug("[Native|Java] Draw begin");
final String string = (iswstring ? rawwstring.toString() : rawstring);

if (X11Controller.focused != null) {
GLFW.glfwSetKeyCallback(windowId, null);
X11Controller.focused.getWrapper().appendPreviewText(string);
}

ModLogger.debug(
"[Native|Java] PreEdit: {} {} {} {} {} {} {} {}",
caret, chg_first, chg_length, length,
primary, secondary, tertiary, string
);

final int[] point = { 600, 600 };
final Memory memory = new Memory(8L);
memory.write(0L, point, 0, 2);
ModLogger.debug("[Native|Java] Draw End");
return memory;
};

@SuppressWarnings("FieldCanBeLocal")
private final Driver_X11.DoneCallback doneCallback = () -> {
ModLogger.debug("[Native|Java] Preedit Done");
if (X11Controller.focused != null) {
X11Controller.focused.getWrapper().insertText("");
}
X11Controller.setupKeyboardEvent();
};

/**
* Create X11 Controller
*/
Expand All @@ -39,35 +71,9 @@ public X11Controller() {
// X11 Windows Id
GLFWNativeX11.glfwGetX11Window(windowId),
// Draw Callback
(caret, chg_first, chg_length, length, iswstring, rawstring, rawwstring, primary, secondary, tertiary) -> {
ModLogger.debug("[Native|Java] Draw begin");
final String string = (iswstring ? rawwstring.toString() : rawstring);

if (X11Controller.focused != null) {
GLFW.glfwSetKeyCallback(windowId, null);
X11Controller.focused.getWrapper().appendPreviewText(string);
}

ModLogger.debug(
"[Native|Java] PreEdit: {} {} {} {} {} {} {} {}",
caret, chg_first, chg_length, length,
primary, secondary, tertiary, string
);

final int[] point = { 600, 600 };
final Memory memory = new Memory(8L);
memory.write(0L, point, 0, 2);
ModLogger.debug("[Native|Java] Draw End");
return memory;
},
this.drawCallback,
// Done Callback
() -> {
ModLogger.debug("[Native|Java] Preedit Done");
if (X11Controller.focused != null) {
X11Controller.focused.getWrapper().insertText("");
}
X11Controller.setupKeyboardEvent();
},
this.doneCallback,
// Info
(log) -> ModLogger.log("[Native|C] " + log),
// Error
Expand Down