diff --git a/core/src/main/java/com/github/weisj/darklaf/DarkLaf.java b/core/src/main/java/com/github/weisj/darklaf/DarkLaf.java index 39dc302e..c5900ddb 100644 --- a/core/src/main/java/com/github/weisj/darklaf/DarkLaf.java +++ b/core/src/main/java/com/github/weisj/darklaf/DarkLaf.java @@ -42,6 +42,7 @@ import java.util.logging.Logger; public class DarkLaf extends BasicLookAndFeel { public static final String SYSTEM_PROPERTY_PREFIX = "darklaf."; + public static final String ALLOW_NATIVE_CODE_FLAG = DarkLaf.SYSTEM_PROPERTY_PREFIX + "allowNativeCode"; private static final Logger LOGGER = Logger.getLogger(DarkLaf.class.getName()); /* * All tasks for initializing the ui defaults in order of execution. diff --git a/core/src/main/java/com/github/weisj/darklaf/platform/DecorationsHandler.java b/core/src/main/java/com/github/weisj/darklaf/platform/DecorationsHandler.java index 3b67ef4b..1f17bf0c 100644 --- a/core/src/main/java/com/github/weisj/darklaf/platform/DecorationsHandler.java +++ b/core/src/main/java/com/github/weisj/darklaf/platform/DecorationsHandler.java @@ -55,8 +55,7 @@ public class DecorationsHandler { protected DecorationsHandler() { try { //Extend for different platforms. - boolean enableDecorations = - !PropertyValue.FALSE.equals(System.getProperty(DECORATIONS_FLAG)); + boolean enableDecorations = isNativeDecorationsEnabled(); if (SystemInfo.isWindows10 && enableDecorations) { //Decorations are in the Windows10 visuals. Disable for older version. decorationsProvider = new WindowsDecorationsProvider(); @@ -91,6 +90,11 @@ public class DecorationsHandler { && LafManager.getTheme().useCustomDecorations(); } + private boolean isNativeDecorationsEnabled() { + return !PropertyValue.FALSE.equals(System.getProperty(DECORATIONS_FLAG)) + && !PropertyValue.FALSE.equals(System.getProperty(DarkLaf.ALLOW_NATIVE_CODE_FLAG)); + } + public void initialize() { decorationsProvider.initialize(); } diff --git a/core/src/main/java/com/github/weisj/darklaf/platform/ThemePreferencesHandler.java b/core/src/main/java/com/github/weisj/darklaf/platform/ThemePreferencesHandler.java index 656eb2b4..4d3f73d8 100644 --- a/core/src/main/java/com/github/weisj/darklaf/platform/ThemePreferencesHandler.java +++ b/core/src/main/java/com/github/weisj/darklaf/platform/ThemePreferencesHandler.java @@ -35,7 +35,7 @@ import com.github.weisj.darklaf.util.SystemInfo; public class ThemePreferencesHandler { - public static final String PREFERENCE_REPORTING_FLAG = DarkLaf.SYSTEM_PROPERTY_PREFIX + "themePreferenceReporting"; + public static final String PREFERENCE_REPORTING_FLAG = DarkLaf.SYSTEM_PROPERTY_PREFIX + "enableNativePreferences"; private static ThemePreferencesHandler sharedInstance; private final ThemePreferenceChangeSupport changeSupport = new ThemePreferenceChangeSupport(); @@ -54,9 +54,8 @@ public class ThemePreferencesHandler { protected ThemePreferencesHandler() { try { // Extend for different platforms. - boolean enableDecorations = - !PropertyValue.FALSE.equals(System.getProperty(PREFERENCE_REPORTING_FLAG)); - if (SystemInfo.isWindows10 && enableDecorations) { + boolean enableNativePreferences = isNativePreferencesEnabled(); + if (SystemInfo.isWindows10 && enableNativePreferences) { // Decorations are in the Windows10 visuals. Disable for older version. preferenceProvider = new WindowsThemePreferenceProvider(); } else { @@ -66,6 +65,7 @@ public class ThemePreferencesHandler { // If decorations modules are not available disable them. preferenceProvider = new DefaultThemePreferenceProvider(); } + preferenceProvider.initialize(); preferenceProvider.setCallback(this::onChange); } @@ -82,11 +82,12 @@ public class ThemePreferencesHandler { } public void enablePreferenceChangeReporting(final boolean enabled) { - boolean oldEnabled = isPreferenceChangeReportingEnabled(); preferenceProvider.setReporting(enabled); - if (isPreferenceChangeReportingEnabled() != oldEnabled && enabled) { - preferenceProvider.initialize(); - } + } + + private boolean isNativePreferencesEnabled() { + return !PropertyValue.FALSE.equals(System.getProperty(PREFERENCE_REPORTING_FLAG)) + && !PropertyValue.FALSE.equals(System.getProperty(DarkLaf.ALLOW_NATIVE_CODE_FLAG)); } public boolean isPreferenceChangeReportingEnabled() { diff --git a/windows/src/main/java/com/github/weisj/darklaf/platform/windows/WindowsLibrary.java b/windows/src/main/java/com/github/weisj/darklaf/platform/windows/WindowsLibrary.java index dfef9d5f..cc2ed17c 100644 --- a/windows/src/main/java/com/github/weisj/darklaf/platform/windows/WindowsLibrary.java +++ b/windows/src/main/java/com/github/weisj/darklaf/platform/windows/WindowsLibrary.java @@ -60,15 +60,15 @@ public class WindowsLibrary { } else { LOGGER.warning("Could not determine jre model '" + SystemInfo.jreArchitecture - + "'. Decorations will be disabled"); + + "'. Native features will be disabled"); return; } loaded = true; - LOGGER.info("Loaded darklaf-windows.dll. Decorations are enabled."); + LOGGER.info("Loaded darklaf-windows.dll. Native features are enabled."); } catch (Throwable e) { //Library not found, SecurityManager prevents library loading etc. LOGGER.log(Level.SEVERE, "Could not load decorations library darklaf-windows.dll." + - " Decorations will be disabled", e); + " Native features will be disabled", e); } }