RFR: 6899304 : java.awt.Toolkit.getScreenInsets(GraphicsConfiguration) returns incorrect values [v6]
Alexey Ivanov
aivanov at openjdk.org
Tue Jan 28 11:39:47 UTC 2025
On Mon, 27 Jan 2025 14:25:08 GMT, anass baya <duke at openjdk.org> wrote:
>> Screen number 0 is not always the primary screen, so we’ve removed the code that assumes it is.
>>
>> We used an existing test and took the following considerations into account for Windows:
>>
>> - On Windows, undecorated maximized frames are placed over the taskbar.
>> - On Windows, the top-left corner of an undecorated maximized frame may have negative coordinates (x, y).
>> - Consider the fractional part after scaling.
>
> anass baya has updated the pull request incrementally with three additional commits since the last revision:
>
> - Reduce the line length
>
> Co-authored-by: Alexey Ivanov <alexey.ivanov at oracle.com>
> - Reduce the line length
>
> Co-authored-by: Alexey Ivanov <alexey.ivanov at oracle.com>
> - add "@build jdk.test.lib.Platform jtreg.SkippedException"
>
> Co-authored-by: Alexey Ivanov <alexey.ivanov at oracle.com>
The updated test `MultiScreenInsetsTest.java` fails for me on Windows:
bounds: java.awt.Rectangle[x=0,y=0,width=1920,height=1080]
frameBounds: java.awt.Rectangle[x=-7,y=-7,width=1933,height=1045]
adjusted: java.awt.Rectangle[x=0,y=0,width=1919,height=1031]
marginX = 0, marginY 0
Exception in thread "main" java.lang.RuntimeException: Test FAILED! Wrong screen #0 insets: java.awt.Insets[top=0,left=0,bottom=48,right=0]
at MultiScreenInsetsTest.main(MultiScreenInsetsTest.java:113)
I added some debug prints to the test. Both width and height are 1 pixel off. I'm pretty sure it's due to scaling.
You tried to take this fact into account, yet it doesn't seem to work reliably in all the cases… and rounding error could accumulate.
Probably, we can tolerate a 1-pixel difference from what is expected.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/23183#issuecomment-2618750856
More information about the client-libs-dev
mailing list