On Tue, 3 Jan 2023 05:53:30 GMT, Ambarish Rapte <ara...@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:
> ![Screenshot 2022-12-09 
> 145806](https://user-images.githubusercontent.com/11330676/210305749-d5073945-bfaa-44cc-98eb-172f6b344e22.png)
> 
> Screenshots of some observations:
> 1. 
> ![Screenshot 2022-12-09 
> 144504](https://user-images.githubusercontent.com/11330676/210305790-61530649-eaec-441b-8262-ebd9f7bb877c.png)
> 2.
> ![Screenshot 2022-12-09 
> 144624](https://user-images.githubusercontent.com/11330676/210305822-6b3aa883-bb2f-496d-9a0a-6f95fcffdddb.png)
> 3.
> ![Screenshot 2022-12-09 
> 145645](https://user-images.githubusercontent.com/11330676/210305861-5249ee28-3898-4d5b-8b52-d3e1b3389af2.png)
> 4.
> ![Screenshot 2022-12-09 
> 144722](https://user-images.githubusercontent.com/11330676/210305838-711ddcfa-a3ee-4b35-8b02-f1a510d080f9.png)
> 
> Similar behavior can also be observed if monitors are in landscape mode:
> ![Screenshot 2022-12-09 
> 150231](https://user-images.githubusercontent.com/11330676/210305945-ba171790-4767-4cd2-96c4-2f6fb57b7e50.png)

@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

Reply via email to