SineStriker
2023-12-27 88b5b56b6a67d93208eae3980af2f30da09dd8ae
src/core/contexts/qtwindowcontext.cpp
@@ -77,9 +77,9 @@
#endif
    }
    class QtWindowEventFilter : public QObject {
    class QtWindowEventFilter : public SharedEventFilter {
    public:
        explicit QtWindowEventFilter(AbstractWindowContext *context, QObject *parent = nullptr);
        explicit QtWindowEventFilter(AbstractWindowContext *context);
        ~QtWindowEventFilter() override;
        enum WindowStatus {
@@ -91,7 +91,7 @@
        };
    protected:
        bool eventFilter(QObject *object, QEvent *event) override;
        bool sharedEventFilter(QObject *object, QEvent *event) override;
    private:
        AbstractWindowContext *m_context;
@@ -99,15 +99,16 @@
        WindowStatus m_windowStatus;
    };
    QtWindowEventFilter::QtWindowEventFilter(AbstractWindowContext *context, QObject *parent)
        : QObject(parent), m_context(context), m_cursorShapeChanged(false), m_windowStatus(Idle) {
        m_context->window()->installEventFilter(this);
    QtWindowEventFilter::QtWindowEventFilter(AbstractWindowContext *context)
        : m_context(context), m_cursorShapeChanged(false), m_windowStatus(Idle) {
        m_context->installSharedEventFilter(this);
    }
    QtWindowEventFilter::~QtWindowEventFilter() = default;
    bool QtWindowEventFilter::eventFilter(QObject *obj, QEvent *event) {
    bool QtWindowEventFilter::sharedEventFilter(QObject *obj, QEvent *event) {
        Q_UNUSED(obj)
        auto type = event->type();
        if (type < QEvent::MouseButtonPress || type > QEvent::MouseMove) {
            return false;
@@ -235,6 +236,7 @@
    }
    QtWindowContext::QtWindowContext() : AbstractWindowContext() {
        qtWindowEventFilter = std::make_unique<QtWindowEventFilter>(this);
    }
    QtWindowContext::~QtWindowContext() = default;
@@ -247,14 +249,7 @@
        AbstractWindowContext::virtual_hook(id, data);
    }
    void QtWindowContext::winIdChanged(QWindow *oldWindow, bool isDestroyed) {
        Q_UNUSED(isDestroyed)
        // If the original window id is valid, remove all resources related
        if (oldWindow) {
            qtWindowEventFilter.reset();
        }
    void QtWindowContext::winIdChanged() {
        if (!m_windowHandle) {
            m_delegate->setWindowFlags(m_host, m_delegate->getWindowFlags(m_host) &
                                                   ~Qt::FramelessWindowHint);
@@ -264,7 +259,6 @@
        // Allocate new resources
        m_delegate->setWindowFlags(m_host,
                                   m_delegate->getWindowFlags(m_host) | Qt::FramelessWindowHint);
        qtWindowEventFilter = std::make_unique<QtWindowEventFilter>(this);
    }
}