Skip to content

Commit

Permalink
Window decorations: window top border on Windows 10 in "full window c…
Browse files Browse the repository at this point in the history
…ontent" mode was not fully repainted when activating or deactivating window (issue #809)
  • Loading branch information
DevCharly committed May 28, 2024
1 parent a311bac commit cc4f9a9
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 17 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ FlatLaf Change Log
- Popup: Fixed flicker of popups (e.g. tooltips) while they are moving (e.g.
following mouse pointer). (issues #832 and #672)

#### Fixed bugs

- FlatLaf window decorations: Window top border on Windows 10 in "full window
content" mode was not fully repainted when activating or deactivating window.
(issue #809)

#### Incompatibilities

- ProgressBar: Log warning (including stack trace) when uninstalling
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ public FlatTitlePane( JRootPane rootPane ) {
windowTopBorderLayer = new JPanel();
windowTopBorderLayer.setVisible( false );
windowTopBorderLayer.setOpaque( false );
windowTopBorderLayer.setBorder( FlatUIUtils.nonUIResource( FlatNativeWindowBorder.WindowTopBorder.getInstance() ) );
windowTopBorderLayer.setBorder( FlatUIUtils.nonUIResource( WindowTopBorder.getInstance() ) );
} else
windowTopBorderLayer = null;

Expand Down Expand Up @@ -745,16 +745,6 @@ protected void paintComponent( Graphics g ) {
g.fillRect( 0, 0, getWidth(), getHeight() );
}

protected void repaintWindowBorder() {
int width = rootPane.getWidth();
int height = rootPane.getHeight();
Insets insets = rootPane.getInsets();
rootPane.repaint( 0, 0, width, insets.top ); // top
rootPane.repaint( 0, 0, insets.left, height ); // left
rootPane.repaint( 0, height - insets.bottom, width, insets.bottom ); // bottom
rootPane.repaint( width - insets.right, 0, insets.right, height ); // right
}

/**
* Iconifies the window.
*/
Expand Down Expand Up @@ -1352,21 +1342,30 @@ public void windowActivated( WindowEvent e ) {
activeChanged( true );
updateNativeTitleBarHeightAndHitTestSpots();

if( isWindowTopBorderNeeded() )
WindowTopBorder.getInstance().repaintBorder( FlatTitlePane.this );

repaintWindowBorder();
repaintBorder();
}

@Override
public void windowDeactivated( WindowEvent e ) {
activeChanged( false );
updateNativeTitleBarHeightAndHitTestSpots();

if( isWindowTopBorderNeeded() )
repaintBorder();
}

private void repaintBorder() {
// Windows 10 top border
if( windowTopBorderLayer != null && windowTopBorderLayer.isShowing())
WindowTopBorder.getInstance().repaintBorder( windowTopBorderLayer );
else if( isWindowTopBorderNeeded() && !isWindowMaximized() && !isFullWindowContent() )
WindowTopBorder.getInstance().repaintBorder( FlatTitlePane.this );

repaintWindowBorder();
// Window border used for non-native window decorations
if( rootPane.getBorder() instanceof FlatRootPaneUI.FlatWindowBorder ) {
// not repainting four areas on the four sides because RepaintManager
// unions dirty regions, which also results in repaint of whole rootpane
rootPane.repaint();
}
}

@Override
Expand Down

0 comments on commit cc4f9a9

Please sign in to comment.