qtquick: Fix detecting top level geometry

For QtQuick we want the QWindow geometry. For QtWidget it just works,
as the top level widget as the same geometry as the window, unlike
QQuickItem.

Fixes issue #199
This commit is contained in:
Eism
2021-05-24 11:41:43 +01:00
committed by Sergio Martins
parent 1721415799
commit 0ab701bab6
2 changed files with 12 additions and 5 deletions

View File

@@ -787,6 +787,15 @@ static QWidgetOrQuick *qtTopLevelForHWND(HWND hwnd)
return nullptr;
}
#endif
static QRect topLevelGeometry(const QWidgetOrQuick* topLevel)
{
if (auto mainWindow = qobject_cast<const MainWindowBase*>(topLevel))
return mainWindow->windowGeometry();
return topLevel->geometry();
}
template <typename T>
static WidgetType* qtTopLevelUnderCursor_impl(QPoint globalPos, const QVector<QWindow*> &windows, T windowBeingDragged)
{
@@ -832,7 +841,9 @@ WidgetType *DragController::qtTopLevelUnderCursor() const
continue;
if (auto tl = qtTopLevelForHWND(hwnd)) {
if (tl->geometry().contains(globalPos) && tl->objectName() != QStringLiteral("_docks_IndicatorWindow_Overlay")) {
const QRect windowGeometry = topLevelGeometry(tl);
if (windowGeometry.contains(globalPos) && tl->objectName() != QStringLiteral("_docks_IndicatorWindow_Overlay")) {
qCDebug(toplevels) << Q_FUNC_INFO << "Found top-level" << tl;
return tl;
}

View File

@@ -933,10 +933,6 @@ void TestDocks::tst_hoverShowsDropIndicators()
auto fw = floatingDockWidget->floatingWindow();
dragFloatingWindowTo(fw, mainWindowCenterPos);
#if defined(Q_OS_WIN32)
if (!isOffscreen())
QEXPECT_FAIL("", "to be fixed", Continue);
#endif
QCOMPARE(dock0->dptr()->frame()->dockWidgetCount(), 2);
}
#endif