Popup: no longer reuse popup windows for menus to avoid immediately closing dialogs on ChromeOS (issue #1029)

added system property `flatlaf.reuseVisiblePopupWindow`
This commit is contained in:
Karl Tauber
2025-09-20 12:51:50 +02:00
parent f8e53c9064
commit 15cbf28a0d
3 changed files with 27 additions and 2 deletions

View File

@@ -15,6 +15,8 @@ FlatLaf Change Log
- Tree and List: Fixed painting of rounded drop backgrounds. (issue #1023)
- Popup: Showing tooltip in inactive window brought that window to front (made
it active) and potentially hid the previously active window. (issue #1037)
- Popup: No longer reuse popup windows for menus to avoid immediately closing
dialogs on ChromeOS. (issue #1029)
- macOS: Fixed window "flashing" when switching from a light to a dark theme (or
vice versa). Especially when using animated theme changer (see
[FlatLaf Extras](flatlaf-extras)).

View File

@@ -16,6 +16,7 @@
package com.formdev.flatlaf;
import javax.swing.JPopupMenu;
import javax.swing.SwingUtilities;
import com.formdev.flatlaf.util.UIScale;
@@ -147,6 +148,25 @@ public interface FlatSystemProperties
*/
String USE_ROUNDED_POPUP_BORDER = "flatlaf.useRoundedPopupBorder";
/**
* Species whether popup windows may be reused without (temporary) hiding them.
* E.g. if "moving" a tooltip to follow the mouse pointer, normally it is necessary
* to hide the tooltip and show it again at the new location, which causes some
* flicker with heavy-weight popup windows that FlatLaf uses on all platforms.
* <p>
* If {@code true}, hiding popup window is deferred for an event cycle,
* which allows reusing still visible popup window and avoids flicker when "moving" the popup.
* <p>
* Note that {@link JPopupMenu} popup windows (menus and combobox lists) are newer reused.
* <p>
* <strong>Allowed Values</strong> {@code false} and {@code true}<br>
* <strong>Default</strong> {@code true}
*
* @since 3.7
*/
String REUSE_VISIBLE_POPUP_WINDOW = "flatlaf.reuseVisiblePopupWindow";
/**
* Specifies whether vertical text position is corrected when UI is scaled on HiDPI screens.
* <p>

View File

@@ -676,8 +676,11 @@ public class FlatPopupFactory
return;
disposed = true;
// immediately hide non-heavy weight popups or combobox popups
if( !(popupWindow instanceof JWindow) || contents instanceof BasicComboPopup ) {
// immediately hide non-heavy weight popups, popup menus and combobox popups
// of if system property is false
if( !(popupWindow instanceof JWindow) || contents instanceof JPopupMenu ||
!FlatSystemProperties.getBoolean( FlatSystemProperties.REUSE_VISIBLE_POPUP_WINDOW, true ) )
{
hideImpl();
return;
}