@@ -160,6 +160,11 @@ void DockFocusControllerPrivate::updateDockWidgetFocus(CDockWidget* DockWidget)
160
160
}
161
161
#endif
162
162
163
+ if (old == DockWidget)
164
+ {
165
+ return ;
166
+ }
167
+
163
168
if (DockWidget->isVisible ())
164
169
{
165
170
emit DockManager->focusedDockWidgetChanged (old, DockWidget);
@@ -212,6 +217,8 @@ void CDockFocusController::onApplicationFocusChanged(QWidget* focusedOld, QWidge
212
217
return ;
213
218
}
214
219
220
+ // qDebug() << "\n----------------------------";
221
+ // qDebug() << "CDockFocusController::onApplicationFocusChanged " << " old: " << focusedOld << " new: " << focusedNow;
215
222
Q_UNUSED (focusedOld)
216
223
if (!focusedNow)
217
224
{
@@ -223,6 +230,14 @@ void CDockFocusController::onApplicationFocusChanged(QWidget* focusedOld, QWidge
223
230
if (DockWidgetTab)
224
231
{
225
232
DockWidget = DockWidgetTab->dockWidget ();
233
+ // If the DockWidgetTab "steals" the focus from a widget in the same
234
+ // DockWidget, then we immediately give the focus back to the previous
235
+ // focused widget focusedOld
236
+ if (DockWidget == d->FocusedDockWidget && focusedOld && focusedOld != focusedNow)
237
+ {
238
+ focusedOld->setFocus ();
239
+ return ;
240
+ }
226
241
}
227
242
228
243
if (!DockWidget)
@@ -278,7 +293,8 @@ void CDockFocusController::onFocusedDockAreaViewToggled(bool Open)
278
293
return ;
279
294
}
280
295
281
- CDockManager::setWidgetFocus (OpenedDockAreas[0 ]->currentDockWidget ()->tabWidget ());
296
+ // CDockManager::setWidgetFocus(OpenedDockAreas[0]->currentDockWidget()->tabWidget());
297
+ d->updateDockWidgetFocus (OpenedDockAreas[0 ]->currentDockWidget ());
282
298
}
283
299
284
300
@@ -293,7 +309,8 @@ void CDockFocusController::notifyWidgetOrAreaRelocation(QWidget* DroppedWidget)
293
309
CDockWidget* DockWidget = qobject_cast<CDockWidget*>(DroppedWidget);
294
310
if (DockWidget)
295
311
{
296
- CDockManager::setWidgetFocus (DockWidget->tabWidget ());
312
+ // CDockManager::setWidgetFocus(DockWidget->tabWidget());
313
+ d->updateDockWidgetFocus (DockWidget);
297
314
return ;
298
315
}
299
316
@@ -304,7 +321,8 @@ void CDockFocusController::notifyWidgetOrAreaRelocation(QWidget* DroppedWidget)
304
321
}
305
322
306
323
DockWidget = DockArea->currentDockWidget ();
307
- CDockManager::setWidgetFocus (DockWidget->tabWidget ());
324
+ // CDockManager::setWidgetFocus(DockWidget->tabWidget());
325
+ d->updateDockWidgetFocus (DockWidget);
308
326
}
309
327
310
328
@@ -325,8 +343,11 @@ void CDockFocusController::notifyFloatingWidgetDrop(CFloatingDockContainer* Floa
325
343
auto DockWidget = vDockWidget.value <CDockWidget*>();
326
344
if (DockWidget)
327
345
{
346
+ d->FocusedDockWidget = nullptr ;
328
347
DockWidget->dockAreaWidget ()->setCurrentDockWidget (DockWidget);
329
- CDockManager::setWidgetFocus (DockWidget->tabWidget ());
348
+ // CDockManager::setWidgetFocus(DockWidget->tabWidget());
349
+ // qDebug() << "CDockFocusController::notifyFloatingWidgetDrop";
350
+ d->updateDockWidgetFocus (DockWidget);
330
351
}
331
352
}
332
353
0 commit comments