From 06b335edde08b91aeb5497719f2d584f98abd7c4 Mon Sep 17 00:00:00 2001
From: SineStriker <trueful@163.com>
Date: 摹曛, 28 12月 2023 23:04:49 +0800
Subject: [PATCH] clean code

---
 src/core/contexts/abstractwindowcontext.cpp |   60 +++++++++++++++++++++++++++++++++++-------------------------
 1 files changed, 35 insertions(+), 25 deletions(-)

diff --git a/src/core/contexts/abstractwindowcontext.cpp b/src/core/contexts/abstractwindowcontext.cpp
index 8672faf..2fdada5 100644
--- a/src/core/contexts/abstractwindowcontext.cpp
+++ b/src/core/contexts/abstractwindowcontext.cpp
@@ -71,32 +71,7 @@
         }
     }
 
-    bool AbstractWindowContext::setWindowAttribute(const QString &key, const QVariant &attribute) {
-        auto it = m_windowAttributes.find(key);
-        if (it == m_windowAttributes.end()) {
-            if (!attribute.isValid()) {
-                return true;
-            }
-            if (!m_windowHandle || !windowAttributeChanged(key, attribute, {})) {
-                return false;
-            }
-            m_windowAttributes.insert(key, attribute);
-            return true;
-        }
 
-        if (it.value() == attribute)
-            return true;
-        if (!m_windowHandle || !windowAttributeChanged(key, attribute, it.value())) {
-            return false;
-        }
-
-        if (attribute.isValid()) {
-            it.value() = attribute;
-        } else {
-            m_windowAttributes.erase(it);
-        }
-        return true;
-    }
 
     bool AbstractWindowContext::setHitTestVisible(const QObject *obj, bool visible) {
         Q_ASSERT(obj);
@@ -236,6 +211,10 @@
             }
 
             case RaiseWindowHook: {
+                if (!m_windowHandle)
+                    return;
+
+                m_delegate->setWindowVisible(m_host, true);
                 Qt::WindowStates state = m_delegate->getWindowState(m_host);
                 if (state & Qt::WindowMinimized) {
                     m_delegate->setWindowState(m_host, state & ~Qt::WindowMinimized);
@@ -285,6 +264,37 @@
         }
     }
 
+    QVariant AbstractWindowContext::windowAttribute(const QString &key) const {
+        return m_windowAttributes.value(key);
+    }
+
+    bool AbstractWindowContext::setWindowAttribute(const QString &key, const QVariant &attribute) {
+        auto it = m_windowAttributes.find(key);
+        if (it == m_windowAttributes.end()) {
+            if (!attribute.isValid()) {
+                return true;
+            }
+            if (!m_windowHandle || !windowAttributeChanged(key, attribute, {})) {
+                return false;
+            }
+            m_windowAttributes.insert(key, attribute);
+            return true;
+        }
+
+        if (it.value() == attribute)
+            return true;
+        if (!m_windowHandle || !windowAttributeChanged(key, attribute, it.value())) {
+            return false;
+        }
+
+        if (attribute.isValid()) {
+            it.value() = attribute;
+        } else {
+            m_windowAttributes.erase(it);
+        }
+        return true;
+    }
+
     bool AbstractWindowContext::windowAttributeChanged(const QString &key,
                                                        const QVariant &attribute,
                                                        const QVariant &oldAttribute) {

--
Gitblit v1.9.1