From 1c41cbff82a557ee67104df8cb28181e7763b9ec Mon Sep 17 00:00:00 2001 From: Uwe Kindler Date: Mon, 8 Jul 2024 10:43:02 +0200 Subject: [PATCH] Fixed issue #641 - Unexpected behaviour with tab drag on scrollable tab bar --- src/DockAreaTabBar.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/DockAreaTabBar.cpp b/src/DockAreaTabBar.cpp index e835144..39b2901 100644 --- a/src/DockAreaTabBar.cpp +++ b/src/DockAreaTabBar.cpp @@ -390,15 +390,18 @@ void CDockAreaTabBar::onTabWidgetMoved(const QPoint& GlobalPos) int fromIndex = d->TabsLayout->indexOf(MovingTab); auto MousePos = mapFromGlobal(GlobalPos); - MousePos.rx() = qMax(d->firstTab()->geometry().left(), MousePos.x()); - MousePos.rx() = qMin(d->lastTab()->geometry().right(), MousePos.x()); + MousePos.rx() = qMax(0, MousePos.x()); + MousePos.rx() = qMin(width(), MousePos.x()); int toIndex = -1; // Find tab under mouse for (int i = 0; i < count(); ++i) { CDockWidgetTab* DropTab = tab(i); + auto TabGeometry = DropTab->geometry(); + TabGeometry.setTopLeft(d->TabsContainerWidget->mapToParent(TabGeometry.topLeft())); + TabGeometry.setBottomRight(d->TabsContainerWidget->mapToParent(TabGeometry.bottomRight())); if (DropTab == MovingTab || !DropTab->isVisibleTo(this) - || !DropTab->geometry().contains(MousePos)) + || !TabGeometry.contains(MousePos)) { continue; }