diff --git a/platform-base/src/main/java/com/github/weisj/darklaf/platform/DecorationsConstants.java b/platform-base/src/main/java/com/github/weisj/darklaf/platform/DecorationsConstants.java index f67e729f..d7d058e3 100644 --- a/platform-base/src/main/java/com/github/weisj/darklaf/platform/DecorationsConstants.java +++ b/platform-base/src/main/java/com/github/weisj/darklaf/platform/DecorationsConstants.java @@ -1,7 +1,7 @@ /* * MIT License * - * Copyright (c) 2022 Jannis Weis + * Copyright (c) 2022-2023 Jannis Weis * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and * associated documentation files (the "Software"), to deal in the Software without restriction, @@ -28,4 +28,5 @@ public interface DecorationsConstants { String KEY_UNIFIED_MENUBAR = "JRootPane.unifiedMenuBar"; String KEY_COLORED_TITLE_BAR = "JRootPane.coloredTitleBar"; String KEY_HIDE_TITLE = "JRootPane.hideTitle"; + String KEY_WINDOWS_SMALL_CORNER_RADIUS = "JRootPane.windows.smallCornerRadius"; } diff --git a/windows/src/main/cpp/Decorations.cpp b/windows/src/main/cpp/Decorations.cpp index 9632768e..e2acef3e 100644 --- a/windows/src/main/cpp/Decorations.cpp +++ b/windows/src/main/cpp/Decorations.cpp @@ -1,7 +1,7 @@ /* * MIT License * - * Copyright (c) 2019-2022 Jannis Weis + * Copyright (c) 2019-2023 Jannis Weis * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and * associated documentation files (the "Software"), to deal in the Software without restriction, @@ -316,14 +316,14 @@ static void SetupWindowStyle(HWND handle) { SetWindowLongPtr(handle, GWL_STYLE, style); } -static bool InstallDecorations(HWND handle, bool is_popup) { +static bool InstallDecorations(HWND handle, bool is_popup, bool use_small_corner_arc = false) { // Prevent multiple installations overriding the real window procedure. auto it = wrapper_map.find(handle); if (it != wrapper_map.end()) return false; SetupWindowStyle(handle); ExtendClientFrame(handle); - if (is_popup) { + if (use_small_corner_arc) { auto attribute = DWMWINDOWATTRIBUTE::DWMWA_WINDOW_CORNER_PREFERENCE; auto preference = DWM_WINDOW_CORNER_PREFERENCE::DWMWCP_ROUNDSMALL; DwmSetWindowAttribute(handle, attribute, &preference, sizeof(preference)); @@ -509,9 +509,9 @@ Java_com_github_weisj_darklaf_platform_windows_JNIDecorationsWindows_uninstallDe } JNIEXPORT jboolean JNICALL -Java_com_github_weisj_darklaf_platform_windows_JNIDecorationsWindows_installPopupMenuDecorations(JNIEnv*, jclass, jlong hwnd) { +Java_com_github_weisj_darklaf_platform_windows_JNIDecorationsWindows_installPopupMenuDecorations(JNIEnv*, jclass, jlong hwnd, jboolean useSmallCornerArc) { HWND handle = reinterpret_cast(hwnd); - return static_cast(InstallDecorations(handle, true)); + return static_cast(InstallDecorations(handle, true, useSmallCornerArc)); } //Window functions. diff --git a/windows/src/main/java/com/github/weisj/darklaf/platform/windows/JNIDecorationsWindows.java b/windows/src/main/java/com/github/weisj/darklaf/platform/windows/JNIDecorationsWindows.java index bc10c5ea..6c9e0669 100644 --- a/windows/src/main/java/com/github/weisj/darklaf/platform/windows/JNIDecorationsWindows.java +++ b/windows/src/main/java/com/github/weisj/darklaf/platform/windows/JNIDecorationsWindows.java @@ -1,7 +1,7 @@ /* * MIT License * - * Copyright (c) 2019-2021 Jannis Weis + * Copyright (c) 2019-2023 Jannis Weis * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and * associated documentation files (the "Software"), to deal in the Software without restriction, @@ -48,7 +48,7 @@ public final class JNIDecorationsWindows { public static native void uninstallDecorations(final long hwnd, final boolean decorated); - public static native boolean installPopupMenuDecorations(final long hwnd); + public static native boolean installPopupMenuDecorations(final long hwnd, final boolean useSmallCornerArc); public static native void init(); 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 c0df57a0..6248f786 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 @@ -1,7 +1,7 @@ /* * MIT License * - * Copyright (c) 2019-2022 Jannis Weis + * Copyright (c) 2019-2023 Jannis Weis * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and * associated documentation files (the "Software"), to deal in the Software without restriction, @@ -29,6 +29,7 @@ import javax.swing.border.Border; import com.github.weisj.darklaf.platform.*; import com.github.weisj.darklaf.platform.windows.ui.WindowsTitlePane; +import com.github.weisj.darklaf.util.PropertyUtil; public class WindowsDecorationsProvider implements DecorationsProvider { @@ -61,7 +62,9 @@ public class WindowsDecorationsProvider implements DecorationsProvider { } PointerUtil.WindowPointer hwnd = PointerUtil.getHWND(window); if (hwnd.isValid()) { - JNIDecorationsWindows.installPopupMenuDecorations(hwnd.value()); + + JNIDecorationsWindows.installPopupMenuDecorations(hwnd.value(), + useSmallCornerRadiusForWindow(window)); if (window instanceof RootPaneContainer) { JRootPane rootPane = ((RootPaneContainer) window).getRootPane(); Color bg = rootPane != null ? rootPane.getBackground() : null; @@ -72,6 +75,12 @@ public class WindowsDecorationsProvider implements DecorationsProvider { } } + private boolean useSmallCornerRadiusForWindow(final Window w) { + if (!(w instanceof RootPaneContainer)) return false; + return PropertyUtil.getBooleanProperty(((RootPaneContainer) w).getRootPane(), + DecorationsConstants.KEY_WINDOWS_SMALL_CORNER_RADIUS, true); + } + @Override public void uninstallPopupWindow(final Window window) { if (window.isDisplayable()) {