Skip to content

Commit

Permalink
fix problems related to macOS
Browse files Browse the repository at this point in the history
Update CocoaInput-lib
- Korea-Minecraft-Forum/CocoaInput-lib@80cd730 fix crash possibility & sonoma preliminary support

caramelChat Changes
- fix crash possibility on macOS Sonoma
- fix rect is not rendered in the correct position
  • Loading branch information
LemonCaramel committed Nov 4, 2023
1 parent 9b20329 commit 139e2b6
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 11 deletions.
20 changes: 19 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# caramelChat

![License](https://img.shields.io/github/license/LemonCaramel/caramelChat.svg)
![GitHub Issues](https://img.shields.io/github/issues/LemonCaramel/caramelChat.svg)
![GitHub Tag](https://img.shields.io/github/tag/LemonCaramel/caramelChat.svg)

Expand Down Expand Up @@ -34,6 +33,25 @@ Below is the ModLoader compatibility.
| Fabric / Quilt | 🟢 Compatible |
| Forge / NeoForge | 🟢 Compatible |

## 🛠️ Troubleshooting (macOS 14.0+)
If you are using macOS Sonoma or later versions, you may experience the following issue:
- Some characters are skipped when typing very quickly.
- The client crashes when a system key is pressed (e.g., input source switch).

Most of the causes are due to the Input Tooltip added in Sonoma. However, Apple has not provided an API to disable it.

![macOS Sonoma Indicator](https://github.com/LemonCaramel/caramelChat/assets/45729082/e1d34917-1892-4cb6-aa3f-38fdab58fad9)


You can disable the Input Tooltip system-wide through the following guide.

Open the Terminal and enter the following command:
```Bash
sudo mkdir -p /Library/Preferences/FeatureFlags/Domain
sudo /usr/libexec/PlistBuddy -c "Add 'redesigned_text_cursor:Enabled' bool false" /Library/Preferences/FeatureFlags/Domain/UIKit.plist
```
And then, reboot your Macintosh. This will return you to the input environment from before Sonoma.

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

Expand Down
2 changes: 1 addition & 1 deletion common/src/main/java/moe/caramel/chat/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public static String copyLibrary(final String name) {
final InputStream is = url.openStream();
final FileOutputStream fos = new FileOutputStream(lib)
) {
ModLogger.debug("Extracting library to {0}", lib.getAbsolutePath());
ModLogger.debug("Extracting library to {}", lib.getAbsolutePath());
fos.write(is.readAllBytes());
lib.deleteOnExit();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package moe.caramel.chat.driver.arch.darwin;

import com.sun.jna.Memory;
import com.sun.jna.Pointer;
import com.mojang.blaze3d.platform.Window;
import moe.caramel.chat.driver.IOperator;
import moe.caramel.chat.util.ModLogger;
import moe.caramel.chat.wrapper.AbstractIMEWrapper;
Expand Down Expand Up @@ -38,18 +37,20 @@ public DarwinOperator(final DarwinController controller, final AbstractIMEWrappe
this.wrapper.appendPreviewText(str);
},
// Rect Range
() -> {
(pointer) -> {
ModLogger.debug("[Native|Java] Called to determine where to draw.");
final float[] buff = this.wrapper.getRect().copy();
final float factor = (float) Minecraft.getInstance().getWindow().getGuiScale();
final Window window = Minecraft.getInstance().getWindow();
final float factor = (float) window.getGuiScale();
buff[0] *= factor;
buff[1] *= factor;
buff[2] *= factor;
buff[3] *= factor;

final Pointer rect = new Memory(Float.BYTES * 4);
rect.write(0, buff, 0, 4);
return rect;
buff[0] += window.getX();
buff[1] += window.getY();

pointer.write(0, buff, 0, 4);
}
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ interface SetMarkedText extends Callback {
}

interface FirstRectForCharacterRange extends Callback {
Pointer invoke();
void invoke(final Pointer pointer);
}

interface LogInfoCallback extends Callback {
Expand Down
Binary file modified common/src/main/resources/native/libdarwincocoainput.dylib
100644 → 100755
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
org.gradle.jvmargs=-Xmx2G

archives_base_name=caramelChat
mod_version=1.1.0
mod_version=1.1.1-SNAPSHOT
maven_group=moe.caramel

minecraft_version=1.20.2
Expand Down

0 comments on commit 139e2b6

Please sign in to comment.