diff --git a/examples/dockwidgets/main.cpp b/examples/dockwidgets/main.cpp index 24e4a4ad..b7a87c43 100644 --- a/examples/dockwidgets/main.cpp +++ b/examples/dockwidgets/main.cpp @@ -271,7 +271,8 @@ int main(int argc, char **argv) // Dock widget 8 will only be allowed to dock to the outter areas auto func = [](KDDockWidgets::DropLocation location, const KDDockWidgets::Controllers::DockWidget::List &source, - const KDDockWidgets::Controllers::DockWidget::List &target) { + const KDDockWidgets::Controllers::DockWidget::List &target, + Controllers::DropArea *) { Q_UNUSED(target); // When dragging into a tab, 'target' would have the list of already tabbed dock widgets const bool isDraggingDW8 = std::find_if(source.cbegin(), source.cend(), [](KDDockWidgets::Controllers::DockWidget *dw) { diff --git a/src/Config.h b/src/Config.h index ab7cadfe..992c9920 100644 --- a/src/Config.h +++ b/src/Config.h @@ -33,6 +33,7 @@ namespace KDDockWidgets { namespace Controllers { class DockWidget; class MainWindow; +class DropArea; } class ViewFactory; @@ -49,11 +50,13 @@ typedef KDDockWidgets::Controllers::MainWindow *(*MainWindowFactoryFunc)(const Q /// @param location The drop indicator location to allow or disallow /// @param source The dock widgets being dragged /// @param target The dock widgets within an existing docked tab group +/// @param dropArea The target drop area. Can belong to a MainWindow or a FloatingWindow. /// @return true if the docking is allowed. /// @sa setDropIndicatorAllowedFunc typedef bool (*DropIndicatorAllowedFunc)(DropLocation location, const QVector &source, - const QVector &target); + const QVector &target, + Controllers::DropArea *dropArea); /// @deprecated Use DropIndicatorAllowedFunc instead. /// @brief Function to allow the user more granularity to disallow dock widgets to tab together @@ -261,7 +264,8 @@ public: * * auto func = [] (KDDockWidgets::DropLocation loc, * const KDDockWidgets::Controllers::DockWidget::List &source, - * const KDDockWidgets::Controllers::DockWidget::List &target) + * const KDDockWidgets::Controllers::DockWidget::List &target, + * KDDockWidgets::Controllers::DropArea *) * { * // disallows dockFoo to be docked to outter areas * return !((loc & KDDockWidgets::DropLocation_Outter) && source.contains(dockFoo)); diff --git a/src/controllers/DropIndicatorOverlay.cpp b/src/controllers/DropIndicatorOverlay.cpp index d04ffa79..79328ffd 100644 --- a/src/controllers/DropIndicatorOverlay.cpp +++ b/src/controllers/DropIndicatorOverlay.cpp @@ -165,7 +165,8 @@ bool DropIndicatorOverlay::dropIndicatorVisible(DropLocation dropLoc) const } if (auto dropIndicatorAllowedFunc = Config::self().dropIndicatorAllowedFunc()) { - if (!dropIndicatorAllowedFunc(dropLoc, source, target)) + DropArea *dropArea = DragController::instance()->dropAreaUnderCursor(); + if (!dropIndicatorAllowedFunc(dropLoc, source, target, dropArea)) return false; } diff --git a/src/private/DragController_p.h b/src/private/DragController_p.h index e89eaf7f..b3e55144 100644 --- a/src/private/DragController_p.h +++ b/src/private/DragController_p.h @@ -98,6 +98,9 @@ public: Controllers::FloatingWindow *floatingWindowBeingDragged() const; + /// @brief Returns the current drop area under the mouse + Controllers::DropArea *dropAreaUnderCursor() const; + ///@brief Returns the window being dragged WindowBeingDragged *windowBeingDragged() const; @@ -128,7 +131,6 @@ private: DragController(QObject * = nullptr); StateBase *activeState() const; ViewWrapper::Ptr qtTopLevelUnderCursor() const; - Controllers::DropArea *dropAreaUnderCursor() const; Draggable *draggableForQObject(QObject *o) const; QPoint m_pressPos; QPoint m_offset;