summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/platforms/rcore_desktop.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/platforms/rcore_desktop.c b/src/platforms/rcore_desktop.c
index 64e79c6d..211a6cbb 100644
--- a/src/platforms/rcore_desktop.c
+++ b/src/platforms/rcore_desktop.c
@@ -1518,10 +1518,16 @@ int InitPlatform(void)
else
{
// Try to center window on screen but avoiding window-bar outside of screen
- int posX = GetMonitorWidth(GetCurrentMonitor())/2 - CORE.Window.screen.width/2;
- int posY = GetMonitorHeight(GetCurrentMonitor())/2 - CORE.Window.screen.height/2;
- if (posX < 0) posX = 0;
- if (posY < 0) posY = 0;
+ int monitorX = 0;
+ int monitorY = 0;
+ int monitorWidth = 0;
+ int monitorHeight = 0;
+ glfwGetMonitorWorkarea(monitor, &monitorX, &monitorY, &monitorWidth, &monitorHeight);
+
+ int posX = monitorX + (monitorWidth - CORE.Window.screen.width)/2;
+ int posY = monitorY + (monitorHeight - CORE.Window.screen.height)/2;
+ if (posX < monitorX) posX = monitorX;
+ if (posY < monitorY) posY = monitorY;
SetWindowPosition(posX, posY);
}