From fe50d30edcc31618905ec3e3dc39c8b78cee49db Mon Sep 17 00:00:00 2001
From: Yuhang Zhao <zhaoyuhang@rankyee.com>
Date: 周二, 19 12月 2023 18:09:23 +0800
Subject: [PATCH] minor tweaks

---
 src/core/contexts/abstractwindowcontext.cpp |   20 ++++++++++++--------
 1 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/src/core/contexts/abstractwindowcontext.cpp b/src/core/contexts/abstractwindowcontext.cpp
index 5ce7c8c..0602bdc 100644
--- a/src/core/contexts/abstractwindowcontext.cpp
+++ b/src/core/contexts/abstractwindowcontext.cpp
@@ -156,17 +156,21 @@
         switch (id) {
             case CentralizeHook: {
                 QRect screenGeometry = m_windowHandle->screen()->geometry();
-                int x = screenGeometry.width() / 2 - m_windowHandle->width() / 2;
-                int y = screenGeometry.height() / 2 - m_windowHandle->height() / 2;
-                m_windowHandle->setPosition(x, y);
-                break;
+                int x = (screenGeometry.width() - m_windowHandle->width()) / 2;
+                int y = (screenGeometry.height() - m_windowHandle->height()) / 2;
+                QPoint pos(x, y);
+                pos += screenGeometry.topLeft();
+                m_windowHandle->setPosition(pos);
+                return;
             }
 
             case RaiseWindowHook: {
-                if (m_windowHandle->windowStates() & Qt::WindowMinimized)
-                    m_windowHandle->showNormal();
-                m_windowHandle->raise();
-                break;
+                Qt::WindowStates state = m_delegate->getWindowState(m_host);
+                if (state & Qt::WindowMinimized) {
+                    m_delegate->setWindowState(m_host, state & ~Qt::WindowMinimized);
+                }
+                m_delegate->bringWindowToTop(m_host);
+                return;
             }
 
             case DefaultColorsHook: {

--
Gitblit v1.9.1