From af733c7a3269bfd8a65a1e7bdeea3e13934c0a75 Mon Sep 17 00:00:00 2001 From: Pieter-Jan Briers Date: Mon, 20 Jun 2022 02:26:40 +0200 Subject: [PATCH] Fix DPI-raised SDL_WINDOWEVENT_SIZE_CHANGED with event callback. Move the sending of this event down so stuff like calling SDL_GL_GetDrawableSize() from a callback reports the new size instead of the old one. --- src/video/windows/SDL_windowsevents.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/video/windows/SDL_windowsevents.c b/src/video/windows/SDL_windowsevents.c index 69f6d14a2..f3ed588d8 100644 --- a/src/video/windows/SDL_windowsevents.c +++ b/src/video/windows/SDL_windowsevents.c @@ -1534,15 +1534,6 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) suggestedRect->left, suggestedRect->top, suggestedRect->right - suggestedRect->left, suggestedRect->bottom - suggestedRect->top); #endif - if (data->videodata->dpi_scaling_enabled) { - /* Update the cached DPI value for this window */ - data->scaling_dpi = newDPI; - - /* Send a SDL_WINDOWEVENT_SIZE_CHANGED saying that the client size (in dpi-scaled points) is unchanged. - Renderers need to get this to know that the framebuffer size changed. */ - SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_SIZE_CHANGED, data->window->w, data->window->h); - } - if (data->expected_resize) { /* This DPI change is coming from an explicit SetWindowPos call within SDL. Assume all call sites are calculating the DPI-aware frame correctly, so @@ -1603,6 +1594,16 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) h, SWP_NOZORDER | SWP_NOACTIVATE); data->expected_resize = SDL_FALSE; + + if (data->videodata->dpi_scaling_enabled) { + /* Update the cached DPI value for this window */ + data->scaling_dpi = newDPI; + + /* Send a SDL_WINDOWEVENT_SIZE_CHANGED saying that the client size (in dpi-scaled points) is unchanged. + Renderers need to get this to know that the framebuffer size changed. */ + SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_SIZE_CHANGED, data->window->w, data->window->h); + } + return 0; } break;