This commit is contained in:
crschnick 2024-07-16 09:09:48 +00:00
parent 781e1b3c84
commit 63a579cf05
5 changed files with 21 additions and 3 deletions

View file

@ -43,6 +43,7 @@ public class AppTheme {
public static void initThemeHandlers(Stage stage) {
Runnable r = () -> {
stage.getScene().getRoot().getStyleClass().add(OsType.getLocal().getId());
if (AppPrefs.get() == null) {
var def = Theme.getDefaultLightTheme();
stage.getScene().getRoot().getStyleClass().add(def.getCssId());

View file

@ -66,8 +66,8 @@ public class ModifiedStage extends Stage {
}
case OsType.MacOs macOs -> {
var ctrl = new NativeMacOsWindowControl(stage);
ctrl.setWindowDarkMode(AppPrefs.get().theme.getValue().isDark());
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);
}

View file

@ -28,7 +28,7 @@ public class NativeMacOsWindowControl {
this.nsWindow = (long) nativeHandle;
}
public void setWindowDarkMode(boolean darkMode) {
public void setAppearance(boolean seamlessFrame, boolean darkMode) {
if (!ModuleHelper.isImage()) {
return;
}

View file

@ -9,7 +9,7 @@
-fx-background-color: transparent;
}
.root:seamless-frame {
.root.macos:seamless-frame {
-fx-padding: 0 0 27 0;
}

View file

@ -46,6 +46,8 @@ public interface OsType {
sealed interface Local extends OsType permits OsType.Windows, OsType.Linux, OsType.MacOs {
String getId();
default Any toAny() {
return (Any) this;
}
@ -131,6 +133,11 @@ public interface OsType {
return "Windows";
}
}
@Override
public String getId() {
return "windows";
}
}
class Unix implements OsType {
@ -197,6 +204,11 @@ public interface OsType {
final class Linux extends Unix implements OsType, Local, Any {
@Override
public String getId() {
return "linux";
}
@Override
public String determineOperatingSystemName(ShellControl pc) throws Exception {
try (CommandControl c = pc.command("lsb_release -a").start()) {
@ -223,6 +235,11 @@ public interface OsType {
final class MacOs implements OsType, Local, Any {
@Override
public String getId() {
return "macos";
}
@Override
public String makeFileSystemCompatible(String name) {
// Technically the backslash is supported, but it causes all kinds of troubles, so we also exclude it