Skip to content

Commit 50e3ef3

Browse files
Fixed stealing of focus by tab close button
1 parent 9974256 commit 50e3ef3

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

src/DockFocusController.cpp

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
#include <QPointer>
1717
#include <QApplication>
18+
#include <QAbstractButton>
1819

1920
#include "DockWidget.h"
2021
#include "DockAreaWidget.h"
@@ -217,15 +218,26 @@ void CDockFocusController::onApplicationFocusChanged(QWidget* focusedOld, QWidge
217218
return;
218219
}
219220

220-
//qDebug() << "\n----------------------------";
221+
//qDebug() << "\n----------------------------";
221222
//qDebug() << "CDockFocusController::onApplicationFocusChanged " << " old: " << focusedOld << " new: " << focusedNow;
222-
Q_UNUSED(focusedOld)
223223
if (!focusedNow)
224224
{
225225
return;
226226
}
227227

228-
CDockWidget* DockWidget = nullptr;
228+
// If the close button in another tab steals the focus from the current
229+
// active dock widget content, then we giv it back immediately
230+
if (CDockManager::testConfigFlag(CDockManager::AllTabsHaveCloseButton))
231+
{
232+
auto OtherDockWidgetTab = internal::findParent<CDockWidgetTab*>(focusedNow);
233+
if (OtherDockWidgetTab && focusedOld)
234+
{
235+
focusedOld->setFocus();
236+
return;
237+
}
238+
}
239+
240+
CDockWidget* DockWidget = nullptr;
229241
auto DockWidgetTab = qobject_cast<CDockWidgetTab*>(focusedNow);
230242
if (DockWidgetTab)
231243
{

0 commit comments

Comments
 (0)