From bc8868d519702c5a55f21377711cf4db54714650 Mon Sep 17 00:00:00 2001
From: SineStriker <55847490+SineStriker@users.noreply.github.com>
Date: 周一, 29 1月 2024 22:03:10 +0800
Subject: [PATCH] Fix centerize issue (#34)

---
 src/core/contexts/abstractwindowcontext.cpp |   11 ++++++-----
 1 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/src/core/contexts/abstractwindowcontext.cpp b/src/core/contexts/abstractwindowcontext.cpp
index d0ca27c..6f2e421 100644
--- a/src/core/contexts/abstractwindowcontext.cpp
+++ b/src/core/contexts/abstractwindowcontext.cpp
@@ -1,4 +1,5 @@
-// Copyright (C) 2023-2024 Stdware Collections
+// Copyright (C) 2023-2024 Stdware Collections (https://www.github.com/stdware)
+// Copyright (C) 2021-2023 wangwenx190 (Yuhang Zhao)
 // SPDX-License-Identifier: Apache-2.0
 
 #include "abstractwindowcontext_p.h"
@@ -123,8 +124,7 @@
     }
 
 #ifdef Q_OS_MAC
-    void
-        AbstractWindowContext::setSystemButtonAreaCallback(const ScreenRectCallback &callback) {
+    void AbstractWindowContext::setSystemButtonAreaCallback(const ScreenRectCallback &callback) {
         m_systemButtonAreaCallback = callback;
         virtual_hook(SystemButtonAreaChangedHook, nullptr);
     }
@@ -205,9 +205,10 @@
                 if (!m_windowHandle)
                     return;
 
+                QRect windowGeometry = m_delegate->getGeometry(m_host);
                 QRect screenGeometry = m_windowHandle->screen()->geometry();
-                int x = (screenGeometry.width() - m_windowHandle->width()) / 2;
-                int y = (screenGeometry.height() - m_windowHandle->height()) / 2;
+                int x = (screenGeometry.width() - windowGeometry.width()) / 2;
+                int y = (screenGeometry.height() - windowGeometry.height()) / 2;
                 QPoint pos(x, y);
                 pos += screenGeometry.topLeft();
                 m_windowHandle->setPosition(pos);

--
Gitblit v1.9.1