You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
SDL 3.2.5 (main branch as of 69d2802, built from source)
macOS 15.3
MacBook Air M2, display resolution "default" (1710x1107)
Observed behavior
Opening a window with SDL_WINDOW_RESIZABLE results in a window size 20 pixels shorter and narrower (about the size of a scroll bar, even though none are visible?) than the usable screen space passed to SDL_CreateWindowAndRenderer sourced from SDL_GetDisplayUsableBounds.
I expected SDL_WINDOW_RESIZABLE to not change the initial size of the window. When it's removed, the window uses all available screen space as passed from display_bounds.w and display_bounds.h:
Hard-coding the window height and width values to 1710 x 1068 also results in a smaller window size than expected if SDL_WINDOW_RESIZABLE is used. Hard-coding them to lower values such as 500 x 500 does not result in a size change if SDL_WINDOW_RESIZABLE is used.
Removing SDL_WINDOW_BORDERLESS still results in a gap if SDL_WINDOW_RESIZABLE is used in conjunction with SDL_GetDisplayUsableBounds:
Workarounds
Removing SDL_WINDOW_RESIZABLE works but leaves the window non-resizable (can't use true full-screen).
If I switch to SDL_GetDisplayBounds from SDL_GetDisplayUsableBounds then using SDL_WINDOW_RESIZABLE does not cause size differences, but the height becomes 1107 (full screen height) instead of usable height of 1068 (full height minus the macOS status bar) so the window is taller than it needs to be (losing the top).
I can also launch with SDL_WINDOW_FULLSCREEN but it's not ideal because it doesn't give users a chance to choose monitors, and I'd prefer that they choose to go full screen on their terms.
To reproduce
Run the following:
#defineSDL_MAIN_USE_CALLBACKS#include<SDL3/SDL.h>#include<SDL3/SDL_log.h>#include<SDL3/SDL_main.h>staticSDL_Window*window=NULL;
staticSDL_Renderer*renderer=NULL;
SDL_AppResultSDL_AppInit(void**appstate, intargc, char**argv) {
SDL_Log("Initializing using SDL %d.%d.%d", SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_MICRO_VERSION);
SDL_SetAppMetadata("Demo", "0.1.0", "com.example.demo");
if (!SDL_Init(SDL_INIT_VIDEO)) {
SDL_Log("Couldn't initialize SDL: %s", SDL_GetError());
returnSDL_APP_FAILURE;
}
SDL_DisplayIDdisplay=SDL_GetPrimaryDisplay();
if (display==0) {
SDL_Log("Couldn't get primary display: %s", SDL_GetError());
returnSDL_APP_FAILURE;
}
SDL_Log("Display ID: %u", display);
SDL_Rectdisplay_bounds;
if (!SDL_GetDisplayUsableBounds(display, &display_bounds)) {
SDL_Log("Couldn't get display bounds: %s", SDL_GetError());
returnSDL_APP_FAILURE;
}
SDL_Log("Expected window size: %d, %d", display_bounds.w, display_bounds.h);
// Create window using available display bounds.if (!SDL_CreateWindowAndRenderer(
"Demo app", display_bounds.w, display_bounds.h,
SDL_WINDOW_HIGH_PIXEL_DENSITY | SDL_WINDOW_BORDERLESS | SDL_WINDOW_RESIZABLE, &window, &renderer)) {
SDL_Log("Couldn't create window/renderer: %s", SDL_GetError());
returnSDL_APP_FAILURE;
}
intwindow_width, window_height;
SDL_GetWindowSize(window, &window_width, &window_height);
SDL_Log("Actual window size: %d, %d", window_width, window_height);
returnSDL_APP_CONTINUE;
}
SDL_AppResultSDL_AppIterate(void*appstate) {
SDL_SetRenderDrawColor(renderer, 200, 0, 200, 255);
SDL_RenderClear(renderer);
SDL_RenderPresent(renderer);
returnSDL_APP_CONTINUE;
}
SDL_AppResultSDL_AppEvent(void*appstate, SDL_Event*event) {
if (event->type==SDL_EVENT_QUIT) {
returnSDL_APP_SUCCESS;
}
returnSDL_APP_CONTINUE;
}
voidSDL_AppQuit(void*appstate, SDL_AppResultresult) {
SDL_Log("Quitting");
// SDL cleans up the window and renderer, no need to manually free.
}
The text was updated successfully, but these errors were encountered:
nickcernis
changed the title
[SDL 3.2.5, macOS 15.3] SDL_WINDOW_RESIZABLE results in 20px smaller window width/height than values passed from SDL_GetDisplayUsableBounds
[SDL 3.2.5, macOS 15.3] Window height and width 20px smaller than expected when using SDL_WINDOW_RESIZABLE
Feb 9, 2025
Observed behavior
Opening a window with
SDL_WINDOW_RESIZABLE
results in a window size 20 pixels shorter and narrower (about the size of a scroll bar, even though none are visible?) than the usable screen space passed toSDL_CreateWindowAndRenderer
sourced fromSDL_GetDisplayUsableBounds
.Flags
Snippet (full repro code at the bottom of this report):
❌ Result — empty space around window revealing desktop
Logged output shows the actual window is 20px smaller in width and height than the size I passed to
SDL_CreateWindowAndRenderer
:Expected behavior
I expected
SDL_WINDOW_RESIZABLE
to not change the initial size of the window. When it's removed, the window uses all available screen space as passed from display_bounds.w and display_bounds.h:Flags
Snippet diff:
✅ Result — no empty space around window
And logged sizes match; note that the expected window size has not changed, it's just being honoured now with
SDL_WINDOW_RESIZABLE
removed:Non-workarounds
Adding
SDL_WINDOW_MAXIMIZED
has no effect.Hard-coding the window height and width values to 1710 x 1068 also results in a smaller window size than expected if
SDL_WINDOW_RESIZABLE
is used. Hard-coding them to lower values such as 500 x 500 does not result in a size change ifSDL_WINDOW_RESIZABLE
is used.Removing
SDL_WINDOW_BORDERLESS
still results in a gap ifSDL_WINDOW_RESIZABLE
is used in conjunction withSDL_GetDisplayUsableBounds
:Workarounds
Removing SDL_WINDOW_RESIZABLE works but leaves the window non-resizable (can't use true full-screen).
If I switch to
SDL_GetDisplayBounds
fromSDL_GetDisplayUsableBounds
then usingSDL_WINDOW_RESIZABLE
does not cause size differences, but the height becomes 1107 (full screen height) instead of usable height of 1068 (full height minus the macOS status bar) so the window is taller than it needs to be (losing the top).I can also launch with
SDL_WINDOW_FULLSCREEN
but it's not ideal because it doesn't give users a chance to choose monitors, and I'd prefer that they choose to go full screen on their terms.To reproduce
Run the following:
The text was updated successfully, but these errors were encountered: