Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8270868

[Windows] Moving a stage from one monitor to another fails if it expands over both



    • Type: Bug
    • Status: Open
    • Priority: P4
    • Resolution: Unresolved
    • Affects Version/s: openjfx11, openjfx16
    • Fix Version/s: tbd
    • Component/s: javafx
    • Labels:
    • Subcomponent:
    • CPU:
    • OS:


      On Windows, with two monitors with different DPI settings. When the app is in the monitor with 100% and the stage is big enough, when it is translated to the origin of the other monitor with higher DPI, not by dragging but programmatically, the window stops at a given x value almost close to the centre of the screen (see attached picture), while the scene coordinates are correctly located. Therefore, the menu shows up at the correct location, but the stage is actually far away.

      In the process, Screen::toPlatformX is firstly used to find out a coordinate of the "best platform location".

      For instance, given two monitors 1920x1080, main left DPI 150%, secondary right DPI 100%, with the app at the second one (1920x0). When moving to the first one, platformX is estimated as 1920+(0-1280)*1.0) = 640 pixels (note that 1280 comes from 1920/1.5), and the window is actually moved there (640,0), but then there is a WinWindow::notifyMoving call where the first screen is identified, and WinWindow::notifiyMoveToAnotherScreen is called, so finally the proper location at (0,0) is set.

      However, when the window is too big, the first call to platformX gives 640 pixels, the window is moved to (640, 0) as before, but at that point the stage still expands in both screens, so when Screen::portionIntersectsPlatformRect returns < 0.6f [1] (as the second screen still contains part of window), "bestScreen" doesn't change, and the call to notifiyMoveToAnotherScreen is not done, the update process ends there, with the window at (640,0).

      As the stage X,Y coordinates were set to 0,0 (this is why the menu popup is displayed "correctly" at the position it was supposed to be), there is a mismatch with the rendered/presentableState (640,0).

      To reproduce the issue, run the attached test with two monitors (one 150% DPI for instance, the other 100%), click the button to move to the 100% DPI monitor, enlarge the app nearly as full screen, and then click the button to move to the 150% DPI monitor. The stage will stay at a centred position.

      Tested on Windows with JavaFX from 11 to latest 17-ea.

      [1]: https://github.com/openjdk/jfx/blob/master/modules/javafx.graphics/src/main/java/com/sun/glass/ui/win/WinWindow.java#L190




            Unassigned Unassigned
            jpereda Jose Pereda
            0 Vote for this issue
            1 Start watching this issue