mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2026-02-12 06:57:13 -06:00
RootPane: undone commits 7b248427f0 and c6d1ed91a7 because it seems to have no effect anymore
- on Windows with FlatLaf window decorations, maybe because of 7f02eb9cf0
- on Windows with standard window decorations, it seems not to work (still shows "white lines" @2.25x on Windows 10; Java 17)
- macOS and Linux do not support fractional scaling and "white lines" shown never be shown on that platforms
This commit is contained in:
@@ -28,11 +28,8 @@ import java.awt.Insets;
|
|||||||
import java.awt.LayoutManager;
|
import java.awt.LayoutManager;
|
||||||
import java.awt.LayoutManager2;
|
import java.awt.LayoutManager2;
|
||||||
import java.awt.Window;
|
import java.awt.Window;
|
||||||
import java.awt.event.ComponentAdapter;
|
|
||||||
import java.awt.event.ComponentEvent;
|
|
||||||
import java.awt.event.ComponentListener;
|
import java.awt.event.ComponentListener;
|
||||||
import java.beans.PropertyChangeEvent;
|
import java.beans.PropertyChangeEvent;
|
||||||
import java.beans.PropertyChangeListener;
|
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import javax.swing.JComponent;
|
import javax.swing.JComponent;
|
||||||
import javax.swing.JDialog;
|
import javax.swing.JDialog;
|
||||||
@@ -41,7 +38,6 @@ import javax.swing.JLayeredPane;
|
|||||||
import javax.swing.JMenuBar;
|
import javax.swing.JMenuBar;
|
||||||
import javax.swing.JRootPane;
|
import javax.swing.JRootPane;
|
||||||
import javax.swing.LookAndFeel;
|
import javax.swing.LookAndFeel;
|
||||||
import javax.swing.SwingUtilities;
|
|
||||||
import javax.swing.UIManager;
|
import javax.swing.UIManager;
|
||||||
import javax.swing.border.Border;
|
import javax.swing.border.Border;
|
||||||
import javax.swing.plaf.BorderUIResource;
|
import javax.swing.plaf.BorderUIResource;
|
||||||
@@ -88,8 +84,6 @@ public class FlatRootPaneUI
|
|||||||
|
|
||||||
private Object nativeWindowBorderData;
|
private Object nativeWindowBorderData;
|
||||||
private LayoutManager oldLayout;
|
private LayoutManager oldLayout;
|
||||||
private PropertyChangeListener ancestorListener;
|
|
||||||
private ComponentListener componentListener;
|
|
||||||
private ComponentListener macFullWindowContentListener;
|
private ComponentListener macFullWindowContentListener;
|
||||||
|
|
||||||
public static ComponentUI createUI( JComponent c ) {
|
public static ComponentUI createUI( JComponent c ) {
|
||||||
@@ -178,40 +172,6 @@ public class FlatRootPaneUI
|
|||||||
protected void installListeners( JRootPane root ) {
|
protected void installListeners( JRootPane root ) {
|
||||||
super.installListeners( root );
|
super.installListeners( root );
|
||||||
|
|
||||||
if( SystemInfo.isJava_9_orLater ) {
|
|
||||||
// On HiDPI screens, where scaling is used, there may be white lines on the
|
|
||||||
// bottom and on the right side of the window when it is initially shown.
|
|
||||||
// This is very disturbing in dark themes, but hard to notice in light themes.
|
|
||||||
// Seems to be a rounding issue when Swing adds dirty region of window
|
|
||||||
// using RepaintManager.nativeAddDirtyRegion().
|
|
||||||
//
|
|
||||||
// Note: Not using a HierarchyListener here, which would be much easier,
|
|
||||||
// because this causes problems with mouse clicks in heavy-weight popups.
|
|
||||||
// Instead, add a listener to the root pane that waits until it is added
|
|
||||||
// to a window, then add a component listener to the window.
|
|
||||||
// See: https://github.com/JFormDesigner/FlatLaf/issues/371
|
|
||||||
ancestorListener = e -> {
|
|
||||||
Object oldValue = e.getOldValue();
|
|
||||||
Object newValue = e.getNewValue();
|
|
||||||
if( newValue instanceof Window ) {
|
|
||||||
if( componentListener == null ) {
|
|
||||||
componentListener = new ComponentAdapter() {
|
|
||||||
@Override
|
|
||||||
public void componentShown( ComponentEvent e ) {
|
|
||||||
// add whole root pane to dirty regions when window is initially shown
|
|
||||||
root.getParent().repaint( root.getX(), root.getY(), root.getWidth(), root.getHeight() );
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
((Window)newValue).addComponentListener( componentListener );
|
|
||||||
} else if( newValue == null && oldValue instanceof Window ) {
|
|
||||||
if( componentListener != null )
|
|
||||||
((Window)oldValue).removeComponentListener( componentListener );
|
|
||||||
}
|
|
||||||
};
|
|
||||||
root.addPropertyChangeListener( "ancestor", ancestorListener );
|
|
||||||
}
|
|
||||||
|
|
||||||
if( SystemInfo.isMacFullWindowContentSupported )
|
if( SystemInfo.isMacFullWindowContentSupported )
|
||||||
macFullWindowContentListener = FullWindowContentSupport.macInstallListeners( root );
|
macFullWindowContentListener = FullWindowContentSupport.macInstallListeners( root );
|
||||||
}
|
}
|
||||||
@@ -220,17 +180,6 @@ public class FlatRootPaneUI
|
|||||||
protected void uninstallListeners( JRootPane root ) {
|
protected void uninstallListeners( JRootPane root ) {
|
||||||
super.uninstallListeners( root );
|
super.uninstallListeners( root );
|
||||||
|
|
||||||
if( SystemInfo.isJava_9_orLater ) {
|
|
||||||
if( componentListener != null ) {
|
|
||||||
Window window = SwingUtilities.windowForComponent( root );
|
|
||||||
if( window != null )
|
|
||||||
window.removeComponentListener( componentListener );
|
|
||||||
componentListener = null;
|
|
||||||
}
|
|
||||||
root.removePropertyChangeListener( "ancestor", ancestorListener );
|
|
||||||
ancestorListener = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( SystemInfo.isMacFullWindowContentSupported ) {
|
if( SystemInfo.isMacFullWindowContentSupported ) {
|
||||||
FullWindowContentSupport.macUninstallListeners( root, macFullWindowContentListener );
|
FullWindowContentSupport.macUninstallListeners( root, macFullWindowContentListener );
|
||||||
macFullWindowContentListener = null;
|
macFullWindowContentListener = null;
|
||||||
|
|||||||
Reference in New Issue
Block a user