Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: adapt to qt6 for PlatformWindowHelper #281

Merged
merged 1 commit into from
Mar 19, 2025
Merged
Show file tree
Hide file tree
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
7 changes: 6 additions & 1 deletion xcb/dframewindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -924,8 +924,13 @@ void DFrameWindow::updateShadow()
update();

// 阴影更新后尝试刷新内部窗口
if (m_contentBackingStore)
if (m_contentBackingStore) {
// Timer maybe miss killed if updateShadow is called frequently.
if (m_paintShadowOnContentTimerId >= 0) {
killTimer(m_paintShadowOnContentTimerId);
}
m_paintShadowOnContentTimerId = startTimer(300, Qt::PreciseTimer);
}
}

void DFrameWindow::updateShadowAsync(int delaye)
Expand Down
30 changes: 22 additions & 8 deletions xcb/dplatformwindowhelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,11 @@ void DPlatformWindowHelper::requestActivateWindow()
}
#endif

// ActivateWindow is called recursively in qt6.8
#if QT_VERSION < QT_VERSION_CHECK(6, 8, 0)
helper->m_frameWindow->handle()->requestActivateWindow();
#endif

#ifdef Q_OS_LINUX
// 对于有parent的窗口,需要调用此接口让其获得输入焦点
xcb_set_input_focus(DPlatformIntegration::xcbConnection()->xcb_connection(),
Expand Down Expand Up @@ -624,10 +628,15 @@ bool DPlatformWindowHelper::eventFilter(QObject *watched, QEvent *event)
mevent->mutablePoint().setScenePosition(m_nativeWindow->window()->mapFromGlobal(e->globalPosition()));
qApp->sendEvent(m_nativeWindow->window(), 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());
if (!e->points().isEmpty()) {
QEventPoint &point = e->m_points[0];
const auto pos = m_frameWindow->mapFromGlobal(e->globalPosition());
QEventPoint targetPoint = QMutableEventPoint::withTimeStamp(point.timestamp(), point.id(), point.state(),
pos, pos, pos);
QMutableEventPoint::update(targetPoint, point);
m_frameWindow->mouseMoveEvent(e);
qApp->sendEvent(m_nativeWindow->window(), e);
}
#endif
return true;
}
Expand Down Expand Up @@ -719,10 +728,15 @@ bool DPlatformWindowHelper::eventFilter(QObject *watched, QEvent *event)
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_frameWindow->mapFromGlobal(e->globalPosition()));
QMutableEventPoint::setScenePosition(mevent->point(0), m_frameWindow->mapFromGlobal(e->globalPosition()));
qApp->sendEvent(m_frameWindow, mevent.data());
if (!e->points().isEmpty()) {
QEventPoint &point = e->m_points[0];
const auto pos = m_frameWindow->mapFromGlobal(e->globalPosition());
QEventPoint targetPoint = QMutableEventPoint::withTimeStamp(point.timestamp(), point.id(), point.state(),
pos, pos, pos);
QMutableEventPoint::update(targetPoint, point);
e->m_source = Qt::MouseEventSynthesizedByQt;
m_frameWindow->mouseMoveEvent(e);
}
#endif
return true;
}
Expand Down