From 7f58877a47096f23efe031d9c0412d1339e1d3e5 Mon Sep 17 00:00:00 2001 From: Uwe Date: Tue, 15 Nov 2022 08:44:07 +0100 Subject: [PATCH] Added FloatingWidgetDragStartEvent to hide AutoHideContainer if user drags floating widget --- src/AutoHideDockContainer.cpp | 6 +++++- src/FloatingDockContainer.cpp | 9 ++++++++- src/ads_globals.cpp | 1 + src/ads_globals.h | 1 + 4 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/AutoHideDockContainer.cpp b/src/AutoHideDockContainer.cpp index 03f34c0..c63e17c 100644 --- a/src/AutoHideDockContainer.cpp +++ b/src/AutoHideDockContainer.cpp @@ -471,7 +471,7 @@ void CAutoHideDockContainer::setSize(int Size) //============================================================================ bool CAutoHideDockContainer::eventFilter(QObject* watched, QEvent* event) { - if (event->type() == QEvent::Resize) + if (event->type() == QEvent::Resize) { if (!d->ResizeHandle->isResizing()) { @@ -539,6 +539,10 @@ bool CAutoHideDockContainer::eventFilter(QObject* watched, QEvent* event) collapseView(true); } } + else if (event->type() == internal::FloatingWidgetDragStartEvent) + { + collapseView(true); + } return Super::eventFilter(watched, event); } diff --git a/src/FloatingDockContainer.cpp b/src/FloatingDockContainer.cpp index 2152b6b..6de5904 100644 --- a/src/FloatingDockContainer.cpp +++ b/src/FloatingDockContainer.cpp @@ -406,7 +406,13 @@ struct FloatingDockContainerPrivate void setState(eDragState StateId) { + auto OldState = DraggingState; DraggingState = StateId; + if (DraggingInactive == OldState && DraggingFloatingWidget == DraggingState) + { + qDebug() << "Start dragging floating widget " << internal::FloatingWidgetDragStartEvent; + qApp->postEvent(DockManager, new QEvent((QEvent::Type)internal::FloatingWidgetDragStartEvent)); + } } void setWindowTitle(const QString &Text) @@ -1281,12 +1287,13 @@ void CFloatingDockContainer::moveEvent(QMoveEvent *event) Super::moveEvent(event); if (!d->IsResizing && event->spontaneous() && s_mousePressed) { - d->DraggingState = DraggingFloatingWidget; + d->setState(DraggingFloatingWidget); d->updateDropOverlays(QCursor::pos()); } d->IsResizing = false; } + //============================================================================ bool CFloatingDockContainer::event(QEvent *e) { diff --git a/src/ads_globals.cpp b/src/ads_globals.cpp index 3971abf..29743fc 100644 --- a/src/ads_globals.cpp +++ b/src/ads_globals.cpp @@ -53,6 +53,7 @@ namespace internal #ifdef Q_OS_LINUX static QString _window_manager; static QHash _xcb_atom_cache; +const int FloatingWidgetDragStartEvent = QEvent::registerEventType(); //============================================================================ diff --git a/src/ads_globals.h b/src/ads_globals.h index 1b86b01..e82853a 100644 --- a/src/ads_globals.h +++ b/src/ads_globals.h @@ -151,6 +151,7 @@ static const bool RestoreTesting = true; static const bool Restore = false; static const char* const ClosedProperty = "close"; static const char* const DirtyProperty = "dirty"; +extern const int FloatingWidgetDragStartEvent; #ifdef Q_OS_LINUX // Utils to directly communicate with the X server