Skip to content

Commit

Permalink
fix: the autoStarted app crashed when dragging it
Browse files Browse the repository at this point in the history
typed wrong window type when adapting to Qt6

Log: fix the autoStarted app crashed when dragging it
  • Loading branch information
FeiWang1119 committed Sep 15, 2023
1 parent 1c4a98c commit 76e644c
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions xcb/dplatformwindowhelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -702,18 +702,19 @@ bool DPlatformWindowHelper::eventFilter(QObject *watched, QEvent *event)
DQMouseEvent *e = static_cast<DQMouseEvent*>(event);

#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
e->l = e->w = m_nativeWindow->window()->mapFromGlobal(e->globalPos());
qApp->sendEvent(m_nativeWindow->window(), e);
e->l = e->w = m_frameWindow->mapFromGlobal(e->globalPos());
QGuiApplicationPrivate::setMouseEventSource(e, Qt::MouseEventSynthesizedByQt);
m_frameWindow->mouseMoveEvent(e);
#elif QT_VERSION <= QT_VERSION_CHECK(6, 2, 4)
QScopedPointer<QMutableSinglePointEvent> mevent(QMutableSinglePointEvent::from(e->clone()));
mevent->mutablePoint().setPosition(m_nativeWindow->window()->mapFromGlobal(e->globalPosition()));
mevent->mutablePoint().setScenePosition(m_nativeWindow->window()->mapFromGlobal(e->globalPosition()));
qApp->sendEvent(m_nativeWindow->window(), mevent.data());
mevent->mutablePoint().setPosition(m_frameWindow->mapFromGlobal(e->globalPosition()));
mevent->mutablePoint().setScenePosition(m_frameWindow->mapFromGlobal(e->globalPosition()));
qApp->sendEvent(m_frameWindow, mevent.data());
#else
QScopedPointer<QMutableSinglePointEvent> mevent(QMutableSinglePointEvent::from(e->clone()));
QMutableEventPoint::setPosition(mevent->point(0), m_nativeWindow->window()->mapFromGlobal(e->globalPosition()));
QMutableEventPoint::setScenePosition(mevent->point(0), m_nativeWindow->window()->mapFromGlobal(e->globalPosition()));
qApp->sendEvent(m_nativeWindow->window(), mevent.data());
QMutableEventPoint::setPosition(mevent->point(0), m_frameWindow->mapFromGlobal(e->globalPosition()));
QMutableEventPoint::setScenePosition(mevent->point(0), m_frameWindow->mapFromGlobal(e->globalPosition()));
qApp->sendEvent(m_frameWindow, mevent.data());
#endif
return true;
}
Expand Down

0 comments on commit 76e644c

Please sign in to comment.