On Thu, 20 Oct 2022 16:02:46 GMT, Andy Goryachev <ango...@openjdk.org> wrote:

>> Johan Vos has updated the pull request incrementally with one additional 
>> commit since the last revision:
>> 
>>   address reviewer comments
>>   Fix detection on screen, based on awtScale factors
>
> modules/javafx.swing/src/main/java/javafx/embed/swing/JFXPanel.java line 375:
> 
>> 373:         AffineTransform awtScales = 
>> graphicsConfiguration.getDefaultTransform();
>> 374:         for (Screen screen : Screen.getScreens()) {
>> 375:             if ((Math.abs(screen.getPlatformX() - awtBounds.getX() * 
>> awtScales.getScaleX()) < 0.001) &&
> 
> minor: would it be better to create a standard method?
> 
> isNearZero(double)?
> 
> although the value of the constant might depend on a situation.

it's a good question, and I don't know the "best" answer. What we want to 
achieve here is to get the FX Screen that matches the AWT 
graphicsConfiguration. I *assume* that the `screen.getPlatformX()` being equal 
to the `bounds.getX()` etc, but I have no evidence for it. I could not find 
clear definitions of either the JavaFX Screen parameters nor the AWT concepts. 
In practice, the approach above (which I tweaked because at least on my Ubuntu, 
there are differences between the JavaFX platformScale and the AWT scales) 
works correctly. However, as I don't see any clear definition, I think it is 
safe to account for rounding errors (given the mixture of int, float, doubles 
that are used in the different areas).

> modules/javafx.swing/src/main/java/javafx/embed/swing/JFXPanel.java line 385:
> 
>> 383:     }
>> 384: 
>> 385:     private Dimension2D getSwingToFxPixel(GraphicsConfiguration g, 
>> float wx, float wy) {
> 
> minor: convertSwingToFxPixel() ?

done.

-------------

PR: https://git.openjdk.org/jfx/pull/924

Reply via email to