diff --git a/xcb/dnotitlebarwindowhelper.cpp b/xcb/dnotitlebarwindowhelper.cpp index 1a6b898d..fe34e2c6 100644 --- a/xcb/dnotitlebarwindowhelper.cpp +++ b/xcb/dnotitlebarwindowhelper.cpp @@ -2,16 +2,13 @@ // // SPDX-License-Identifier: LGPL-3.0-or-later -#define protected public -#include -#undef protected #include "dnotitlebarwindowhelper.h" -#include "vtablehook.h" #include "utility.h" #include "dwmsupport.h" #include "dnativesettings.h" #include "dplatformintegration.h" +#include #include #include #include @@ -19,6 +16,7 @@ #include #include #include +#include #define _DEEPIN_SCISSOR_WINDOW "_DEEPIN_SCISSOR_WINDOW" Q_DECLARE_METATYPE(QPainterPath) @@ -81,9 +79,8 @@ DNoTitlebarWindowHelper::~DNoTitlebarWindowHelper() { g_pressPoint.remove(this); - if (VtableHook::hasVtable(m_window)) { - VtableHook::resetVtable(m_window); - } + if (m_enableSystemMove) + m_window->removeEventFilter(this); mapped.remove(qobject_cast(parent())); @@ -426,9 +423,9 @@ void DNoTitlebarWindowHelper::updateEnableSystemMoveFromProperty() m_enableSystemMove = !v.isValid() || v.toBool(); if (m_enableSystemMove) { - VtableHook::overrideVfptrFun(m_window, &QWindow::event, this, &DNoTitlebarWindowHelper::windowEvent); - } else if (VtableHook::hasVtable(m_window)) { - VtableHook::resetVfptrFun(m_window, &QWindow::event); + m_window->installEventFilter(this); + } else { + m_window->removeEventFilter(this); } } @@ -510,9 +507,11 @@ void DNoTitlebarWindowHelper::updateAutoInputMaskByClipPathFromProperty() updateWindowShape(); } -bool DNoTitlebarWindowHelper::windowEvent(QEvent *event) +bool DNoTitlebarWindowHelper::eventFilter(QObject *watched, QEvent *event) { - QWindow *w = this->window(); + QWindow *w = qobject_cast(watched); + if (!w) + return false; // get touch begin position static bool isTouchDown = false; @@ -531,7 +530,7 @@ bool DNoTitlebarWindowHelper::windowEvent(QEvent *event) QPointF currentPos = static_cast(event)->globalPos(); QPointF delta = touchBeginPosition - currentPos; if (delta.manhattanLength() < QGuiApplication::styleHints()->startDragDistance()) { - return VtableHook::callOriginalFun(w, &QWindow::event, event); + return w->event(event); } } @@ -549,7 +548,8 @@ bool DNoTitlebarWindowHelper::windowEvent(QEvent *event) updateMoveWindow(winId); } - bool ret = VtableHook::callOriginalFun(w, &QWindow::event, event); + // call first to set accept false(quickwindow) + w->event(event); // workaround for kwin: Qt receives no release event when kwin finishes MOVE operation, // which makes app hang in windowMoving state. when a press happens, there's no sense of @@ -563,12 +563,12 @@ bool DNoTitlebarWindowHelper::windowEvent(QEvent *event) QMouseEvent *me = static_cast(event); QRect windowRect = QRect(QPoint(0, 0), w->size()); if (!windowRect.contains(me->windowPos().toPoint())) { - return ret; + return true; } QPointF delta = me->globalPos() - g_pressPoint[this]; if (delta.manhattanLength() < QGuiApplication::styleHints()->startDragDistance()) { - return ret; + return true; } if (!self->m_windowMoving && self->isEnableSystemMove(winId)) { @@ -583,7 +583,7 @@ bool DNoTitlebarWindowHelper::windowEvent(QEvent *event) } } - return ret; + return true; } bool DNoTitlebarWindowHelper::isEnableSystemMove(quint32 winId) diff --git a/xcb/dnotitlebarwindowhelper.h b/xcb/dnotitlebarwindowhelper.h index 88d78e8f..33d99b27 100644 --- a/xcb/dnotitlebarwindowhelper.h +++ b/xcb/dnotitlebarwindowhelper.h @@ -98,7 +98,7 @@ private slots: Q_SLOT void updateAutoInputMaskByClipPathFromProperty(); private: - bool windowEvent(QEvent *event); + virtual bool eventFilter(QObject *watched, QEvent *event) override; bool isEnableSystemMove(quint32 winId); bool updateWindowBlurAreasForWM(); void updateWindowShape();