Merge pull request #4836 from JeffM2501/unscale_on_resize

[rcore] Correctly handle window size on resize in auto-scaled HIGHDPI environment
This commit is contained in:
Ray 2025-03-14 17:15:14 +01:00 committed by GitHub
commit 2f63a15630
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 89 additions and 63 deletions

View file

@ -1753,8 +1753,14 @@ static void WindowSizeCallback(GLFWwindow *window, int width, int height)
if (IsWindowFullscreen()) return;
// Set current screen size
// if we are doing automatic DPI scaling, then the "screen" size is divided by the window scale
if (IsWindowState(FLAG_WINDOW_HIGHDPI))
{
width = (int)(width / GetWindowScaleDPI().x);
height = (int)(height / GetWindowScaleDPI().y);
}
// Set current screen size
CORE.Window.screen.width = width;
CORE.Window.screen.height = height;

View file

@ -1033,8 +1033,19 @@ void PollInputEvents(void)
case RGFW_windowResized:
{
SetupViewport(platform.window->r.w, platform.window->r.h);
// if we are doing automatic DPI scaling, then the "screen" size is divided by the window scale
if (IsWindowState(FLAG_WINDOW_HIGHDPI))
{
CORE.Window.screen.width = (int)(platform.window->r.w / GetWindowScaleDPI().x);
CORE.Window.screen.height = (int)(platform.window->r.h / GetWindowScaleDPI().y);
}
else
{
CORE.Window.screen.width = platform.window->r.w;
CORE.Window.screen.height = platform.window->r.h;
}
CORE.Window.currentFbo.width = platform.window->r.w;
CORE.Window.currentFbo.height = platform.window->r.h;
CORE.Window.resizedLastFrame = true;

View file

@ -1451,8 +1451,17 @@ void PollInputEvents(void)
const int width = event.window.data1;
const int height = event.window.data2;
SetupViewport(width, height);
// if we are doing automatic DPI scaling, then the "screen" size is divided by the window scale
if (IsWindowState(FLAG_WINDOW_HIGHDPI))
{
CORE.Window.screen.width = (int)(width / GetWindowScaleDPI().x);
CORE.Window.screen.height = (int)(height / GetWindowScaleDPI().y);
}
else
{
CORE.Window.screen.width = width;
CORE.Window.screen.height = height;
}
CORE.Window.currentFbo.width = width;
CORE.Window.currentFbo.height = height;
CORE.Window.resizedLastFrame = true;