Request to rethink Window position/size in SDL

At the moment SDL_SetWindowPos(x,y) and SDL_SetWindowSize(x,y) use window client coordinates, at least on Windows and Mac.

That appears as conceptually wrong for many reasons. Both these functions, as their SDL_Get… counterparts shall rather use window border frame coordinates (window border box placement on screen).

Window border frame is the only reliable and invariant metric of window geometry that OS GUI provides.

On Windows for example, client area (reported by GetClientRect) can be changed at runtime by calling DwmExtendFrameIntoClientArea. MacOS has similar mechanism, GTK too.

If someone needs window client screen position then SDL_GetWindowBordersSize() can be used to get actual offsets of client area from window border box.

This allows to remove all calls of AdjustWindowRectEx() from source code as almost all of them are used inappropriately right now. The only place where AdjustWindowRectEx() can be used is
some new SDL_GetSuggestedWindowBordersSize() that will return OS preferences for such type of window.

SDL_EVENT_WINDOW_RESIZED event shall report window frame dimensions.
and SDL_EVENT_WINDOW_PIXEL_SIZE_CHANGED shall report client dimensions (user drawable area of the window).

Use of window frame border is also the must if SDL_SetWindowPos(x,y) and SDL_SetWindowSize(x,y) are used for persisting window position between sessions. Use of client coordinates is unacceptable in such cases as user may change desktop theme in between store/restore.

1 Like