From 02a15f13514b94f35c811a642ddb8ce262a15d22 Mon Sep 17 00:00:00 2001 From: Jannis Weis <31143295+weisJ@users.noreply.github.com> Date: Sat, 13 Nov 2021 21:26:38 +0100 Subject: [PATCH] Rename isWindows10 to isWindows10OrGreater This value does report true for Windows 11 and should indicate this in its name. --- .../darklaf/platform/ThemePreferencesHandler.java | 2 +- .../weisj/darklaf/task/PlatformDefaultsInitTask.java | 2 +- .../java/com/github/weisj/darklaf/util/SystemInfo.java | 10 +++++++--- .../platform/windows/WindowsDecorationsProvider.java | 2 +- .../weisj/darklaf/platform/windows/WindowsLibrary.java | 2 +- .../darklaf/platform/windows/ui/WindowsTitlePane.java | 5 +++-- 6 files changed, 14 insertions(+), 9 deletions(-) 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 ff77d39d..0c5b4d14 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 @@ -56,7 +56,7 @@ public class ThemePreferencesHandler { try { // Extend for different platforms. boolean enableNativePreferences = isNativePreferencesEnabled(); - if (SystemInfo.isWindows10 && enableNativePreferences) { + if (SystemInfo.isWindows10OrGreater && enableNativePreferences) { preferenceProvider = new WindowsThemePreferenceProvider(); } else if (SystemInfo.isMac && enableNativePreferences) { preferenceProvider = new MacOSThemePreferenceProvider(); diff --git a/core/src/main/java/com/github/weisj/darklaf/task/PlatformDefaultsInitTask.java b/core/src/main/java/com/github/weisj/darklaf/task/PlatformDefaultsInitTask.java index 5ff83bd1..121cb6a6 100644 --- a/core/src/main/java/com/github/weisj/darklaf/task/PlatformDefaultsInitTask.java +++ b/core/src/main/java/com/github/weisj/darklaf/task/PlatformDefaultsInitTask.java @@ -32,7 +32,7 @@ public class PlatformDefaultsInitTask implements DefaultsInitTask { @Override public void run(final Theme currentTheme, final UIDefaults defaults) { String key = DarkPopupMenuUI.KEY_DEFAULT_LIGHTWEIGHT_POPUPS; - if (SystemInfo.isWindows10 && DecorationsHandler.getSharedInstance().isCustomDecorationSupported()) { + if (SystemInfo.isWindows10OrGreater && DecorationsHandler.getSharedInstance().isCustomDecorationSupported()) { JPopupMenu.setDefaultLightWeightPopupEnabled(Boolean.TRUE.equals(defaults.get(key + ".windows10"))); } else { JPopupMenu.setDefaultLightWeightPopupEnabled(Boolean.TRUE.equals(defaults.get(key))); diff --git a/utils/src/main/java/com/github/weisj/darklaf/util/SystemInfo.java b/utils/src/main/java/com/github/weisj/darklaf/util/SystemInfo.java index 8a27a34e..636af589 100644 --- a/utils/src/main/java/com/github/weisj/darklaf/util/SystemInfo.java +++ b/utils/src/main/java/com/github/weisj/darklaf/util/SystemInfo.java @@ -69,7 +69,7 @@ public final class SystemInfo { public static final boolean isMacOSMojave; public static final boolean isMacOSCatalina; public static final boolean isMacOSYosemite; - public static final boolean isWindows10; + public static final boolean isWindows10OrGreater; public static final boolean isWindows7; public static final boolean isWindowsVista; @@ -94,8 +94,12 @@ public final class SystemInfo { isMacOSCatalina = isMac && isOsVersionAtLeast("10.15"); isMacOSMojave = isMacOSCatalina || (isMac && isOsVersionAtLeast("10.14")); isMacOSYosemite = isMacOSCatalina || (isMac && isOsVersionAtLeast("10.10")); - isWindows10 = isWindows && isOsVersionAtLeast("10.0"); - isWindows7 = isWindows10 || (isWindows && isOsVersionAtLeast("6.1")); + + isWindows10OrGreater = isWindows && isOsVersionAtLeast("10.0"); + System.out.println(OS_VERSION); + System.out.println(OS_NAME); + + isWindows7 = isWindows10OrGreater || (isWindows && isOsVersionAtLeast("6.1")); isWindowsVista = isWindows7 || (isWindows && isOsVersionAtLeast("6.0")); isJava9OrGreater = isJavaVersionAtLeast("9"); isJava16OrGreater = isJava9OrGreater && isJavaVersionAtLeast("16"); diff --git a/windows/src/main/java/com/github/weisj/darklaf/platform/windows/WindowsDecorationsProvider.java b/windows/src/main/java/com/github/weisj/darklaf/platform/windows/WindowsDecorationsProvider.java index d7f3d2c1..925d4e3b 100644 --- a/windows/src/main/java/com/github/weisj/darklaf/platform/windows/WindowsDecorationsProvider.java +++ b/windows/src/main/java/com/github/weisj/darklaf/platform/windows/WindowsDecorationsProvider.java @@ -38,7 +38,7 @@ import com.github.weisj.darklaf.util.SystemInfo; public class WindowsDecorationsProvider implements DecorationsProvider { public WindowsDecorationsProvider() throws UnsupportedProviderException { - if (!SystemInfo.isWindows10) + if (!SystemInfo.isWindows10OrGreater) throw new UnsupportedProviderException("Only supported on Windows 10 or later"); if (!WindowsLibrary.get().canLoad()) throw new UnsupportedProviderException("Native components aren't supported"); 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 13b6d895..7929c047 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 @@ -66,6 +66,6 @@ public class WindowsLibrary extends AbstractLibrary { @Override protected boolean canLoad() { - return !SystemInfo.undefinedArchitecture && SystemInfo.isX86Compatible && SystemInfo.isWindows10; + return !SystemInfo.undefinedArchitecture && SystemInfo.isX86Compatible && SystemInfo.isWindows10OrGreater; } } diff --git a/windows/src/main/java/com/github/weisj/darklaf/platform/windows/ui/WindowsTitlePane.java b/windows/src/main/java/com/github/weisj/darklaf/platform/windows/ui/WindowsTitlePane.java index 003954c0..4c4e7dde 100644 --- a/windows/src/main/java/com/github/weisj/darklaf/platform/windows/ui/WindowsTitlePane.java +++ b/windows/src/main/java/com/github/weisj/darklaf/platform/windows/ui/WindowsTitlePane.java @@ -743,8 +743,9 @@ public class WindowsTitlePane extends CustomTitlePane { } protected void updateDragArea(final GraphicsConfiguration gc) { - JNIDecorationsWindows.updateValues(windowHandle, (int) Scale.scaleWidth(left, gc), - (int) Scale.scaleWidth(right, gc), (int) Scale.scaleHeight(height, gc)); + JNIDecorationsWindows.updateValues(windowHandle, + (int) Scale.scaleWidth(left, gc), (int) Scale.scaleWidth(right, gc), + (int) Scale.scaleHeight(height, gc), (int) Scale.scaleHeight(BUTTON_WIDTH, gc)); } private Dimension getPreferredMenuSize() {