| Summary: | SDL_WINDOWEVENT_RESIZED can have incorrect window data returning from full screen | ||
|---|---|---|---|
| Product: | SDL | Reporter: | buckyballreaction |
| Component: | video | Assignee: | Sam Lantinga <slouken> |
| Status: | RESOLVED INVALID | QA Contact: | Sam Lantinga <slouken> |
| Severity: | normal | ||
| Priority: | P2 | CC: | vitto.giova |
| Version: | 2.0.0 | Keywords: | target-2.0.0 |
| Hardware: | All | ||
| OS: | Windows (All) | ||
| Attachments: | test case | ||
OK, so I find that the data is not incorrect in the SDL_WINDOWEVENT_RESIZED event. This is what happens. First some facts: - Our game handles the SDL_WINDOWEVENT_RESIZED event and calls SDL_SetWindowSize() in it (like when resizing the window) - SDL_SetWindowFullscreen() internally sends a SDL_WINDOWEVENT_RESIZED event with the data1 and data2 being the fullscreen window with window decorations - SDL_SetWindowSize() does not send the SDL_WINDOWEVENT_RESIZED event (by design) and resizes the window immediately With those findings, this is roughly the flow of how the problem manifests itself when using SDL_SetWindowSize() immediately following SDL_SetWindowFullscreen(): 1. SDL_SetWindowFullscreen(window, FALSE) comes out of fullscreen and adds SDL_WINDOWEVENT_RESIZED to event queue 2. SDL_SetWindowSize(window, 800, 600) changes our window to a desired resolution 3. The SDL_WINDOWEVENT_RESIZED in the event queue is now triggered in our Event loop which then calls SDL_SetWindowSize() on the resolution again, putting back the resolution to what SDL_SetWindowFullscreen(window, FALSE) would output So I guess I would need to code a flag somewhere that either discards the SDL_WINDOWEVENT_RESIZED sent by the fullscreen change; or, call SDL_SetWindowSize() elsewhere, after the SDL_WINDOWEVENT_RESIZED from the fullscreen change is processed. Unless, there is some other way to change to the resolution directly that I want after coming out of fullscreen? (Sorry if you get a lot of copies of this email, we're touching dozens of bug reports right now.) Tagging a bunch of bugs as target-2.0.0, Priority 2. This means we're in the final stretch for an official SDL 2.0.0 release! These are the bugs we really want to fix before shipping if humanly possible. That being said, we don't promise to fix them because of this tag, we just want to make sure we don't forget to deal with them before we bless a final 2.0.0 release, and generally be organized about what we're aiming to ship. Hopefully you'll hear more about this bug soon. If you have more information (including "this got fixed at some point, nevermind"), we would love to have you come add more information to the bug report when you have a moment. Thanks! --ryan. |
Created attachment 1181 [details] test case The SDL_WINDOWEVENT_RESIZED event that is triggered when returning from full screen to windowed mode can have incorrect window width and height in it if you do the following: 1. Trigger a change from fullscreen to windowed mode like so: SDL_SetWindowFullscreen(window, SDL_FALSE); SDL_SetWindowSize(window, 800, 600); 2. In your event loop, when handling the SDL_WINDOWEVENT_RESIZED event triggered by the SDL_SetWindowFullscreen() above, you'll see that event->window.data1 and event->window.data2 are not set to 800 and 600, but is instead set to full screen window size minus the window decorations (roughly). This happens on at least Windows XP and Windows 7. I attached a test-case. It may be a little more complicated than needed, but it follows our game logic with fullscreen modes. Press ALT + ENTER to switch modes Might I be using SDL_SetWindowSize improperly in this case?