From 50e3ef3dd8ea7d209f74bfac5b664ba7976084ae Mon Sep 17 00:00:00 2001 From: Uwe Kindler Date: Wed, 8 Jul 2020 08:08:50 +0200 Subject: [PATCH] Fixed stealing of focus by tab close button --- src/DockFocusController.cpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/DockFocusController.cpp b/src/DockFocusController.cpp index 0ecedc4..b4232a0 100644 --- a/src/DockFocusController.cpp +++ b/src/DockFocusController.cpp @@ -15,6 +15,7 @@ #include #include +#include #include "DockWidget.h" #include "DockAreaWidget.h" @@ -217,15 +218,26 @@ void CDockFocusController::onApplicationFocusChanged(QWidget* focusedOld, QWidge return; } - //qDebug() << "\n----------------------------"; + //qDebug() << "\n----------------------------"; //qDebug() << "CDockFocusController::onApplicationFocusChanged " << " old: " << focusedOld << " new: " << focusedNow; - Q_UNUSED(focusedOld) if (!focusedNow) { return; } - CDockWidget* DockWidget = nullptr; + // If the close button in another tab steals the focus from the current + // active dock widget content, then we giv it back immediately + if (CDockManager::testConfigFlag(CDockManager::AllTabsHaveCloseButton)) + { + auto OtherDockWidgetTab = internal::findParent(focusedNow); + if (OtherDockWidgetTab && focusedOld) + { + focusedOld->setFocus(); + return; + } + } + + CDockWidget* DockWidget = nullptr; auto DockWidgetTab = qobject_cast(focusedNow); if (DockWidgetTab) {