RFR: 8251862: Wrong position of Popup windows at the intersection of 2 screens [v2]
Kevin Rushforth
kcr at openjdk.org
Wed Jan 4 23:39:59 UTC 2023
On Tue, 3 Jan 2023 05:53:30 GMT, Ambarish Rapte <arapte at openjdk.org> wrote:
>> Kevin Rushforth has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains two additional commits since the last revision:
>>
>> - Merge remote-tracking branch 'origin/master' into 8251862-multi-screen-popup
>> - 8251862: Wrong position of Popup windows at the intersection of 2 screens
>
> I noticed some wrong position of menu popup when tested with 2 external monitors.
> I have a monitors configured in portrait mode as:
> 
>
> Screenshots of some observations:
> 1.
> 
> 2.
> 
> 3.
> 
> 4.
> 
>
> Similar behavior can also be observed if monitors are in landscape mode:
> 
@arapte Thanks for the additional testing and screenshots. This is similar to what I see, but it is helpful to have the additional configuration to confirm this.
To summarize, this PR fixes the Windows-specific screen scale bug reported in [JDK-8251862](https://bugs.openjdk.org/browse/JDK-8251862) by always taking the screen scales for popups windows from their owner window. This fixes most, but not all of the multi-screen problems when the screen scales are different.
The remaining issues seen in testing are in the code that adjusts the position of the popup to keep it on the same screen as the anchor. It is a separate issue, even though it presents in a similar manner. It is not platform-specific, so we need to test any changes in this code on other platforms.
As a note, I pushed some debugging changes to a new [`test-8251862-multi-screen-popup`](https://github.com/kevinrushforth/jfx/tree/test-8251862-multi-screen-popup) branch. This temporarily adds a system property, `com.sun.javafx.popup.autofix`, to override the autofix logic, which is responsible for keeping popup controls on the same screen. With this set to `false`, popups appear in the correct location, which supports the theory that the remaining problem is in the repositioning code. One exception to this is that the first time a context menu is opened from a TextArea, it is still positioned incorrectly, even when running with `-Dcom.sun.javafx.popup.autofix=false`, so there must be some other code that does a position adjustment besides the two places I modified.
The root cause of this new problem is that the coordinates of the anchor to be adjusted are scaled using the screen that most of the parent window is on (i.e., the "first" screen), while the bounds of the "second" screen that the anchor is on are relative to the scale of that screen. A likely fix for this problem is to adjust the bounds of the screen by the ratio of the two screen scales before comparing the coordinates with the screen bounds, but this might be somewhat tricky.
-------------
PR: https://git.openjdk.org/jfx/pull/971
More information about the openjfx-dev
mailing list