Commit 9bd4b30
committed
[rcore][GLFW] Fix window ending up off-screen when larger than the monitor workarea
InitPlatform() centers the window with monitorX + (monitorWidth - width)/2,
with no check for the window being bigger than the monitor. If it is
(landscape window on a portrait primary monitor, or any window wider/taller
than the workarea), that division goes negative and the window gets placed
outside the virtual desktop. On Windows this doesn't just look off-center,
glfwSetWindowPos/GetWindowPos come back with garbage coordinates and the
window can end up invisible until you drag it back with win+shift+arrow.
SetWindowMonitor() already guards against this by anchoring to the workarea
origin when the window doesn't fit, so apply the same check here.
Repro: request InitWindow() with a size wider than the monitor and read
GetWindowPosition() right after. Before the fix this returns a huge bogus
x value instead of a small negative one. After the fix it's anchored to
the monitor origin. Verified on Windows 11 with a single monitor (couldn't
test the original portrait multi-monitor report from #6002 directly, don't
have that hardware, but the position math is the same code path).
Fixes #6002
Signed-off-by: Kyue <164024549+Gooh456@users.noreply.github.com>1 parent c15f321 commit 9bd4b30
1 file changed
Lines changed: 20 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1791 | 1791 | | |
1792 | 1792 | | |
1793 | 1793 | | |
1794 | | - | |
1795 | | - | |
| 1794 | + | |
| 1795 | + | |
1796 | 1796 | | |
1797 | | - | |
1798 | | - | |
| 1797 | + | |
| 1798 | + | |
1799 | 1799 | | |
| 1800 | + | |
| 1801 | + | |
| 1802 | + | |
| 1803 | + | |
| 1804 | + | |
| 1805 | + | |
| 1806 | + | |
| 1807 | + | |
| 1808 | + | |
| 1809 | + | |
| 1810 | + | |
| 1811 | + | |
| 1812 | + | |
| 1813 | + | |
| 1814 | + | |
| 1815 | + | |
1800 | 1816 | | |
1801 | 1817 | | |
1802 | 1818 | | |
| |||
0 commit comments