MDI: Fix case where resize cursor would be shown for frame bellow

Was already fixed a few days ago, but this is the case for nested
mdi.
This commit is contained in:
Sergio Martins
2022-03-09 19:08:29 +00:00
parent a97663294c
commit e345e89c35
2 changed files with 32 additions and 0 deletions

View File

@@ -388,6 +388,33 @@ inline T* firstParentOfType(const QObject *child)
return nullptr;
}
template <typename T>
inline T* lastParentOfType(const QObject *child)
{
auto p = const_cast<QObject *>(child);
T* result = nullptr;
while (p) {
if (auto candidate = qobject_cast<T *>(p))
result = candidate;
if (qobject_cast<const QWindow*>(p)) {
// Ignore QObject hierarchies spanning though multiple windows
return result;
}
#ifdef KDDOCKWIDGETS_QTWIDGETS
// Ignore QObject hierarchies spanning though multiple windows
if (auto w = qobject_cast<QWidget *>(p))
if (w->isWindow())
return result;
#endif
p = p->parent();
}
return result;
}
};
#endif

View File

@@ -101,6 +101,11 @@ bool WidgetResizeHandler::eventFilter(QObject *o, QEvent *e)
// We only want to continue if the cursor is near the margins of our own frame (mTarget)
auto frame = firstParentOfType<Frame>(widget);
if (frame && frame->isMDIWrapper()) {
// We don't care about the inner Option_MDINestable helper frame
frame = frame->mdiFrame();
}
if (frame && frame != mTarget) {
const bool areSiblings = frame->QWidgetAdapter::parentWidget() == mTarget->parentWidget();
if (areSiblings)