Resolves: tdf#146825 select under mouse on right click

if something isn't already selected

Change-Id: Ifa692cd71bb71ecb5c7af732deef510f2bac5fce
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131111
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
diff --git a/sd/source/ui/animations/CustomAnimationList.cxx b/sd/source/ui/animations/CustomAnimationList.cxx
index c5690a0..9dcde6d 100644
--- a/sd/source/ui/animations/CustomAnimationList.cxx
+++ b/sd/source/ui/animations/CustomAnimationList.cxx
@@ -1147,6 +1147,22 @@ IMPL_LINK(CustomAnimationList, CommandHdl, const CommandEvent&, rCEvt, bool)
    if (rCEvt.GetCommand() != CommandEventId::ContextMenu)
        return false;

    if (rCEvt.IsMouseEvent())
    {
        ::Point aPos = rCEvt.GetMousePosPixel();
        std::unique_ptr<weld::TreeIter> xIter(mxTreeView->make_iterator());
        if (mxTreeView->get_dest_row_at_pos(aPos, xIter.get(), false) && !mxTreeView->is_selected(*xIter))
        {
            mxTreeView->unselect_all();
            mxTreeView->set_cursor(*xIter);
            mxTreeView->select(*xIter);
            SelectHdl(*mxTreeView);
        }
    }

    if (!mxTreeView->get_selected(nullptr))
        return false;

    std::unique_ptr<weld::Builder> xBuilder(Application::CreateBuilder(mxTreeView.get(), "modules/simpress/ui/effectmenu.ui"));
    std::unique_ptr<weld::Menu> xMenu = xBuilder->weld_menu("menu");