Skip to content

Commit

Permalink
FlatLaf window decorations on Windows: fixed possible application fre…
Browse files Browse the repository at this point in the history
…eze when using custom component that overrides `Component.contains(int x, int y)` and invokes `SwingUtilities.convertPoint()` (or similar) from the overridden method (issue #878)
  • Loading branch information
DevCharly committed Sep 3, 2024
1 parent 438ec6a commit a6ecb0e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
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

#### Fixed bugs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1079,7 +1079,7 @@ private boolean captionHitTest( Point pt ) {
}

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

if( c.isEnabled() &&
Expand Down Expand Up @@ -1131,6 +1131,16 @@ private boolean isTitleBarCaptionAt( Component c, int x, int y ) {
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 lastCaptionHitTestY;
private long lastCaptionHitTestTime;
Expand Down

0 comments on commit a6ecb0e

Please sign in to comment.