Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows: get/setWindowSize include drop shadow area #289

Open
tonsky opened this issue Feb 20, 2024 · 1 comment
Open

Windows: get/setWindowSize include drop shadow area #289

tonsky opened this issue Feb 20, 2024 · 1 comment
Labels
Good First Issue Good for newcomers Help Wanted Extra attention is needed Platform: Windows

Comments

@tonsky
Copy link
Collaborator

tonsky commented Feb 20, 2024

They shouldn’t. We want window bounds excluding the drop shadow, both for getting and setting window position and size.

https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getwindowrect#return-value

Screenshot 2024-02-20 at 22 08 21

@Quezion
Copy link
Contributor

Quezion commented Feb 21, 2024

I'm working on this now as part of #286 -- it might take me some days to get the PR ready, but this local code seems to work.

RECT jwm::WindowWin32::_getWindowRectSimple() const {
    RECT rect;
    // TODO: continue using old implementation if "OS major version is < 6" (Vista)
    // GetWindowRect(_hWnd, &rect);
    DwmGetWindowAttribute(_hWnd, DWMWA_EXTENDED_FRAME_BOUNDS, &rect, sizeof(rect));
    return rect;
}

jwm::IRect jwm::WindowWin32::getWindowRect() const {
    RECT rect = _getWindowRectSimple();
    return IRect{rect.left, rect.top, rect.right, rect.bottom};
}

I've replaced all calls to winAPI GetWindowRect with the internal getWindowRectSimple & this is working so far.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Good First Issue Good for newcomers Help Wanted Extra attention is needed Platform: Windows
Development

No branches or pull requests

2 participants