include/sfx2/weldutils.hxx | 2 ++ sfx2/source/dialog/recfloat.cxx | 14 ++++++++++++++ sfx2/source/inc/recfloat.hxx | 2 ++ 3 files changed, 18 insertions(+)
New commits: commit 57ec3c4a40847b28390e1c208d5c771409ff1cab Author: Caolán McNamara <[email protected]> AuthorDate: Sun Mar 6 21:20:46 2022 +0000 Commit: Xisco Fauli <[email protected]> CommitDate: Thu Mar 10 10:28:28 2022 +0100 tdf#147782 retain focus in launching frame on first activate Change-Id: I813c675ecf7c4a364f9d770af12e99275f510e7b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131017 Tested-by: Jenkins Reviewed-by: Xisco Fauli <[email protected]> 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
