diff --git a/demo/MainWindow.cpp b/demo/MainWindow.cpp index a522515..762c7a9 100644 --- a/demo/MainWindow.cpp +++ b/demo/MainWindow.cpp @@ -697,7 +697,7 @@ CMainWindow::CMainWindow(QWidget *parent) : // uncomment the following line if you want to use opaque undocking and // opaque splitter resizing - //CDockManager::setConfigFlags(CDockManager::DefaultOpaqueConfig); + CDockManager::setConfigFlags(CDockManager::DefaultOpaqueConfig); // uncomment the following line if you want a fixed tab width that does // not change if the visibility of the close button changes diff --git a/src/AutoHideDockContainer.cpp b/src/AutoHideDockContainer.cpp index b5d404b..0ba25e1 100644 --- a/src/AutoHideDockContainer.cpp +++ b/src/AutoHideDockContainer.cpp @@ -486,6 +486,18 @@ void CAutoHideDockContainer::setSize(int Size) updateSize(); } +bool is_ancestor_of (const QObject *descendant, const QObject *ancestor) +{ + if (!ancestor) + return false; + while (descendant) { + if (descendant == ancestor) + return true; + descendant = descendant->parent(); + } + return false; +} + //============================================================================ bool CAutoHideDockContainer::eventFilter(QObject* watched, QEvent* event) @@ -503,17 +515,21 @@ bool CAutoHideDockContainer::eventFilter(QObject* watched, QEvent* event) { // If the user clicked into another window, then we collapse the // auto hide widget + /*qDebug() << 1; + qDebug() << "is_ancestor_of " << is_ancestor_of(watched, this); auto widget = qobject_cast(watched); + qDebug() << "isAnchestorOf" << isAncestorOf(widget); if (widget && widget->window() != this->window()) { collapseView(true); return Super::eventFilter(watched, event); - } + }*/ // We check, if the mouse button press is inside the container // widget. If it is not, i.e. if someone resizes the main window or // clicks into the application menu or toolbar, then we ignore the // event + qDebug() << 2; auto Container = dockContainer(); QMouseEvent* me = static_cast(event); auto GlobalPos = internal::globalPositionOf(me); @@ -527,6 +543,7 @@ bool CAutoHideDockContainer::eventFilter(QObject* watched, QEvent* event) // If the click is inside of this auto hide container, then we can also // ignore the event, because the auto hide overlay should not get collapsed if // user works in it + qDebug() << 3; pos = mapFromGlobal(GlobalPos); if (rect().contains(pos)) { @@ -537,6 +554,7 @@ bool CAutoHideDockContainer::eventFilter(QObject* watched, QEvent* event) // because the side tab click handler will call collapseView(). If we // do not ignore this here, then we will collapse the container and the side tab // click handler will uncollapse it + qDebug() << 4; auto SideTab = d->SideTab; pos = SideTab->mapFromGlobal(GlobalPos); if (SideTab->rect().contains(pos)) @@ -547,9 +565,11 @@ bool CAutoHideDockContainer::eventFilter(QObject* watched, QEvent* event) // If the mouse button down event is in the dock manager but outside // of the open auto hide container, then the auto hide dock widget // should get collapsed + qDebug() << 5; collapseView(true); } - else if (event->type() == internal::FloatingWidgetDragStartEvent) + else if (event->type() == internal::FloatingWidgetDragStartEvent + || event->type() == internal::DockedWidgetDragStartEvent) { collapseView(true); } diff --git a/src/DockWidgetTab.cpp b/src/DockWidgetTab.cpp index 7a81942..31e6f15 100644 --- a/src/DockWidgetTab.cpp +++ b/src/DockWidgetTab.cpp @@ -333,9 +333,11 @@ bool DockWidgetTabPrivate::startFloating(eDragState DraggingState) if (DraggingFloatingWidget == DraggingState) { FloatingWidget->startFloating(DragStartMousePosition, Size, DraggingFloatingWidget, _this); - auto Overlay = DockWidget->dockManager()->containerOverlay(); + auto DockManager = DockWidget->dockManager(); + auto Overlay = DockManager->containerOverlay(); Overlay->setAllowedAreas(OuterDockAreas); this->FloatingWidget = FloatingWidget; + qApp->postEvent(DockManager, new QEvent((QEvent::Type)internal::DockedWidgetDragStartEvent)); } else { diff --git a/src/ads_globals.cpp b/src/ads_globals.cpp index c2e4681..c096188 100644 --- a/src/ads_globals.cpp +++ b/src/ads_globals.cpp @@ -51,6 +51,7 @@ namespace ads namespace internal { const int FloatingWidgetDragStartEvent = QEvent::registerEventType(); +const int DockedWidgetDragStartEvent = QEvent::registerEventType(); #ifdef Q_OS_LINUX static QString _window_manager; static QHash _xcb_atom_cache; diff --git a/src/ads_globals.h b/src/ads_globals.h index e82853a..24a65c7 100644 --- a/src/ads_globals.h +++ b/src/ads_globals.h @@ -152,6 +152,7 @@ static const bool Restore = false; static const char* const ClosedProperty = "close"; static const char* const DirtyProperty = "dirty"; extern const int FloatingWidgetDragStartEvent; +extern const int DockedWidgetDragStartEvent; #ifdef Q_OS_LINUX // Utils to directly communicate with the X server