[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.
This commit is contained in:
Nicholas Velten
2026-09-12 05:54:30 -03:00
committed by GitHub
parent 2f699f6bf0
commit 9f59089de1

View File

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