From cf71fddc68307fc2271d5dd02e3fbcb932b70180 Mon Sep 17 00:00:00 2001 From: Melody Madeline Lyons Date: Fri, 5 Jul 2024 05:49:18 -0700 Subject: [PATCH] Fix multi-monitor window centering --- src/eventthread.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/eventthread.cpp b/src/eventthread.cpp index 40de3c7d1..b7afd95ca 100644 --- a/src/eventthread.cpp +++ b/src/eventthread.cpp @@ -528,13 +528,16 @@ void EventThread::process(RGSSThreadData &rtData) rtData.rqWindowAdjust.clear(); break; - case REQUEST_WINCENTER : - rc = SDL_GetDesktopDisplayMode(SDL_GetWindowDisplayIndex(win), &dm); - if (!rc) - SDL_SetWindowPosition(win, - (dm.w / 2) - (winW / 2), - (dm.h / 2) - (winH / 2)); - rtData.rqWindowAdjust.clear(); + case REQUEST_WINCENTER : { + rc = SDL_GetDesktopDisplayMode(SDL_GetWindowDisplayIndex(win), &dm); + SDL_Rect rect; + SDL_GetDisplayUsableBounds(SDL_GetWindowDisplayIndex(win), &rect); + if (!rc) + SDL_SetWindowPosition(win, + rect.x + (dm.w / 2) - (winW / 2), + rect.y + (dm.h / 2) - (winH / 2)); + rtData.rqWindowAdjust.clear(); + } break; case REQUEST_WINRENAME :