Skip to content

Commit

Permalink
sync: from linuxdeepin/qt5platform-plugins
Browse files Browse the repository at this point in the history
Synchronize source files from linuxdeepin/qt5platform-plugins.

Source-pull-request: linuxdeepin/qt5platform-plugins#252
  • Loading branch information
deepin-ci-robot committed Aug 27, 2024
1 parent 1d2dbd7 commit 3b33669
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion xcb/dnotitlebarwindowhelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ DPP_BEGIN_NAMESPACE

QHash<const QWindow*, DNoTitlebarWindowHelper*> DNoTitlebarWindowHelper::mapped;

static QHash<DNoTitlebarWindowHelper*, QPointF> g_pressPoint;

DNoTitlebarWindowHelper::DNoTitlebarWindowHelper(QWindow *window, quint32 windowID)
: QObject(window)
, m_window(window)
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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) {
Expand All @@ -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<QMouseEvent*>(event)->globalPos();
}

if (is_mouse_move && !event->isAccepted()) {
if (is_mouse_move && !event->isAccepted() && g_pressPoint.contains(this)) {
QMouseEvent *me = static_cast<QMouseEvent*>(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;

Expand Down

0 comments on commit 3b33669

Please sign in to comment.