We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 5302 - SDL_GetWindowBordersSize() includes drop shadow on Windows
Summary: SDL_GetWindowBordersSize() includes drop shadow on Windows
Status: NEW
Alias: None
Product: SDL
Classification: Unclassified
Component: video (show other bugs)
Version: HG 2.0
Hardware: x86_64 Windows 10
: P2 normal
Assignee: Sam Lantinga
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-09-27 22:14 UTC by Michel Rouzic
Modified: 2020-10-18 10:38 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Michel Rouzic 2020-09-27 22:14:56 UTC
WIN_GetWindowBordersSize() relies on GetWindowRect() to get the rectangle of the outer window. The problem with this as MSDN explains is that this rectangle "includes the area occupied by the drop shadow", which is why I get 31 8 8 8 when clearly there isn't 8 px of visual border. So instead of:
GetWindowRect(hwnd, &rcWindow);
we should use:
DwmGetWindowAttribute(hwnd, DWMWA_EXTENDED_FRAME_BOUNDS, &rcWindow, sizeof(rcWindow));

When my window is maximised this gives me 23 0 0 0 and when it's not I get 31 1 1 1, which seems to be exactly what it should be. Note that you might need to add something to the effect of the following to make it work:
#include <dwmapi.h>
#pragma comment (lib, "Dwmapi.lib")

Btw the SDL wiki hasn't been updated to reflect that SDL_GetWindowBordersSize() works on Windows.