Skip to content

Improve Shell#getLocation OS calls #307

@akoch-yatta

Description

@akoch-yatta

Description
Shell#getLocation is currently returning coordinates outside of the monitor, when the window is maximized (at least for Windows 11). We could replace This call by replace GetWindowRect with DwmGetWindowAttribute that returns a better location in this case.

Reproduction

--

Expected Behavior

If the location of a shell is fetched via the API, the given location should always be assigned to the monitor it is assigned to from the OS.

Necessary configuration:

--

Additional knowledge

As DwmGetWindowAttribute return different types for different attributes, we probably need to have a more sophisticated approach in OS.java for this, simple test was done with:

/**
 * @param hwnd cast=(HWND)
 * */
public static final native void DwmGetWindowAttribute (long hwnd, int dwAttribute, RECT pvAttribute, int cbAttribute);

and then called with

RECT rect = new RECT();
OS.DwmGetWindowAttribute(handle, 9, rect, RECT.sizeof);

For more information see https://learn.microsoft.com/en-us/windows/win32/api/dwmapi/nf-dwmapi-dwmgetwindowattribute

Metadata

Metadata

Labels

HiDPIA HiDPI-Related Issue or FeatureSWTIssue for SWT

Type

No type

Projects

Status

🏗 In Work: Short

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions