Enable undocking of sidebar by dragging a deck grip

Change-Id: I59d15b4c61045bfd97dd937e6f383652db33fd8f
Reviewed-on: https://gerrit.libreoffice.org/53496
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Katarina Behrens <Katarina.Behrens@cib.de>
diff --git a/include/vcl/dockwin.hxx b/include/vcl/dockwin.hxx
index 905500e..a4f99a7 100644
--- a/include/vcl/dockwin.hxx
+++ b/include/vcl/dockwin.hxx
@@ -270,7 +270,8 @@ public:
    bool            isLayoutEnabled() const;
    void            setOptimalLayoutSize();

    SAL_DLLPRIVATE void    ImplStartDocking( const Point& rPos );
    //FIXME: is it okay to make this public?
    void    ImplStartDocking( const Point& rPos );
    SAL_DLLPRIVATE bool    isDeferredInit() const { return mbIsDeferredInit; }
    virtual        void    doDeferredInit(WinBits nBits);
protected:
diff --git a/sfx2/source/sidebar/SidebarDockingWindow.cxx b/sfx2/source/sidebar/SidebarDockingWindow.cxx
index 11ebe76..e241ab6c 100644
--- a/sfx2/source/sidebar/SidebarDockingWindow.cxx
+++ b/sfx2/source/sidebar/SidebarDockingWindow.cxx
@@ -117,7 +117,7 @@ bool SidebarDockingWindow::EventNotify(NotifyEvent& rEvent)
    if (MouseNotifyEvent::KEYINPUT == nType)
        return true;

    if ( MouseNotifyEvent::MOUSEBUTTONDOWN == nType)
    if (MouseNotifyEvent::MOUSEBUTTONDOWN == nType)
    {
        const MouseEvent *mEvt = rEvent.GetMouseEvent();
        if (mEvt->IsLeft())
@@ -127,6 +127,22 @@ bool SidebarDockingWindow::EventNotify(NotifyEvent& rEvent)
                SetReadyToDrag( true );
        }
    }
    else if (MouseNotifyEvent::MOUSEMOVE == nType)
    {
        const MouseEvent *mEvt = rEvent.GetMouseEvent();
        tools::Rectangle aGrip = mpSidebarController->GetDeckDragArea();
        if (mEvt->IsLeft() && aGrip.IsInside( mEvt->GetPosPixel() ) && IsReadyToDrag() )
        {
            Point aPos = mEvt->GetPosPixel();
            vcl::Window* pWindow = rEvent.GetWindow();
            if ( pWindow != this )
            {
                aPos = pWindow->OutputToScreenPixel( aPos );
                aPos = ScreenToOutputPixel( aPos );
            }
            ImplStartDocking( aPos );
        }
    }

    return SfxDockingWindow::EventNotify(rEvent);
}