Zhao Yuhang
2023-12-22 0cedc474f38dca024f77ebf1d7ac5bf22c19744a
src/core/contexts/abstractwindowcontext.cpp
@@ -48,6 +48,33 @@
        }
    }
    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);
        if (!obj) {
@@ -81,6 +108,15 @@
        if (m_titleBar == item) {
            return false;
        }
        if (m_titleBar) {
            // Since the title bar is changed, all items inside it should be dereferenced right away
            for (auto &button : m_systemButtons) {
                button = nullptr;
            }
            m_hitTestVisibleItems.clear();
        }
        m_titleBar = item;
        return true;
    }
@@ -210,6 +246,24 @@
        if (oldWindow == m_windowHandle)
            return;
        winIdChanged();
        if (m_windowHandle) {
            // Refresh window attributes
            auto attributes = m_windowAttributes;
            m_windowAttributes.clear();
            for (auto it = attributes.begin(); it != attributes.end(); ++it) {
                if (!windowAttributeChanged(it.key(), it.value(), {})) {
                    continue;
                }
                m_windowAttributes.insert(it.key(), it.value());
            }
        }
    }
    bool AbstractWindowContext::windowAttributeChanged(const QString &key,
                                                       const QVariant &attribute,
                                                       const QVariant &oldAttribute) {
        return false;
    }
}