mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2026-02-13 07:17:13 -06:00
This commit is contained in:
@@ -58,6 +58,7 @@ import javax.swing.border.AbstractBorder;
|
|||||||
import javax.swing.border.Border;
|
import javax.swing.border.Border;
|
||||||
import com.formdev.flatlaf.FlatClientProperties;
|
import com.formdev.flatlaf.FlatClientProperties;
|
||||||
import com.formdev.flatlaf.ui.JBRCustomDecorations.JBRWindowTopBorder;
|
import com.formdev.flatlaf.ui.JBRCustomDecorations.JBRWindowTopBorder;
|
||||||
|
import com.formdev.flatlaf.util.SystemInfo;
|
||||||
import com.formdev.flatlaf.util.UIScale;
|
import com.formdev.flatlaf.util.UIScale;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -371,32 +372,48 @@ class FlatTitlePane
|
|||||||
// remember current maximized bounds
|
// remember current maximized bounds
|
||||||
Rectangle oldMaximizedBounds = frame.getMaximizedBounds();
|
Rectangle oldMaximizedBounds = frame.getMaximizedBounds();
|
||||||
|
|
||||||
// Scaled screen size, which may be smaller than physical size on Java 9+.
|
// Screen bounds, which may be smaller than physical size on Java 9+.
|
||||||
// E.g. if running a 3840x2160 screen at 200%, scaledSreenSize is 1920x1080.
|
// E.g. if running a 3840x2160 screen at 200%, screenBounds.size is 1920x1080.
|
||||||
// In Java 9+, each screen can have its own scale factor.
|
// In Java 9+, each screen can have its own scale factor.
|
||||||
//
|
//
|
||||||
// On Java 8, which does not scale, scaledSreenSize of the primary screen
|
// On Java 8, which does not scale, screenBounds.size of the primary screen
|
||||||
// is identical to its physical size. But when the primary screen is scaled,
|
// is identical to its physical size. But when the primary screen is scaled,
|
||||||
// then scaledSreenSize of secondary screens is scaled with the scale factor
|
// then screenBounds.size of secondary screens is scaled with the scale factor
|
||||||
// of the primary screen.
|
// of the primary screen.
|
||||||
// E.g. primary 3840x2160 screen at 150%, secondary 1920x1080 screen at 100%,
|
// E.g. primary 3840x2160 screen at 150%, secondary 1920x1080 screen at 100%,
|
||||||
// then scaledSreenSize is 3840x2160 on primary and 2880x1560 on secondary.
|
// then screenBounds.size is 3840x2160 on primary and 2880x1560 on secondary.
|
||||||
Dimension scaledSreenSize = gc.getBounds().getSize();
|
Rectangle screenBounds = gc.getBounds();
|
||||||
|
|
||||||
// scale screen bounds to get physical screen size
|
int maximizedX = screenBounds.x;
|
||||||
AffineTransform defaultTransform = gc.getDefaultTransform();
|
int maximizedY = screenBounds.y;
|
||||||
int screenWidth = (int) (scaledSreenSize.width * defaultTransform.getScaleX());
|
int maximizedWidth = screenBounds.width;
|
||||||
int screenHeight = (int) (scaledSreenSize.height * defaultTransform.getScaleY());
|
int maximizedHeight = screenBounds.height;
|
||||||
|
|
||||||
// screen insets are in physical size,
|
if( !SystemInfo.IS_JAVA_15_OR_LATER ) {
|
||||||
// except for Java 8 on secondary screens where primary screen is scaled
|
// on Java 8 to 14, maximized x,y are 0,0 based on all screens in a multi-screen environment
|
||||||
|
maximizedX = 0;
|
||||||
|
maximizedY = 0;
|
||||||
|
|
||||||
|
// scale maximized screen size to get physical screen size for Java 9 to 14
|
||||||
|
AffineTransform defaultTransform = gc.getDefaultTransform();
|
||||||
|
maximizedWidth = (int) (maximizedWidth * defaultTransform.getScaleX());
|
||||||
|
maximizedHeight = (int) (maximizedHeight * defaultTransform.getScaleY());
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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 = window.getToolkit().getScreenInsets( gc );
|
||||||
|
|
||||||
// maximized bounds are required in physical size,
|
// maximized bounds are required in physical size, except for Java 15+
|
||||||
// except for Java 8 on secondary screens where primary screen is scaled
|
// (see https://bugs.openjdk.java.net/browse/JDK-8231564 and
|
||||||
Rectangle maximizedBounds = new Rectangle( screenInsets.left, screenInsets.top,
|
// https://bugs.openjdk.java.net/browse/JDK-8176359)
|
||||||
screenWidth - screenInsets.left - screenInsets.right,
|
// and except for Java 8 on secondary screens where primary screen is scaled
|
||||||
screenHeight - screenInsets.top - screenInsets.bottom );
|
Rectangle maximizedBounds = new Rectangle(
|
||||||
|
maximizedX + screenInsets.left,
|
||||||
|
maximizedY + screenInsets.top,
|
||||||
|
maximizedWidth - screenInsets.left - screenInsets.right,
|
||||||
|
maximizedHeight - screenInsets.top - screenInsets.bottom );
|
||||||
|
|
||||||
// temporary change maximized bounds
|
// temporary change maximized bounds
|
||||||
frame.setMaximizedBounds( maximizedBounds );
|
frame.setMaximizedBounds( maximizedBounds );
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ public class SystemInfo
|
|||||||
// Java versions
|
// Java versions
|
||||||
public static final boolean IS_JAVA_9_OR_LATER;
|
public static final boolean IS_JAVA_9_OR_LATER;
|
||||||
public static final boolean IS_JAVA_11_OR_LATER;
|
public static final boolean IS_JAVA_11_OR_LATER;
|
||||||
|
public static final boolean IS_JAVA_15_OR_LATER;
|
||||||
|
|
||||||
// Java VMs
|
// Java VMs
|
||||||
public static final boolean IS_JETBRAINS_JVM;
|
public static final boolean IS_JETBRAINS_JVM;
|
||||||
@@ -66,6 +67,7 @@ public class SystemInfo
|
|||||||
long javaVersion = scanVersion( System.getProperty( "java.version" ) );
|
long javaVersion = scanVersion( System.getProperty( "java.version" ) );
|
||||||
IS_JAVA_9_OR_LATER = (javaVersion >= toVersion( 9, 0, 0, 0 ));
|
IS_JAVA_9_OR_LATER = (javaVersion >= toVersion( 9, 0, 0, 0 ));
|
||||||
IS_JAVA_11_OR_LATER = (javaVersion >= toVersion( 11, 0, 0, 0 ));
|
IS_JAVA_11_OR_LATER = (javaVersion >= toVersion( 11, 0, 0, 0 ));
|
||||||
|
IS_JAVA_15_OR_LATER = (javaVersion >= toVersion( 15, 0, 0, 0 ));
|
||||||
|
|
||||||
// Java VMs
|
// Java VMs
|
||||||
IS_JETBRAINS_JVM = System.getProperty( "java.vm.vendor", "Unknown" )
|
IS_JETBRAINS_JVM = System.getProperty( "java.vm.vendor", "Unknown" )
|
||||||
|
|||||||
Reference in New Issue
Block a user