diff --git a/src/modules/event/sdl/Event.cpp b/src/modules/event/sdl/Event.cpp index 8da897f60..bee8090af 100644 --- a/src/modules/event/sdl/Event.cpp +++ b/src/modules/event/sdl/Event.cpp @@ -822,6 +822,37 @@ Message *Event::convertWindowEvent(const SDL_Event &e) vargs.emplace_back(event == SDL_EVENT_WINDOW_SHOWN); msg = new Message("visible", vargs); break; +#if SDL_VERSION_ATLEAST(3, 0, 0) + case SDL_EVENT_WINDOW_PIXEL_SIZE_CHANGED: + { + double width = e.window.data1; + double height = e.window.data2; + + gfx = Module::getInstance(Module::M_GRAPHICS); + win = Module::getInstance(Module::M_WINDOW); + if (win) + win->onSizeChanged(e.window.data1, e.window.data2); + + // The size values in the Window aren't necessarily the same as the + // graphics size, which is what we want to output. + if (gfx) + { + width = gfx->getWidth(); + height = gfx->getHeight(); + } + else if (win) + { + width = win->getWidth(); + height = win->getHeight(); + windowToDPICoords(&width, &height); + } + + vargs.emplace_back(width); + vargs.emplace_back(height); + msg = new Message("resize", vargs); + } + break; +#else case SDL_EVENT_WINDOW_RESIZED: { double width = e.window.data1; @@ -855,6 +886,7 @@ Message *Event::convertWindowEvent(const SDL_Event &e) if (win) win->onSizeChanged(e.window.data1, e.window.data2); break; +#endif case SDL_EVENT_WINDOW_MINIMIZED: case SDL_EVENT_WINDOW_RESTORED: #ifdef LOVE_ANDROID diff --git a/src/modules/window/sdl/Window.cpp b/src/modules/window/sdl/Window.cpp index 1a7580d28..f0da854f8 100644 --- a/src/modules/window/sdl/Window.cpp +++ b/src/modules/window/sdl/Window.cpp @@ -808,7 +808,7 @@ bool Window::onSizeChanged(int width, int height) #endif #if SDL_VERSION_ATLEAST(3, 0, 0) - if (SDL_GetWindowSizeInPixels(window, &pixelWidth, &pixelHeight)) + if (!SDL_GetWindowSizeInPixels(window, &pixelWidth, &pixelHeight)) #else // TODO: Use SDL_GetWindowSizeInPixels here when supported. if (glcontext != nullptr)