render: Update the size/scale/viewport on moves, in addition to resizes.

For OpenGL this means resetting the viewport state shadowing flag too.

Fixes #1504
This commit is contained in:
Ethan Lee 2022-04-08 02:21:52 -04:00 committed by Sam Lantinga
parent 5613a56032
commit cb81630816
2 changed files with 26 additions and 8 deletions

View file

@ -698,7 +698,17 @@ SDL_RendererEventWatch(void *userdata, SDL_Event *event)
renderer->WindowEvent(renderer, &event->window);
}
if (event->window.event == SDL_WINDOWEVENT_SIZE_CHANGED) {
/* In addition to size changes, we also want to do this block for
* moves as well, for two reasons:
*
* 1. The window could be moved to a new display, which has a new
* DPI and therefore a new window/drawable ratio
* 2. For whatever reason, the viewport can get messed up during
* window movement (this has been observed on macOS), so this is
* also a good opportunity to force viewport updates
*/
if (event->window.event == SDL_WINDOWEVENT_SIZE_CHANGED ||
event->window.event == SDL_WINDOWEVENT_MOVED) {
/* Make sure we're operating on the default render target */
SDL_Texture *saved_target = SDL_GetRenderTarget(renderer);
if (saved_target) {