2020import javafx .application .Application ;
2121import javafx .application .Platform ;
2222import javafx .beans .value .ObservableBooleanValue ;
23+ import javafx .geometry .Rectangle2D ;
2324import javafx .scene .control .Alert ;
2425import javafx .scene .control .Alert .AlertType ;
2526import javafx .scene .control .ButtonType ;
2627import javafx .scene .input .Clipboard ;
2728import javafx .scene .input .DataFormat ;
29+ import javafx .stage .Screen ;
2830import javafx .stage .Stage ;
2931import org .jackhuang .hmcl .setting .ConfigHolder ;
3032import org .jackhuang .hmcl .setting .SambaException ;
5456import java .nio .file .Files ;
5557import java .nio .file .Path ;
5658import java .nio .file .Paths ;
59+ import java .text .DecimalFormat ;
5760import java .util .ArrayList ;
5861import java .util .Collections ;
5962import java .util .Objects ;
@@ -79,6 +82,18 @@ public void start(Stage primaryStage) {
7982 LOG .info ("Dark Mode: " + Optional .ofNullable (FXUtils .DARK_MODE ).map (ObservableBooleanValue ::get ).orElse (false ));
8083 LOG .info ("Reduced Motion: " + Objects .requireNonNullElse (FXUtils .REDUCED_MOTION , false ));
8184
85+ if (Screen .getScreens ().isEmpty ()) {
86+ LOG .info ("No screen" );
87+ } else {
88+ StringBuilder builder = new StringBuilder ("Screens:" );
89+ int count = 0 ;
90+ for (Screen screen : Screen .getScreens ()) {
91+ builder .append ("\n - Screen " ).append (++count ).append (": " );
92+ appendScreen (builder , screen );
93+ }
94+ LOG .info (builder .toString ());
95+ }
96+
8297 try {
8398 try {
8499 ConfigHolder .init ();
@@ -131,6 +146,38 @@ public void start(Stage primaryStage) {
131146 }
132147 }
133148
149+ private static void appendScreen (StringBuilder builder , Screen screen ) {
150+ Rectangle2D bounds = screen .getBounds ();
151+ double scale = screen .getOutputScaleX ();
152+
153+ builder .append (Math .round (bounds .getWidth () * scale ));
154+ builder .append ('x' );
155+ builder .append (Math .round (bounds .getHeight () * scale ));
156+
157+ DecimalFormat decimalFormat = new DecimalFormat ("#.##" );
158+
159+ if (scale != 1.0 ) {
160+ builder .append (" @ " );
161+ builder .append (decimalFormat .format (scale ));
162+ builder .append ('x' );
163+ }
164+
165+ double dpi = screen .getDpi ();
166+ builder .append (' ' );
167+ builder .append (decimalFormat .format (dpi ));
168+ builder .append ("dpi" );
169+
170+ builder .append (" in " )
171+ .append (Math .round (Math .sqrt (bounds .getWidth () * bounds .getWidth () + bounds .getHeight () * bounds .getHeight ()) / dpi ))
172+ .append ('"' );
173+
174+ builder .append (" (" ).append (decimalFormat .format (bounds .getMinX ()))
175+ .append (", " ).append (decimalFormat .format (bounds .getMinY ()))
176+ .append (", " ).append (decimalFormat .format (bounds .getMaxX ()))
177+ .append (", " ).append (decimalFormat .format (bounds .getMaxY ()))
178+ .append (")" );
179+ }
180+
134181 private static ButtonType showAlert (AlertType alertType , String contentText , ButtonType ... buttons ) {
135182 return new Alert (alertType , contentText , buttons ).showAndWait ().orElse (null );
136183 }
0 commit comments