RFR: 8269374: Menu inoperable after setting stage to second monitor
Jose Pereda
jpereda at openjdk.java.net
Sat Jul 17 11:49:55 UTC 2021
On Thu, 15 Jul 2021 15:48:18 GMT, Ambarish Rapte <arapte at 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.
>
> I tested the fix with different scaling combinations, the issue reported in JBS does not occur with fix. But noticed a similar issue that occurs only if the primary screen is in landscape mode and external monitor is in portrait mode. This behavior is observed both with and without this change. The behavior may be unrelated to fix, in that it can be addressed separately.
> @kevinrushforth request you to take look and call on this.
>
> Steps:
> 1. Primary screen, 125%, Landscape mode
> 2. Secondary screen, 100%, Portrait mode
> 3. Run the program attached to JBS
> 4. Move the Stage to secondary screen
> 5. Maximize Stage
> 6. Keep focus on the Stage and press Windows + Shift + Left key
> 7. Stage will be moved to primary screen
> 8. Click on menu, observe that location is not correct. Below is screenshot.
>
> 
>
> ----
> A slight different behavior can be observed with a change in step 6
> Follow same steps as above except at step 6: Click 'Change screen' button. Below is the screenshot
>
> 
I can reproduce the issues mentioned by @arapte.
Even with two landscape screens, if you maximise (or just make it big enough) the app on the 100% monitor, and click the button to move it to the other, the app doesn't move correctly, stays more or less to the middle (with wrong scale), but menus location and scale are correct:
<img width="1920" alt="winIssue" src="https://user-images.githubusercontent.com/2043230/126035806-7be3f246-dd91-4aec-bd82-075adc25e745.png">
This issues probably require their own follow-up JBS?
-------------
PR: https://git.openjdk.java.net/jfx/pull/572
More information about the openjfx-dev
mailing list