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 2453 - SDL_SetWindowMinimumSize having no effect before creating renderer (same with SDL_SetWindowMaximumSize)
Summary: SDL_SetWindowMinimumSize having no effect before creating renderer (same with...
Status: NEW
Alias: None
Product: SDL
Classification: Unclassified
Component: video (show other bugs)
Version: HG 2.0
Hardware: x86_64 Linux
: P2 normal
Assignee: Sam Lantinga
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-03-18 21:05 UTC by ny00
Modified: 2016-01-31 15:42 UTC (History)
1 user (show)

See Also:


Attachments
Test cases (3.84 KB, text/x-csrc)
2014-03-18 21:05 UTC, ny00
Details

Note You need to log in before you can comment on or make changes to this bug.
Description ny00 2014-03-18 21:05:07 UTC
Created attachment 1594 [details]
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.
Comment 1 Ryan C. Gordon 2015-02-19 05:22:22 UTC
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!
Comment 2 Rafał Mużyło 2016-01-31 14:27:08 UTC
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.