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.

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

Commit messages:
 - Use public method
 - Force view relocation on Windows after a resize event

Changes: https://git.openjdk.java.net/jfx/pull/572/files
 Webrev: https://webrevs.openjdk.java.net/?repo=jfx&pr=572&range=00
  Issue: https://bugs.openjdk.java.net/browse/JDK-8269374
  Stats: 9 lines in 1 file changed: 9 ins; 0 del; 0 mod
  Patch: https://git.openjdk.java.net/jfx/pull/572.diff
  Fetch: git fetch https://git.openjdk.java.net/jfx pull/572/head:pull/572

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

Reply via email to