Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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