tdf#136474 wait until mouse grab is dropped to trigger selection callback

Change-Id: I495b90b9661c32ad3ec71c2a2455d1576fb8f918
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102112
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
diff --git a/sd/source/ui/animations/CustomAnimationPane.cxx b/sd/source/ui/animations/CustomAnimationPane.cxx
index f7bfc28..1cff8f0 100644
--- a/sd/source/ui/animations/CustomAnimationPane.cxx
+++ b/sd/source/ui/animations/CustomAnimationPane.cxx
@@ -145,6 +145,7 @@ CustomAnimationPane::CustomAnimationPane( Window* pParent, ViewShellBase& rBase,
    , mxMFStartDelay(m_xBuilder->weld_metric_spin_button("delay_value", FieldUnit::SECOND))
    , mxCBAutoPreview(m_xBuilder->weld_check_button("auto_preview"))
    , mxPBPlay(m_xBuilder->weld_button("play"))
    , maIdle("sd idle treeview select")
    , mnLastSelectedAnimation(-1)
    , mnPropertyType(nPropertyTypeNone)
    , mnCurvePathPos(-1)
@@ -180,6 +181,9 @@ void CustomAnimationPane::initialize()
    mxMFStartDelay->connect_value_changed( LINK(this, CustomAnimationPane, DelayModifiedHdl) );
    mxMFStartDelay->connect_focus_out(LINK( this, CustomAnimationPane, DelayLoseFocusHdl));

    maIdle.SetPriority(TaskPriority::DEFAULT);
    maIdle.SetInvokeHandler(LINK(this, CustomAnimationPane, SelectionHandler));

    maStrModify = mxFTEffect->get_label();

    // get current controller and initialize listeners
@@ -2073,6 +2077,17 @@ IMPL_LINK_NOARG(CustomAnimationPane, DelayLoseFocusHdl, weld::Widget&, void)

IMPL_LINK_NOARG(CustomAnimationPane, AnimationSelectHdl, weld::TreeView&, void)
{
    maIdle.Start();
}

IMPL_LINK_NOARG(CustomAnimationPane, SelectionHandler, Timer*, void)
{
    if (mxLBAnimation->has_grab()) // tdf#136474 try again later
    {
        maIdle.Start();
        return;
    }

    int nSelected = mxLBAnimation->get_selected_index();

    // tdf#99137, the selected entry may also be a subcategory title, so not an effect
diff --git a/sd/source/ui/animations/CustomAnimationPane.hxx b/sd/source/ui/animations/CustomAnimationPane.hxx
index 078bb5e..94b543d 100644
--- a/sd/source/ui/animations/CustomAnimationPane.hxx
+++ b/sd/source/ui/animations/CustomAnimationPane.hxx
@@ -113,6 +113,7 @@ private:
    DECL_LINK( DelayLoseFocusHdl, weld::Widget&, void );
    DECL_LINK( UpdateAnimationLB, weld::ComboBox&, void );
    DECL_LINK( AnimationSelectHdl, weld::TreeView&, void );
    DECL_LINK( SelectionHandler, Timer*, void );
    void implControlHdl(const weld::Widget* pControl);

private:
@@ -142,6 +143,8 @@ private:
    std::unique_ptr<weld::CheckButton> mxCBAutoPreview;
    std::unique_ptr<weld::Button> mxPBPlay;

    Idle maIdle;

    OUString    maStrModify;
    OUString    maStrProperty;