include/sfx2/weldutils.hxx      |    2 ++
 sfx2/source/appl/workwin.cxx    |    4 +++-
 sfx2/source/dialog/recfloat.cxx |   14 ++++++++++++++
 sfx2/source/inc/recfloat.hxx    |    2 ++
 4 files changed, 21 insertions(+), 1 deletion(-)

New commits:
commit 471c7d43a4ccdd6debd919cdf9a67f403ace110c
Author:     Caolán McNamara <caol...@redhat.com>
AuthorDate: Sun Mar 6 21:22:41 2022 +0000
Commit:     Caolán McNamara <caol...@redhat.com>
CommitDate: Mon Mar 7 10:00:33 2022 +0100

    improve scope
    
    Change-Id: I69e4e47dbc17f32dacda336f31acad7fff992088
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131089
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caol...@redhat.com>

diff --git a/sfx2/source/appl/workwin.cxx b/sfx2/source/appl/workwin.cxx
index ca0e55d5cdb8..4874db7ee5f6 100644
--- a/sfx2/source/appl/workwin.cxx
+++ b/sfx2/source/appl/workwin.cxx
@@ -992,7 +992,6 @@ void SfxWorkWindow::ShowChildren_Impl()
 
             if ( SfxChildVisibility::VISIBLE == (pCli->nVisible & 
SfxChildVisibility::VISIBLE) && bVisible )
             {
-                ShowFlags nFlags = pCli->bSetFocus ? ShowFlags::NONE : 
ShowFlags::NoFocusChange | ShowFlags::NoActivate;
                 if (pCli->xController)
                 {
                     if (!pCli->xController->getDialog()->get_visible())
@@ -1007,7 +1006,10 @@ void SfxWorkWindow::ShowChildren_Impl()
                     }
                 }
                 else
+                {
+                    ShowFlags nFlags = pCli->bSetFocus ? ShowFlags::NONE : 
ShowFlags::NoFocusChange | ShowFlags::NoActivate;
                     pCli->pWin->Show(true, nFlags);
+                }
                 pCli->bSetFocus = false;
             }
             else
commit c641ca15f2a898b7ec66cf39ef4517a1221bab81
Author:     Caolán McNamara <caol...@redhat.com>
AuthorDate: Sun Mar 6 21:20:46 2022 +0000
Commit:     Caolán McNamara <caol...@redhat.com>
CommitDate: Mon Mar 7 10:00:16 2022 +0100

    tdf#147782 retain focus in launching frame on first activate
    
    Change-Id: I813c675ecf7c4a364f9d770af12e99275f510e7b
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131088
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caol...@redhat.com>

diff --git a/include/sfx2/weldutils.hxx b/include/sfx2/weldutils.hxx
index 81c4cb85dcab..aaa2fe08a2e3 100644
--- a/include/sfx2/weldutils.hxx
+++ b/include/sfx2/weldutils.hxx
@@ -56,6 +56,8 @@ public:
     css::uno::Reference<css::frame::XToolbarController>
     GetControllerForCommand(const OUString& rCommand) const;
 
+    css::uno::Reference<css::frame::XFrame> GetFrame() const { return 
m_xFrame; }
+
     void dispose();
     ~ToolbarUnoDispatcher();
 };
diff --git a/sfx2/source/dialog/recfloat.cxx b/sfx2/source/dialog/recfloat.cxx
index 18833ea5edfa..6a6fc17dbd9a 100644
--- a/sfx2/source/dialog/recfloat.cxx
+++ b/sfx2/source/dialog/recfloat.cxx
@@ -17,6 +17,7 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
+#include <com/sun/star/awt/XTopWindow.hpp>
 #include <com/sun/star/frame/XDispatchRecorder.hpp>
 
 #include <svl/eitem.hxx>
@@ -101,6 +102,7 @@ SfxRecordingFloat_Impl::SfxRecordingFloat_Impl(SfxBindings* 
pBind, SfxChildWindo
                                   "FloatingRecord")
     , m_xToolbar(m_xBuilder->weld_toolbar("toolbar"))
     , m_xDispatcher(new ToolbarUnoDispatcher(*m_xToolbar, *m_xBuilder, 
pBind->GetActiveFrame()))
+    , m_bFirstActivate(true)
 {
     // start recording
     SfxBoolItem aItem( SID_RECORDMACRO, true );
@@ -108,6 +110,18 @@ 
SfxRecordingFloat_Impl::SfxRecordingFloat_Impl(SfxBindings* pBind, SfxChildWindo
             SfxCallMode::SYNCHRON, { &aItem });
 }
 
+void SfxRecordingFloat_Impl::Activate()
+{
+    SfxModelessDialogController::Activate();
+    if (!m_bFirstActivate)
+        return;
+    // tdf#147782 retain focus in launching frame on the first activate on 
automatically gaining focus on getting launched
+    m_bFirstActivate = false;
+    css::uno::Reference<css::awt::XTopWindow> 
xTopWindow(m_xDispatcher->GetFrame()->getContainerWindow(), 
css::uno::UNO_QUERY);
+    if (xTopWindow.is())
+        xTopWindow->toFront();
+}
+
 SfxRecordingFloat_Impl::~SfxRecordingFloat_Impl()
 {
     m_xDispatcher->dispose();
diff --git a/sfx2/source/inc/recfloat.hxx b/sfx2/source/inc/recfloat.hxx
index e25ad7f08fda..b7a4882cd72e 100644
--- a/sfx2/source/inc/recfloat.hxx
+++ b/sfx2/source/inc/recfloat.hxx
@@ -42,12 +42,14 @@ class SfxRecordingFloat_Impl final : public 
SfxModelessDialogController
 {
     std::unique_ptr<weld::Toolbar> m_xToolbar;
     std::unique_ptr<ToolbarUnoDispatcher> m_xDispatcher;
+    bool m_bFirstActivate;
 public:
     SfxRecordingFloat_Impl(SfxBindings* pBindings,
                            SfxChildWindow* pChildWin,
                            weld::Window* pParent);
     virtual ~SfxRecordingFloat_Impl() override;
     virtual void FillInfo(SfxChildWinInfo& rInfo) const override;
+    virtual void Activate() override;
 };
 
 #endif

Reply via email to