diff --git a/xcb/dnotitlebarwindowhelper.cpp b/xcb/dnotitlebarwindowhelper.cpp index 4007ef95..1a6b898d 100644 --- a/xcb/dnotitlebarwindowhelper.cpp +++ b/xcb/dnotitlebarwindowhelper.cpp @@ -29,6 +29,8 @@ DPP_BEGIN_NAMESPACE QHash DNoTitlebarWindowHelper::mapped; +static QHash g_pressPoint; + DNoTitlebarWindowHelper::DNoTitlebarWindowHelper(QWindow *window, quint32 windowID) : QObject(window) , m_window(window) @@ -77,6 +79,8 @@ DNoTitlebarWindowHelper::DNoTitlebarWindowHelper(QWindow *window, quint32 window DNoTitlebarWindowHelper::~DNoTitlebarWindowHelper() { + g_pressPoint.remove(this); + if (VtableHook::hasVtable(m_window)) { VtableHook::resetVtable(m_window); } @@ -538,6 +542,7 @@ bool DNoTitlebarWindowHelper::windowEvent(QEvent *event) if (event->type() == QEvent::MouseButtonRelease) { self->m_windowMoving = false; Utility::updateMousePointForWindowMove(winId, true); + g_pressPoint.remove(this); } if (is_mouse_move && self->m_windowMoving) { @@ -551,15 +556,21 @@ bool DNoTitlebarWindowHelper::windowEvent(QEvent *event) // keeping the moving state, we can just reset ti back to normal. if (event->type() == QEvent::MouseButtonPress) { self->m_windowMoving = false; + g_pressPoint[this] = dynamic_cast(event)->globalPos(); } - if (is_mouse_move && !event->isAccepted()) { + if (is_mouse_move && !event->isAccepted() && g_pressPoint.contains(this)) { QMouseEvent *me = static_cast(event); QRect windowRect = QRect(QPoint(0, 0), w->size()); if (!windowRect.contains(me->windowPos().toPoint())) { return ret; } + QPointF delta = me->globalPos() - g_pressPoint[this]; + if (delta.manhattanLength() < QGuiApplication::styleHints()->startDragDistance()) { + return ret; + } + if (!self->m_windowMoving && self->isEnableSystemMove(winId)) { self->m_windowMoving = true;