From 3b33669f960e53396e39681d99b7a8cd6f6a35b3 Mon Sep 17 00:00:00 2001 From: deepin-ci-robot Date: Tue, 27 Aug 2024 06:26:27 +0000 Subject: [PATCH] sync: from linuxdeepin/qt5platform-plugins Synchronize source files from linuxdeepin/qt5platform-plugins. Source-pull-request: https://github.com/linuxdeepin/qt5platform-plugins/pull/252 --- xcb/dnotitlebarwindowhelper.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/xcb/dnotitlebarwindowhelper.cpp b/xcb/dnotitlebarwindowhelper.cpp index 4007ef9..1a6b898 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;