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

Summary: SDL_GetWindowBordersSize() includes drop shadow on Windows
Product: SDL Reporter: Michel Rouzic <sdl>
Component: videoAssignee: Sam Lantinga <slouken>
Status: NEW --- QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2 CC: sezeroz
Version: HG 2.0   
Hardware: x86_64   
OS: Windows 10   

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.