Native lib loading fixes

This commit is contained in:
crschnick 2024-07-17 09:32:20 +00:00
parent 215b461a65
commit ed8ba0e27f
2 changed files with 21 additions and 3 deletions

View file

@ -33,6 +33,6 @@ public class NativeMacOsWindowControl {
return;
}
NativeBridge.MacOsLibrary.INSTANCE.setAppearance(new NativeLong(nsWindow), seamlessFrame, darkMode);
NativeBridge.getMacOsLibrary().setAppearance(new NativeLong(nsWindow), seamlessFrame, darkMode);
}
}

View file

@ -9,9 +9,27 @@ import java.util.Map;
public class NativeBridge {
public static interface MacOsLibrary extends Library {
private static MacOsLibrary macOsLibrary;
public static MacOsLibrary INSTANCE = Native.load("xpipe_bridge", MacOsLibrary.class, Map.of());
public static MacOsLibrary getMacOsLibrary() {
if (macOsLibrary == null) {
try {
var l = Native.load("xpipe_bridge", MacOsLibrary.class, Map.of());
macOsLibrary = l;
} catch (Throwable t) {
ErrorEvent.fromThrowable(t).handle();
macOsLibrary = new MacOsLibrary() {
@Override
public void setAppearance(NativeLong window, boolean seamlessFrame, boolean dark) {
}
};
}
}
return macOsLibrary;
}
public static interface MacOsLibrary extends Library {
public abstract void setAppearance(NativeLong window, boolean seamlessFrame, boolean dark);
}