Selaa lähdekoodia

Unscale the window size on resize if we are doing automatic HighDPI scaling.

Jeffery Myers 6 kuukautta sitten
vanhempi
commit
4bed3741c1

+ 7 - 1
src/platforms/rcore_desktop_glfw.c

@@ -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;
 

+ 13 - 2
src/platforms/rcore_desktop_rgfw.c

@@ -1033,8 +1033,19 @@ void PollInputEvents(void)
             case RGFW_windowResized:
             {
                 SetupViewport(platform.window->r.w, platform.window->r.h);
-                CORE.Window.screen.width = platform.window->r.w;
-                CORE.Window.screen.height =  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;

+ 11 - 2
src/platforms/rcore_desktop_sdl.c

@@ -1451,8 +1451,17 @@ void PollInputEvents(void)
                         const int width = event.window.data1;
                         const int height = event.window.data2;
                         SetupViewport(width, height);
-                        CORE.Window.screen.width = width;
-                        CORE.Window.screen.height = 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;