From 9f59089de1d606bb698cdcc93c90e37daca5f780 Mon Sep 17 00:00:00 2001 From: Nicholas Velten Date: Sat, 12 Sep 2026 05:54:30 -0300 Subject: [PATCH] [rcore][GLFW] Fix window centering overflow with unsigned screen size (#6119) CORE.Window.screen/render sizes are unsigned, so the subtraction against the monitor workarea wraps when the window is larger than the monitor, producing a huge positive position instead of a negative one. --- src/platforms/rcore_desktop_glfw.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/platforms/rcore_desktop_glfw.c b/src/platforms/rcore_desktop_glfw.c index b6718e5e4..52e986876 100644 --- a/src/platforms/rcore_desktop_glfw.c +++ b/src/platforms/rcore_desktop_glfw.c @@ -1804,11 +1804,11 @@ int InitPlatform(void) // Center window into current monitor #if defined(__APPLE__) - CORE.Window.position.x = monitorX + (monitorWidth - CORE.Window.screen.width)/2; - CORE.Window.position.y = monitorY + (monitorHeight - CORE.Window.screen.height)/2; + CORE.Window.position.x = monitorX + (monitorWidth - (int)CORE.Window.screen.width)/2; + CORE.Window.position.y = monitorY + (monitorHeight - (int)CORE.Window.screen.height)/2; #else - CORE.Window.position.x = monitorX + (monitorWidth - CORE.Window.render.width)/2; - CORE.Window.position.y = monitorY + (monitorHeight - CORE.Window.render.height)/2; + CORE.Window.position.x = monitorX + (monitorWidth - (int)CORE.Window.render.width)/2; + CORE.Window.position.y = monitorY + (monitorHeight - (int)CORE.Window.render.height)/2; #endif SetWindowPosition(CORE.Window.position.x, CORE.Window.position.y);