mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2025-12-08 06:50:56 +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)
|
- JideSplitButton: Fixed updating popup when switching theme. (issue #1000)
|
||||||
- IntelliJ Themes: Fixed logging false errors when loading 3rd party
|
- IntelliJ Themes: Fixed logging false errors when loading 3rd party
|
||||||
`.theme.json` files. (issue #990)
|
`.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
|
## 3.6
|
||||||
|
|||||||
@@ -882,7 +882,7 @@ public class FlatComboBoxUI
|
|||||||
GraphicsConfiguration gc = comboBox.getGraphicsConfiguration();
|
GraphicsConfiguration gc = comboBox.getGraphicsConfiguration();
|
||||||
if( gc != null ) {
|
if( gc != null ) {
|
||||||
Rectangle screenBounds = gc.getBounds();
|
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 );
|
displayWidth = Math.min( displayWidth, screenBounds.width - screenInsets.left - screenInsets.right );
|
||||||
} else {
|
} else {
|
||||||
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
|
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
|
||||||
|
|||||||
@@ -32,7 +32,6 @@ import java.awt.Panel;
|
|||||||
import java.awt.Point;
|
import java.awt.Point;
|
||||||
import java.awt.PointerInfo;
|
import java.awt.PointerInfo;
|
||||||
import java.awt.Rectangle;
|
import java.awt.Rectangle;
|
||||||
import java.awt.Toolkit;
|
|
||||||
import java.awt.Window;
|
import java.awt.Window;
|
||||||
import java.awt.event.ComponentEvent;
|
import java.awt.event.ComponentEvent;
|
||||||
import java.awt.event.ComponentListener;
|
import java.awt.event.ComponentListener;
|
||||||
@@ -312,7 +311,7 @@ public class FlatPopupFactory
|
|||||||
return null;
|
return null;
|
||||||
|
|
||||||
Rectangle screenBounds = gc.getBounds();
|
Rectangle screenBounds = gc.getBounds();
|
||||||
Insets screenInsets = Toolkit.getDefaultToolkit().getScreenInsets( gc );
|
Insets screenInsets = FlatUIUtils.getScreenInsets( gc );
|
||||||
int screenTop = screenBounds.y + screenInsets.top;
|
int screenTop = screenBounds.y + screenInsets.top;
|
||||||
|
|
||||||
// place tooltip above mouse location if there is enough space
|
// 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
|
// (always subtract screen insets because there is no API to detect whether
|
||||||
// the popup can overlap the taskbar; see JPopupMenu.canPopupOverlapTaskBar())
|
// the popup can overlap the taskbar; see JPopupMenu.canPopupOverlapTaskBar())
|
||||||
Rectangle screenBounds = gc.getBounds();
|
Rectangle screenBounds = gc.getBounds();
|
||||||
Insets screenInsets = Toolkit.getDefaultToolkit().getScreenInsets( gc );
|
Insets screenInsets = FlatUIUtils.getScreenInsets( gc );
|
||||||
return FlatUIUtils.subtractInsets( screenBounds, screenInsets );
|
return FlatUIUtils.subtractInsets( screenBounds, screenInsets );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -914,7 +914,7 @@ public class FlatTitlePane
|
|||||||
// screen insets are in physical size, except for Java 15+
|
// screen insets are in physical size, except for Java 15+
|
||||||
// (see https://bugs.openjdk.java.net/browse/JDK-8243925)
|
// (see https://bugs.openjdk.java.net/browse/JDK-8243925)
|
||||||
// and except for Java 8 on secondary screens where primary screen is scaled
|
// 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+
|
// maximized bounds are required in physical size, except for Java 15+
|
||||||
// (see https://bugs.openjdk.java.net/browse/JDK-8231564 and
|
// (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.Graphics2D;
|
||||||
import java.awt.GraphicsConfiguration;
|
import java.awt.GraphicsConfiguration;
|
||||||
import java.awt.GraphicsDevice;
|
import java.awt.GraphicsDevice;
|
||||||
|
import java.awt.GraphicsEnvironment;
|
||||||
import java.awt.Insets;
|
import java.awt.Insets;
|
||||||
import java.awt.KeyboardFocusManager;
|
import java.awt.KeyboardFocusManager;
|
||||||
import java.awt.Paint;
|
import java.awt.Paint;
|
||||||
@@ -34,6 +35,7 @@ import java.awt.RenderingHints;
|
|||||||
import java.awt.Shape;
|
import java.awt.Shape;
|
||||||
import java.awt.Stroke;
|
import java.awt.Stroke;
|
||||||
import java.awt.SystemColor;
|
import java.awt.SystemColor;
|
||||||
|
import java.awt.Toolkit;
|
||||||
import java.awt.Window;
|
import java.awt.Window;
|
||||||
import java.awt.event.FocusEvent;
|
import java.awt.event.FocusEvent;
|
||||||
import java.awt.event.FocusListener;
|
import java.awt.event.FocusListener;
|
||||||
@@ -414,6 +416,17 @@ public class FlatUIUtils
|
|||||||
return (fullScreenWindow != null && fullScreenWindow == SwingUtilities.windowForComponent( c ));
|
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 ) {
|
public static Boolean isRoundRect( Component c ) {
|
||||||
return (c instanceof JComponent)
|
return (c instanceof JComponent)
|
||||||
? FlatClientProperties.clientPropertyBooleanStrict(
|
? FlatClientProperties.clientPropertyBooleanStrict(
|
||||||
|
|||||||
@@ -331,7 +331,7 @@ public abstract class FlatWindowResizer
|
|||||||
protected Rectangle getParentBounds() {
|
protected Rectangle getParentBounds() {
|
||||||
GraphicsConfiguration gc = window.getGraphicsConfiguration();
|
GraphicsConfiguration gc = window.getGraphicsConfiguration();
|
||||||
Rectangle bounds = gc.getBounds();
|
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,
|
return new Rectangle( bounds.x + insets.left, bounds.y + insets.top,
|
||||||
bounds.width - insets.left - insets.right,
|
bounds.width - insets.left - insets.right,
|
||||||
bounds.height - insets.top - insets.bottom );
|
bounds.height - insets.top - insets.bottom );
|
||||||
|
|||||||
Reference in New Issue
Block a user