On Mon, 12 Jul 2021 12:46:10 GMT, Jose Pereda <jper...@openjdk.org> wrote:

> On Windows, with two monitors with different DPI settings, if a JavaFX 
> application changes screens (either by dragging or programmatically) there is 
> a resize event to adjust the view to its new platform scale.
> 
> Note that there is already a 
> [call](https://github.com/openjdk/jfx/blob/master/modules/javafx.graphics/src/main/java/com/sun/glass/ui/win/WinWindow.java#L206)
>  to `View::updateLocation` in WinWindow, right after 
> `notifyMoveToAnotherScreen` and `notifyScaleChanged `. But this is done too 
> soon, before the resize event. There are other MOVE events processed too (in 
> a long complex chain of recursive calls to `WinWindow::setBounds`).
> 
> As a consequence, as commented in the issue 
> [JDK-8269374](https://bugs.openjdk.java.net/browse/JDK-8269374), the view x/y 
> coordinates are wrongly set using the _old_ X,Y values (from the previous 
> screen) with the _new_ platform scale (from the new screen).
> 
> This PR adds an extra call to View::updateLocation` in WinWindow, forcing the 
> view relocation on Windows after every resize event to fix the issue. With 
> the correct location of the scene, the Menus are now perfectly aligned, and 
> the mouse events are correctly processed. It doesn't have any side effect on 
> other platforms.
> 
> There's a very small penalty, as this new relocation will be called whenever 
> there is a resize event on Windows, but it simplifies the overhead of 
> detecting when the change of screens is effectively done (including the chain 
> of move/resize) events.
> 
> No tests are provided, since these would require a setup of two monitors with 
> different DPI settings. However, the test case in the JBS issue can be used 
> to validate the fix.

This seems like a correct fix. I can test it along with a formal review. Even 
though it is a small change in terms of lines of code, I'd like a second 
reviewer.

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

PR: https://git.openjdk.java.net/jfx/pull/572

Reply via email to