diff --git a/CHANGELOG.md b/CHANGELOG.md index 49c2059a..6419f939 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,13 @@ FlatLaf Change Log - ToolBar: Fixed endless loop if button in Toolbar has focus and is made invisible. (issue #884) +#### Other Changes + +- Added system property `flatlaf.useRoundedPopupBorder` to allow disabling + native rounded popup borders on Windows 11 and macOS. On macOS 14.4+, where + rounded popup borders are disabled since FlatLaf 3.5 because of occasional + problems, you can use this to enable rounded popup borders (at your risk). + ## 3.5.1 diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/FlatSystemProperties.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/FlatSystemProperties.java index 956c2b9e..b43082a4 100644 --- a/flatlaf-core/src/main/java/com/formdev/flatlaf/FlatSystemProperties.java +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/FlatSystemProperties.java @@ -135,6 +135,17 @@ public interface FlatSystemProperties */ String ANIMATION = "flatlaf.animation"; + /** + * Specifies whether native rounded popup borders should be used (if supported by operating system). + *
+ * (requires Window 11 or macOS) + *
+ * Allowed Values {@code false} and {@code true}
+ * Default {@code true}; except on macOS 14.4+ where it is {@code false}
+ * @since 3.5.2
+ */
+ String USE_ROUNDED_POPUP_BORDER = "flatlaf.useRoundedPopupBorder";
+
/**
* Specifies whether vertical text position is corrected when UI is scaled on HiDPI screens.
*
diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatPopupFactory.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatPopupFactory.java index b4f5abad..94e7cda8 100644 --- a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatPopupFactory.java +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatPopupFactory.java @@ -63,6 +63,7 @@ import javax.swing.border.EmptyBorder; import javax.swing.border.LineBorder; import javax.swing.plaf.basic.BasicComboPopup; import com.formdev.flatlaf.FlatClientProperties; +import com.formdev.flatlaf.FlatSystemProperties; import com.formdev.flatlaf.util.SystemInfo; import com.formdev.flatlaf.util.UIScale; @@ -116,13 +117,7 @@ public class FlatPopupFactory // macOS and Linux adds drop shadow to heavy weight popups if( SystemInfo.isMacOS || SystemInfo.isLinux ) { NonFlashingPopup popup = new NonFlashingPopup( getPopupForScreenOfOwner( owner, contents, x, y, true ), owner, contents ); - if( popup.popupWindow != null && SystemInfo.isMacOS && - // do not use rounded border on macOS 14.4+ because it may freeze the application - // and crash the macOS WindowServer process (reports vary from Finder restarts to OS restarts) - // https://github.com/apache/netbeans/issues/7560#issuecomment-2226439215 - // https://github.com/apache/netbeans/issues/6647#issuecomment-2070124442 - SystemInfo.osVersion < SystemInfo.toVersion( 14, 4, 0, 0 ) && - FlatNativeMacLibrary.isLoaded() ) + if( popup.popupWindow != null && isMacOSBorderSupported() ) setupRoundedBorder( popup.popupWindow, owner, contents ); return popup; } @@ -363,7 +358,21 @@ public class FlatPopupFactory //---- native rounded border ---------------------------------------------- private static boolean isWindows11BorderSupported() { - return SystemInfo.isWindows_11_orLater && FlatNativeWindowsLibrary.isLoaded(); + return SystemInfo.isWindows_11_orLater && + FlatSystemProperties.getBoolean( FlatSystemProperties.USE_ROUNDED_POPUP_BORDER, true ) && + FlatNativeWindowsLibrary.isLoaded(); + } + + private static boolean isMacOSBorderSupported() { + // do not use rounded border on macOS 14.4+ because it may freeze the application + // and crash the macOS WindowServer process (reports vary from Finder restarts to OS restarts) + // https://github.com/apache/netbeans/issues/7560#issuecomment-2226439215 + // https://github.com/apache/netbeans/issues/6647#issuecomment-2070124442 + boolean isMacOS_14_4_orLater = (SystemInfo.osVersion >= SystemInfo.toVersion( 14, 4, 0, 0 )); + + return SystemInfo.isMacOS && + FlatSystemProperties.getBoolean( FlatSystemProperties.USE_ROUNDED_POPUP_BORDER, !isMacOS_14_4_orLater ) && + FlatNativeMacLibrary.isLoaded(); } private static void setupRoundedBorder( Window popupWindow, Component owner, Component contents ) {