Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SDL_SetWindowMinimumSize having no effect before creating renderer (same with SDL_SetWindowMaximumSize) #1408

SDLBugzilla opened this issue Feb 10, 2021 · 0 comments


Copy link

SDLBugzilla commented Feb 10, 2021

This bug report was migrated from our old Bugzilla tracker.

These attachments are available in the static archive:

Reported in version: HG 2.0
Reported for operating system, platform: Linux, x86_64

Comments on the original bug report:

On 2014-03-18 21:05:07 +0000, wrote:

Created attachment 1594
Test cases

A window can be resized to out-ot-bounds dimensions even if any of SDL_SetWindowMinimumSize and SDL_SetWindowMaximumSize is called, given the following steps are done in the given order:

  • First, the window is created without the SDL_WINDOW_OPENGL flag set.
  • Then SDL_SetWindowMinimumSize and/or SDL_SetWindowMaximumSize are/is called.
  • Afterwards a new renderer is created.

Sample code is attached with a test case. By playing with a few definitions given at the top of the code you can generate a few more tests:

  • Manage a GL context directly (SDL_GL_CreateContext) or access an SDL 1.2 style window surface (SDL_GetWindowSurface), rather than using a renderer (SDL_CreateRenderer).
  • Set window bounds after calling any of these (say SDL_CreateRenderer) rather than before.
  • Optionally add SDL_WINDOW_OPENGL as a flag on window creation.

A few gotchas that should be added for the various cases:

  • An OpenGL context cannot be created without SDL_WINDOW_OPENGL. I have added a compile-time error shown upon an attempt to do so.
  • If the window bounds are set after the call to SDL_GetWindowSurface, then the surface gets invalidated and a new surface should be retrieved again (I suppose that's the expected behavior).
  • As in the case of SDL_CreateRenderer, if the bounds are set before the (only) call to SDL_GetWindowSurface then the window can be resized to out-of-bounds dimensions.

In addition:

  • If the hint SDL_HINT_RENDER_DRIVER is set to "software" before the call to SDL_Hint is done (say by setting the environment variable SDL_RENDER_DRIVER to the same value), then the bounds hold (with the same code as originally attached to this bug report).
  • The latter point applies if a window surface is used, too.

On 2015-02-19 05:22:22 +0000, Ryan C. Gordon wrote:

Marking a large number of bugs with the "triage-2.0.4" keyword at once. Sorry if you got a lot of email from this. This is to help me sort through some bugs in regards to a 2.0.4 release. We may or may not fix this bug for 2.0.4, though!

On 2016-01-31 14:27:08 +0000, Rafał Mużyło wrote:

I think I see a related problem.

This seems to be a case of unintended side-effects, that are beneficial here.

SDL_WINDOW_OPENGL is the flag that has those side-effects.

Another test would be to create a FULLSCREEN_DESKTOP window smaller than the desktop.

If you unset fullscreen, the window will still have the size of the desktop.

If SDL_WINDOW_OPENGL is set, once again, the window is restored to its expected size.

@slouken slouken removed the bug label May 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
None yet

No branches or pull requests

2 participants