RFR: 6899304 : java.awt.Toolkit.getScreenInsets(GraphicsConfiguration) returns incorrect values [v2]

Harshitha Onkar honkar at openjdk.org
Thu Jan 23 23:34:46 UTC 2025


On Thu, 23 Jan 2025 22:29:22 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 one additional commit since the last revision:
> 
>   Update copyright

src/java.desktop/windows/native/libawt/windows/awt_Toolkit.cpp line 1940:

> 1938: {
> 1939:     MONITORINFO *miInfo = AwtWin32GraphicsDevice::GetMonitorInfo(screenNum);
> 1940:     if (miInfo) {

Based on [GetMonitorInfo](https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getmonitorinfoa) API doc, it seems fine to use this API to query monitor info for both primary and non-primary monitors but I'm not sure why original code used `SystemParametersInfo()`  specifically instead of `GetMonitorInfo()` for primary monitor.

In case the screen insets need to be calculated differently for primary and non-primary then MonitorInfo (`miInfo.dwFlag`) can be used to check if it is primary monitor or not, instead of relying on screen number as follows 


MONITORINFO *miInfo = AwtWin32GraphicsDevice::GetMonitorInfo(screenNum);

if (MONITORINFOF_PRIMARY & miInfo ->dwFlags) {
// calculate screen insets for Primary monitor
}
else {
//calculate screen insets for NON-Primary monitor
}

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/23183#discussion_r1927818392


More information about the client-libs-dev mailing list