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 5320

Summary: Bordersize can't be polled immediately after window creation
Product: SDL Reporter: contact
Component: videoAssignee: Sam Lantinga <slouken>
Status: NEW --- QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2    
Version: 2.0.12   
Hardware: x86_64   
OS: Linux   

Description contact 2020-10-13 13:17:12 UTC
Hello all,

I am currently trying to setup clamping windows to the edges of the screen when they're being created. This is mostly used for popups/context-menus.

My calculations are all fine, however when I pass the variables to `SDL_CreateWindow` the created window sticks out to the right by 2 * the border of the window.
So I tried polling `SDL_GetWindowBordersSize`. This however always sets all variables to 0 (and returns 0 as well so it's successful) if polled immediately after the window creation. 
After some digging I figured out that this has to do with the fact that SDL doesn't post a `_NET_REQUEST_FRAME_EXTENTS` to the window manager during window creation.

I believe this to be a bug since it appears that SDL internally also takes this into account. If I just call `SDL_CreateWindow(args)` the window sticks out to the right. If I add a `std::this_thread::sleep_for(50ms)` after the window creation it is properly aligned at the right screen edge without any overhang. This seemingly indicates that SDL wants to take the border-size into account but can't because the values aren't there yet since they haven't been requested from the WM.

sincerely,
Folling
Comment 1 contact 2020-10-14 09:57:24 UTC
I just noticed this only happens if I call `SDL_ShowWindow` shortly after the window's creation. Not doing that resolves the issue. I presume this might be because it forces SDL to show the window before the frame extents information is polled.