Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/DockAreaWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -609,8 +609,7 @@ void CDockAreaWidget::removeDockWidget(CDockWidget* DockWidget)
{
if(CFloatingDockContainer* FloatingDockContainer = DockContainer->floatingWidget())
{
FloatingDockContainer->hide();
FloatingDockContainer->deleteLater();
FloatingDockContainer->finishDropOperation();
Copy link
Author

@Ext3h Ext3h Mar 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hideAndDeleteLater has been recently renamed to finishDropOperation, but its functionality isn't just required for drop-operations.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably should be renamed to close() or teardown().

}
}
}
Expand Down
11 changes: 11 additions & 0 deletions src/DockContainerWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2217,6 +2217,17 @@ CDockManager* CDockContainerWidget::dockManager() const
}


//===========================================================================
void CDockContainerWidget::removeFromDockManager()
{
if (d->DockManager)
{
d->DockManager->removeDockContainer(this);
d->DockManager.clear();
}
}


//===========================================================================
void CDockContainerWidget::handleAutoHideWidgetEvent(QEvent* e, QWidget* w)
{
Expand Down
3 changes: 3 additions & 0 deletions src/DockContainerWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ class ADS_EXPORT CDockContainerWidget : public QFrame
friend AutoHideDockContainerPrivate;
friend CAutoHideSideBar;

private Q_SLOTS:
void removeFromDockManager();
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Name may be realigned with CFloatingDockContainer::finishDropOperation


protected:
/**
* Handles activation events to update zOrderIndex
Expand Down
6 changes: 4 additions & 2 deletions src/DockManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -768,7 +768,8 @@ void CDockManager::registerFloatingWidget(CFloatingDockContainer* FloatingWidget
//============================================================================
void CDockManager::removeFloatingWidget(CFloatingDockContainer* FloatingWidget)
{
d->FloatingWidgets.removeAll(FloatingWidget);
int removed = d->FloatingWidgets.removeAll(FloatingWidget);
Q_ASSERT(removed == 1);
}

//============================================================================
Expand All @@ -783,7 +784,8 @@ void CDockManager::removeDockContainer(CDockContainerWidget* DockContainer)
{
if (this != DockContainer)
{
d->Containers.removeAll(DockContainer);
int removed = d->Containers.removeAll(DockContainer);
Q_ASSERT(removed == 1);
}
}

Expand Down
114 changes: 59 additions & 55 deletions src/FloatingDockContainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -370,14 +370,14 @@ struct FloatingDockContainerPrivate
eDragState DraggingState = DraggingInactive;
QPoint DragStartMousePosition;
CDockContainerWidget *DropContainer = nullptr;
CDockAreaWidget *SingleDockArea = nullptr;
QPoint DragStartPos;
bool Hiding = false;
bool AutoHideChildren = true;
bool HideContentOnNextHide = false;
#if defined(Q_OS_UNIX) && !defined(Q_OS_MACOS)
QWidget* MouseEventHandler = nullptr;
CFloatingWidgetTitleBar* TitleBar = nullptr;
CDockAreaWidget *SingleDockArea = nullptr;
Copy link
Author

@Ext3h Ext3h Mar 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bbde511 had introduced inconsistent line endings. This repository does not appear to be using AUTOCLRF nor specify LineEnding in .clang-format, so that's likely to happen again...

QPoint DragStartPos;
bool Hiding = false;
bool AutoHideChildren = true;
bool HideContentOnNextHide = false;
#if defined(Q_OS_UNIX) && !defined(Q_OS_MACOS)
QWidget* MouseEventHandler = nullptr;
CFloatingWidgetTitleBar* TitleBar = nullptr;
bool IsResizing = false;
bool MousePressed = false;
#endif
Expand Down Expand Up @@ -500,6 +500,9 @@ void FloatingDockContainerPrivate::titleMouseReleaseEvent()
return;
}

// DockManager will be unlinked from this within DropContainer->dropFloatingWidget
const auto OriginalDockManager = this->DockManager.data();

if (DockManager->dockAreaOverlay()->dropAreaUnderCursor() != InvalidDockWidgetArea
|| DockManager->containerOverlay()->dropAreaUnderCursor() != InvalidDockWidgetArea)
{
Expand Down Expand Up @@ -533,8 +536,8 @@ void FloatingDockContainerPrivate::titleMouseReleaseEvent()
DropContainer->dropFloatingWidget(_this, QCursor::pos());
}

DockManager->containerOverlay()->hideOverlay();
DockManager->dockAreaOverlay()->hideOverlay();
OriginalDockManager->containerOverlay()->hideOverlay();
OriginalDockManager->dockAreaOverlay()->hideOverlay();
}


Expand Down Expand Up @@ -928,11 +931,11 @@ bool CFloatingDockContainer::nativeEvent(const QByteArray &eventType, void *mess


//============================================================================
void CFloatingDockContainer::closeEvent(QCloseEvent *event)
{
ADS_PRINT("CFloatingDockContainer closeEvent");
d->setState(DraggingInactive);
event->ignore();
void CFloatingDockContainer::closeEvent(QCloseEvent *event)
{
ADS_PRINT("CFloatingDockContainer closeEvent");
d->setState(DraggingInactive);
event->ignore();
if (!isClosable())
{
return;
Expand Down Expand Up @@ -960,55 +963,55 @@ void CFloatingDockContainer::closeEvent(QCloseEvent *event)
return;
}

// New bug (QWebEngineView reload side effect):
// when a WebEngine-based dock is tabified into a floating container, the
// embedded native/web process can trigger delayed hide/show cycles on the
// floating window. If every non-spontaneous hide propagates to
// DockWidget->toggleView(false), unrelated tabs are marked closed and seem
// New bug (QWebEngineView reload side effect):
// when a WebEngine-based dock is tabified into a floating container, the
// embedded native/web process can trigger delayed hide/show cycles on the
// floating window. If every non-spontaneous hide propagates to
// DockWidget->toggleView(false), unrelated tabs are marked closed and seem
// to "disappear". We therefore arm HideContentOnNextHide only for the
// explicit close path.
d->HideContentOnNextHide = true;
// explicit close path.
d->HideContentOnNextHide = true;

// In Qt version after 5.9.2 there seems to be a bug that causes the
// QWidget::event() function to not receive any NonClientArea mouse
// events anymore after a close/show cycle. The bug is reported here:
// https://bugreports.qt.io/browse/QTBUG-73295
// The following code is a workaround for Qt versions > 5.9.2 that seems
// to work
// Starting from Qt version 5.12.2 this seems to work again. But
// now the QEvent::NonClientAreaMouseButtonPress function returns always
// Qt::RightButton even if the left button was pressed
this->hide();
}

//============================================================================
void CFloatingDockContainer::hideEvent(QHideEvent *event)
{
Super::hideEvent(event);
if (event->spontaneous())
{
return;
}
// Starting from Qt version 5.12.2 this seems to work again. But
// now the QEvent::NonClientAreaMouseButtonPress function returns always
// Qt::RightButton even if the left button was pressed
this->hide();
}
//============================================================================
void CFloatingDockContainer::hideEvent(QHideEvent *event)
{
Super::hideEvent(event);
if (event->spontaneous())
{
return;
}

// Prevent toogleView() events during restore state
if (d->DockManager->isRestoringState())
{
return;
}

// Only a close operation should propagate hide->toggleView(false) to
// child dock widgets. Generic hide/show cycles (e.g. from platform or
// embedded native content) must not change dock open/closed state.
if (!d->HideContentOnNextHide)
{
return;
}
d->HideContentOnNextHide = false;

if ( d->AutoHideChildren )
{
d->Hiding = true;
for ( auto DockArea : d->DockContainer->openedDockAreas() )
if (d->DockManager->isRestoringState())
{
return;
}
// Only a close operation should propagate hide->toggleView(false) to
// child dock widgets. Generic hide/show cycles (e.g. from platform or
// embedded native content) must not change dock open/closed state.
if (!d->HideContentOnNextHide)
{
return;
}
d->HideContentOnNextHide = false;
if ( d->AutoHideChildren )
{
d->Hiding = true;
for ( auto DockArea : d->DockContainer->openedDockAreas() )
{
for ( auto DockWidget : DockArea->openedDockWidgets() )
{
Expand Down Expand Up @@ -1220,8 +1223,9 @@ void CFloatingDockContainer::finishDropOperation()
if (d->DockManager)
{
d->DockManager->removeFloatingWidget(this);
d->DockManager->removeDockContainer(this->dockContainer());
d->DockManager.clear();
}
this->dockContainer()->removeFromDockManager();
}

//============================================================================
Expand Down