mirror of
https://github.com/xpipe-io/xpipe.git
synced 2024-11-22 07:30:24 +00:00
Native lib fixes
This commit is contained in:
parent
6d1d8770a2
commit
940480918e
3 changed files with 21 additions and 15 deletions
|
@ -67,9 +67,9 @@ public class ModifiedStage extends Stage {
|
|||
case OsType.MacOs macOs -> {
|
||||
var ctrl = new NativeMacOsWindowControl(stage);
|
||||
var seamlessFrame = !AppPrefs.get().performanceMode().get() && mergeFrame();
|
||||
ctrl.setAppearance(seamlessFrame, AppPrefs.get().theme.getValue().isDark());
|
||||
stage.getScene().getRoot().pseudoClassStateChanged(PseudoClass.getPseudoClass("seamless-frame"), seamlessFrame);
|
||||
stage.getScene().getRoot().pseudoClassStateChanged(PseudoClass.getPseudoClass("separate-frame"), !seamlessFrame);
|
||||
var seamlessFrameApplied = ctrl.setAppearance(seamlessFrame, AppPrefs.get().theme.getValue().isDark()) && seamlessFrame;
|
||||
stage.getScene().getRoot().pseudoClassStateChanged(PseudoClass.getPseudoClass("seamless-frame"), seamlessFrameApplied);
|
||||
stage.getScene().getRoot().pseudoClassStateChanged(PseudoClass.getPseudoClass("separate-frame"), !seamlessFrameApplied);
|
||||
}
|
||||
case OsType.Windows windows -> {
|
||||
var ctrl = new NativeWinWindowControl(stage);
|
||||
|
|
|
@ -28,11 +28,17 @@ public class NativeMacOsWindowControl {
|
|||
this.nsWindow = (long) nativeHandle;
|
||||
}
|
||||
|
||||
public void setAppearance(boolean seamlessFrame, boolean darkMode) {
|
||||
public boolean setAppearance(boolean seamlessFrame, boolean darkMode) {
|
||||
if (!ModuleHelper.isImage()) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
NativeBridge.getMacOsLibrary().setAppearance(new NativeLong(nsWindow), seamlessFrame, darkMode);
|
||||
var lib = NativeBridge.getMacOsLibrary();
|
||||
if (lib.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
lib.get().setAppearance(new NativeLong(nsWindow), seamlessFrame, darkMode);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,29 +4,29 @@ import com.sun.jna.Library;
|
|||
import com.sun.jna.Native;
|
||||
import com.sun.jna.NativeLong;
|
||||
import io.xpipe.app.issue.ErrorEvent;
|
||||
import io.xpipe.core.util.XPipeInstallation;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
public class NativeBridge {
|
||||
|
||||
private static MacOsLibrary macOsLibrary;
|
||||
private static boolean loadingFailed;
|
||||
|
||||
public static MacOsLibrary getMacOsLibrary() {
|
||||
if (macOsLibrary == null) {
|
||||
public static Optional<MacOsLibrary> getMacOsLibrary() {
|
||||
if (macOsLibrary == null && !loadingFailed) {
|
||||
try {
|
||||
System.setProperty("jna.library.path", XPipeInstallation.getCurrentInstallationBasePath()
|
||||
.resolve("Contents").resolve("runtime").resolve("Home").resolve("lib").toString());
|
||||
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) {
|
||||
|
||||
}
|
||||
};
|
||||
loadingFailed = true;
|
||||
}
|
||||
}
|
||||
return macOsLibrary;
|
||||
return Optional.ofNullable(macOsLibrary);
|
||||
}
|
||||
|
||||
public static interface MacOsLibrary extends Library {
|
||||
|
|
Loading…
Reference in a new issue