From 78f31c67d71ee743f022dd6f5930abae6f6d54f9 Mon Sep 17 00:00:00 2001
From: Yuhang Zhao <zhaoyuhang@rankyee.com>
Date: 周二, 19 12月 2023 16:43:17 +0800
Subject: [PATCH] update readme

---
 src/core/contexts/abstractwindowcontext.cpp |   27 ++++++++++++++++++++++++---
 1 files changed, 24 insertions(+), 3 deletions(-)

diff --git a/src/core/contexts/abstractwindowcontext.cpp b/src/core/contexts/abstractwindowcontext.cpp
index d34a1f9..5ce7c8c 100644
--- a/src/core/contexts/abstractwindowcontext.cpp
+++ b/src/core/contexts/abstractwindowcontext.cpp
@@ -2,6 +2,7 @@
 
 #include <QtGui/QPen>
 #include <QtGui/QPainter>
+#include <QtGui/QScreen>
 
 #include "qwkglobal_p.h"
 
@@ -21,6 +22,21 @@
         if (m_windowHandle) {
             winIdChanged(nullptr);
         }
+    }
+
+    void AbstractWindowContext::setWindowAttribute(const QString &key, const QVariant &var) {
+        auto it = m_windowAttributes.find(key);
+        if (it.value() == var)
+            return;
+
+        auto newVar = var;
+        auto oldVar = it.value();
+        void *a[] = {
+            &const_cast<QString &>(key),
+            &newVar,
+            &oldVar,
+        };
+        virtual_hook(WindowAttributeChangedHook, a);
     }
 
     bool AbstractWindowContext::setHitTestVisible(const QObject *obj, bool visible) {
@@ -139,12 +155,17 @@
     void AbstractWindowContext::virtual_hook(int id, void *data) {
         switch (id) {
             case CentralizeHook: {
-                // TODO: Qt
+                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;
             }
 
-            case ShowSystemMenuHook: {
-                // TODO: Qt
+            case RaiseWindowHook: {
+                if (m_windowHandle->windowStates() & Qt::WindowMinimized)
+                    m_windowHandle->showNormal();
+                m_windowHandle->raise();
                 break;
             }
 

--
Gitblit v1.9.1