gluonhq / substrate

Create native Java(FX) apps for desktop, mobile and embedded
GNU General Public License v2.0
400 stars 51 forks source link

prism.allowhidpi=false doesn't work #935

Open anksty opened 3 years ago

anksty commented 3 years ago

Setting prism.allowhidpi=false to ignore OS scaling doesn't work. Running a native image exe with -Dprism.allowhidpi=false doesn't ignore scaling. If it's set in code with System.setProperty("prism.allowhidpi", "false") before calling the Application class the same project will work properly without scaling when running with mvn javafx:run but will be scaled when running with mvn client:build and mvn client:run

Related stackoverflow question

Expected Behavior

Windows scaling should be ignored.

Current Behavior

The app scales with Windows scaling.

Steps to Reproduce

Build a native image of the HelloFX sample project and try to run the exe with argument -Dprism.allowhidpi=false while Windows OS scaling is 125% or higher.

Your Environment

Java 11.0.10 Windows 10

jperedadnr commented 3 years ago

If you set System.setProperty("prism.allowhidpi", "false") in your Launcher class, that should work with Substrate:

public class Launcher {

    public static void main(String[] args) {
         System.setProperty("prism.allowhidpi", "false");
         HelloFX.main(args);
    }
}
public class HelloFX extends Application {

    public static void main(String[] args) {
        launch(args);
    }

    @Override
    public void start(Stage stage) {
        Scene scene = new Scene(new Label("Test"), 640, 480);
        stage.setScene(scene);
        stage.show();

        System.out.println("Scale: " + stage.getOutputScaleY());
    }
}

If mainClass=Launcher, then mvn clean client:build client:run should print: Scale: 1.0, regardless your HiDPI settings.

But if you don't set the system property in the Launcher, running Launcher.exe -Dprism.allowhidpi=false won't work, and it will print Scale: 1.25 (based on your settings).

Can you verify this?

anksty commented 3 years ago

Sorry for the delay. Yes I can verify that. It prints Scale: 1.0 when I set the property to false although the window is actually scaled. If I don't set the property it prints Scale: 1.25.