FlatLaf window decorations on Windows: fixed possible application freeze when using custom component that overrides Component.contains(int x, int y) and invokes SwingUtilities.convertPoint() (or similar) from the overridden method (issue #878)

This commit is contained in:
Karl Tauber
2024-09-04 00:48:42 +02:00
parent 438ec6ac5c
commit a6ecb0ef85
2 changed files with 21 additions and 1 deletions

View File

@@ -1,6 +1,16 @@
FlatLaf Change Log FlatLaf Change Log
================== ==================
## 3.6-SNAPSHOT
#### Fixed bugs
- FlatLaf window decorations on Windows: Fixed possible application freeze when
using custom component that overrides `Component.contains(int x, int y)` and
invokes `SwingUtilities.convertPoint()` (or similar) from the overridden
method. (issue #878)
## 3.5.1 ## 3.5.1
#### Fixed bugs #### Fixed bugs

View File

@@ -1079,7 +1079,7 @@ public class FlatTitlePane
} }
private boolean isTitleBarCaptionAt( Component c, int x, int y ) { private boolean isTitleBarCaptionAt( Component c, int x, int y ) {
if( !c.isDisplayable() || !c.isVisible() || !c.contains( x, y ) || c == mouseLayer ) if( !c.isDisplayable() || !c.isVisible() || !contains( c, x, y ) || c == mouseLayer )
return true; // continue checking with next component return true; // continue checking with next component
if( c.isEnabled() && if( c.isEnabled() &&
@@ -1131,6 +1131,16 @@ public class FlatTitlePane
return true; return true;
} }
/**
* Same as {@link Component#contains(int, int)}, but not using that method
* because it may be overridden by custom components and invoke code that
* tries to request AWT tree lock on 'AWT-Windows' thread.
* This could freeze the application if AWT tree is already locked on 'AWT-EventQueue' thread.
*/
private boolean contains( Component c, int x, int y ) {
return x >= 0 && y >= 0 && x < c.getWidth() && y < c.getHeight();
}
private int lastCaptionHitTestX; private int lastCaptionHitTestX;
private int lastCaptionHitTestY; private int lastCaptionHitTestY;
private long lastCaptionHitTestTime; private long lastCaptionHitTestTime;