summaryrefslogtreecommitdiffhomepage
path: root/src/platforms
diff options
context:
space:
mode:
authorRay <[email protected]>2024-04-08 11:27:56 +0200
committerRay <[email protected]>2024-04-08 11:27:56 +0200
commit04afba260f64ee2ea9ef0b4a6d2058c9ffdad66d (patch)
treea3ca28f175d129187d6412286b92aa0f2e735740 /src/platforms
parent892e57d46e92d43533d11c608d554b56375b8517 (diff)
downloadraylib-04afba260f64ee2ea9ef0b4a6d2058c9ffdad66d.tar.gz
raylib-04afba260f64ee2ea9ef0b4a6d2058c9ffdad66d.zip
REVIEWED: Window positioning, avoid out-of-screen window-bar
Diffstat (limited to 'src/platforms')
-rw-r--r--src/platforms/rcore_desktop.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/platforms/rcore_desktop.c b/src/platforms/rcore_desktop.c
index 04b73355..64e79c6d 100644
--- a/src/platforms/rcore_desktop.c
+++ b/src/platforms/rcore_desktop.c
@@ -1515,7 +1515,15 @@ int InitPlatform(void)
// If graphic device is no properly initialized, we end program
if (!CORE.Window.ready) { TRACELOG(LOG_FATAL, "PLATFORM: Failed to initialize graphic device"); return -1; }
- else SetWindowPosition(GetMonitorWidth(GetCurrentMonitor())/2 - CORE.Window.screen.width/2, GetMonitorHeight(GetCurrentMonitor())/2 - CORE.Window.screen.height/2);
+ 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;
+ SetWindowPosition(posX, posY);
+ }
// Load OpenGL extensions
// NOTE: GL procedures address loader is required to load extensions