mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2025-12-06 14:00:55 +03:00
Linux: popups appeared in wrong position on multi-screen setup if primary display is located below or right to secondary display (issue https://github.com/apache/netbeans/issues/8532))
This commit is contained in:
@@ -7,6 +7,9 @@ FlatLaf Change Log
|
||||
- JideSplitButton: Fixed updating popup when switching theme. (issue #1000)
|
||||
- IntelliJ Themes: Fixed logging false errors when loading 3rd party
|
||||
`.theme.json` files. (issue #990)
|
||||
- Linux: Popups appeared in wrong position on multi-screen setup if primary
|
||||
display is located below or right to secondary display. (see
|
||||
[NetBeans issue #8532](https://github.com/apache/netbeans/issues/8532))
|
||||
|
||||
|
||||
## 3.6
|
||||
|
||||
@@ -882,7 +882,7 @@ public class FlatComboBoxUI
|
||||
GraphicsConfiguration gc = comboBox.getGraphicsConfiguration();
|
||||
if( gc != null ) {
|
||||
Rectangle screenBounds = gc.getBounds();
|
||||
Insets screenInsets = Toolkit.getDefaultToolkit().getScreenInsets( gc );
|
||||
Insets screenInsets = FlatUIUtils.getScreenInsets( gc );
|
||||
displayWidth = Math.min( displayWidth, screenBounds.width - screenInsets.left - screenInsets.right );
|
||||
} else {
|
||||
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
|
||||
|
||||
@@ -32,7 +32,6 @@ import java.awt.Panel;
|
||||
import java.awt.Point;
|
||||
import java.awt.PointerInfo;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.Toolkit;
|
||||
import java.awt.Window;
|
||||
import java.awt.event.ComponentEvent;
|
||||
import java.awt.event.ComponentListener;
|
||||
@@ -312,7 +311,7 @@ public class FlatPopupFactory
|
||||
return null;
|
||||
|
||||
Rectangle screenBounds = gc.getBounds();
|
||||
Insets screenInsets = Toolkit.getDefaultToolkit().getScreenInsets( gc );
|
||||
Insets screenInsets = FlatUIUtils.getScreenInsets( gc );
|
||||
int screenTop = screenBounds.y + screenInsets.top;
|
||||
|
||||
// place tooltip above mouse location if there is enough space
|
||||
|
||||
@@ -246,7 +246,7 @@ public class FlatPopupMenuUI
|
||||
// (always subtract screen insets because there is no API to detect whether
|
||||
// the popup can overlap the taskbar; see JPopupMenu.canPopupOverlapTaskBar())
|
||||
Rectangle screenBounds = gc.getBounds();
|
||||
Insets screenInsets = Toolkit.getDefaultToolkit().getScreenInsets( gc );
|
||||
Insets screenInsets = FlatUIUtils.getScreenInsets( gc );
|
||||
return FlatUIUtils.subtractInsets( screenBounds, screenInsets );
|
||||
}
|
||||
|
||||
|
||||
@@ -914,7 +914,7 @@ public class FlatTitlePane
|
||||
// screen insets are in physical size, except for Java 15+
|
||||
// (see https://bugs.openjdk.java.net/browse/JDK-8243925)
|
||||
// and except for Java 8 on secondary screens where primary screen is scaled
|
||||
Insets screenInsets = window.getToolkit().getScreenInsets( gc );
|
||||
Insets screenInsets = FlatUIUtils.getScreenInsets( gc );
|
||||
|
||||
// maximized bounds are required in physical size, except for Java 15+
|
||||
// (see https://bugs.openjdk.java.net/browse/JDK-8231564 and
|
||||
|
||||
@@ -26,6 +26,7 @@ import java.awt.Graphics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.GraphicsConfiguration;
|
||||
import java.awt.GraphicsDevice;
|
||||
import java.awt.GraphicsEnvironment;
|
||||
import java.awt.Insets;
|
||||
import java.awt.KeyboardFocusManager;
|
||||
import java.awt.Paint;
|
||||
@@ -34,6 +35,7 @@ import java.awt.RenderingHints;
|
||||
import java.awt.Shape;
|
||||
import java.awt.Stroke;
|
||||
import java.awt.SystemColor;
|
||||
import java.awt.Toolkit;
|
||||
import java.awt.Window;
|
||||
import java.awt.event.FocusEvent;
|
||||
import java.awt.event.FocusListener;
|
||||
@@ -414,6 +416,17 @@ public class FlatUIUtils
|
||||
return (fullScreenWindow != null && fullScreenWindow == SwingUtilities.windowForComponent( c ));
|
||||
}
|
||||
|
||||
/** @since 3.7 */
|
||||
public static Insets getScreenInsets( GraphicsConfiguration gc ) {
|
||||
// on Linux, getScreenInsets() may report wrong values in multi-screen setups
|
||||
// see https://github.com/apache/netbeans/issues/8532#issuecomment-2909687016
|
||||
if( SystemInfo.isLinux &&
|
||||
GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices().length > 1 )
|
||||
return new Insets( 0, 0, 0, 0 );
|
||||
|
||||
return Toolkit.getDefaultToolkit().getScreenInsets( gc );
|
||||
}
|
||||
|
||||
public static Boolean isRoundRect( Component c ) {
|
||||
return (c instanceof JComponent)
|
||||
? FlatClientProperties.clientPropertyBooleanStrict(
|
||||
|
||||
@@ -331,7 +331,7 @@ public abstract class FlatWindowResizer
|
||||
protected Rectangle getParentBounds() {
|
||||
GraphicsConfiguration gc = window.getGraphicsConfiguration();
|
||||
Rectangle bounds = gc.getBounds();
|
||||
Insets insets = window.getToolkit().getScreenInsets( gc );
|
||||
Insets insets = FlatUIUtils.getScreenInsets( gc );
|
||||
return new Rectangle( bounds.x + insets.left, bounds.y + insets.top,
|
||||
bounds.width - insets.left - insets.right,
|
||||
bounds.height - insets.top - insets.bottom );
|
||||
|
||||
Reference in New Issue
Block a user