From ed5f9693b3cd7ddcdc746c4bb65dcd9cf7a8268b Mon Sep 17 00:00:00 2001
From: Sine Striker <trueful@163.com>
Date: 周二, 19 12月 2023 15:09:49 +0800
Subject: [PATCH] Add window attributes

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

diff --git a/src/core/contexts/abstractwindowcontext.cpp b/src/core/contexts/abstractwindowcontext.cpp
index ef1efbf..a62d037 100644
--- a/src/core/contexts/abstractwindowcontext.cpp
+++ b/src/core/contexts/abstractwindowcontext.cpp
@@ -23,6 +23,21 @@
         }
     }
 
+    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) {
         Q_ASSERT(obj);
         if (!obj) {
@@ -39,9 +54,8 @@
 
     bool AbstractWindowContext::setSystemButton(WindowAgentBase::SystemButton button,
                                                 QObject *obj) {
-        Q_ASSERT(obj);
         Q_ASSERT(button != WindowAgentBase::Unknown);
-        if (!obj || (button == WindowAgentBase::Unknown)) {
+        if (button == WindowAgentBase::Unknown) {
             return false;
         }
 
@@ -54,10 +68,6 @@
 
     bool AbstractWindowContext::setTitleBar(QObject *item) {
         Q_ASSERT(item);
-        if (!item) {
-            return false;
-        }
-
         if (m_titleBar == item) {
             return false;
         }

--
Gitblit v1.9.1