vcl/unx/generic/dtrans/X11_droptarget.cxx | 2 +- vcl/unx/generic/dtrans/X11_selection.cxx | 26 +++++++++----------------- vcl/unx/generic/dtrans/X11_selection.hxx | 8 ++------ vcl/unx/generic/dtrans/X11_service.cxx | 28 +++++++++++----------------- 4 files changed, 23 insertions(+), 41 deletions(-)
New commits: commit 7698167b85c2c54e02edfd7070de7482b236ab9e Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Fri Jul 4 09:47:26 2025 +0200 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Sat Jul 5 07:44:07 2025 +0200 gen: Simplify SelectionManager init, don't use XInitialization So far, the initialization of SelectionManager in the gen/x11 VCL plugin was done using the XInitialization UNO interface. The first was the XDisplayConnection retrieved via Application::GetDisplayConnection for all callers, all other args were ignored. Simplify this by retrieving the XDisplayConnection directly inside SelectionManager::initialize instead, and no longer take any arguments. No longer implement the XInitialization interface, as this is all only used in the gen VCL plugin internally. Change-Id: I107edb498b410da14f97979944c7ea900016d0c4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/187365 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> diff --git a/vcl/unx/generic/dtrans/X11_droptarget.cxx b/vcl/unx/generic/dtrans/X11_droptarget.cxx index 0c0b8e99d869..02b20ebeb088 100644 --- a/vcl/unx/generic/dtrans/X11_droptarget.cxx +++ b/vcl/unx/generic/dtrans/X11_droptarget.cxx @@ -51,7 +51,7 @@ void DropTarget::initialize( const Sequence< Any >& arguments ) return; m_xSelectionManager = &SelectionManager::get(); - m_xSelectionManager->initialize( arguments ); + m_xSelectionManager->initialize(); if( m_xSelectionManager->getDisplay() ) // #136582# sanity check { diff --git a/vcl/unx/generic/dtrans/X11_selection.cxx b/vcl/unx/generic/dtrans/X11_selection.cxx index 982adba77b78..38e9ff9935a7 100644 --- a/vcl/unx/generic/dtrans/X11_selection.cxx +++ b/vcl/unx/generic/dtrans/X11_selection.cxx @@ -317,15 +317,14 @@ Cursor SelectionManager::createCursor( const unsigned char* pPointerData, const return aCursor; } -void SelectionManager::initialize( const Sequence< Any >& arguments ) +void SelectionManager::initialize() { osl::MutexGuard aGuard(m_aMutex); if( ! m_xDisplayConnection.is() ) { /* - * first argument must be a css::awt::XDisplayConnection - * from this we will get the XEvents of the vcl event loop by + * We will get the XEvents of the vcl event loop from the css::awt::XDisplayConnection by * registering us as XEventHandler on it. * * implementor's note: @@ -335,13 +334,9 @@ void SelectionManager::initialize( const Sequence< Any >& arguments ) * needs to be added. The display used would be that of the normal event loop * and synchronization should be done via the SolarMutex. */ - if( arguments.hasElements() ) - arguments.getConstArray()[0] >>= m_xDisplayConnection; - if( ! m_xDisplayConnection.is() ) - { - } - else - m_xDisplayConnection->addEventHandler( Any(), this, ~0 ); + m_xDisplayConnection = Application::GetDisplayConnection(); + assert(m_xDisplayConnection.is()); + m_xDisplayConnection->addEventHandler(Any(), this, ~0); } if( m_pDisplay ) @@ -4078,11 +4073,8 @@ css::uno::Reference< XInterface > SelectionManager::getReference() noexcept * SelectionManagerHolder */ -SelectionManagerHolder::SelectionManagerHolder() : - ::cppu::WeakComponentImplHelper< - XDragSource, - XInitialization, - XServiceInfo > (m_aMutex) +SelectionManagerHolder::SelectionManagerHolder() + : ::cppu::WeakComponentImplHelper<XDragSource, XServiceInfo>(m_aMutex) { } @@ -4090,10 +4082,10 @@ SelectionManagerHolder::~SelectionManagerHolder() { } -void SelectionManagerHolder::initialize( const Sequence< Any >& arguments ) +void SelectionManagerHolder::initialize() { SelectionManager& rManager = SelectionManager::get(); - rManager.initialize( arguments ); + rManager.initialize(); m_xRealDragSource = &rManager; } diff --git a/vcl/unx/generic/dtrans/X11_selection.hxx b/vcl/unx/generic/dtrans/X11_selection.hxx index ce89ffc64b70..8cc9e4212800 100644 --- a/vcl/unx/generic/dtrans/X11_selection.hxx +++ b/vcl/unx/generic/dtrans/X11_selection.hxx @@ -109,7 +109,6 @@ namespace x11 { class SelectionManagerHolder : public ::cppu::WeakComponentImplHelper< css::datatransfer::dnd::XDragSource, - css::lang::XInitialization, css::lang::XServiceInfo > { @@ -126,8 +125,7 @@ namespace x11 { virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override; - // XInitialization - virtual void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any >& arguments ) override; + void initialize(); // XDragSource virtual sal_Bool SAL_CALL isDragImageSupported() override; @@ -144,7 +142,6 @@ namespace x11 { class SelectionManager : public ::cppu::WeakImplHelper< css::datatransfer::dnd::XDragSource, - css::lang::XInitialization, css::awt::XEventHandler, css::frame::XTerminateListener >, @@ -452,8 +449,7 @@ namespace x11 { void shutdown() noexcept; - // XInitialization - virtual void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any >& arguments ) override; + void initialize(); // XEventHandler virtual sal_Bool SAL_CALL handleEvent(const css::uno::Any& event) override; diff --git a/vcl/unx/generic/dtrans/X11_service.cxx b/vcl/unx/generic/dtrans/X11_service.cxx index 38487685cdde..3237122fcec5 100644 --- a/vcl/unx/generic/dtrans/X11_service.cxx +++ b/vcl/unx/generic/dtrans/X11_service.cxx @@ -56,8 +56,7 @@ X11SalInstance::CreateClipboard(const Sequence<Any>& arguments) return SalInstance::CreateClipboard( arguments ); SelectionManager& rManager = SelectionManager::get(); - css::uno::Sequence<css::uno::Any> mgrArgs{ css::uno::Any(Application::GetDisplayConnection()) }; - rManager.initialize(mgrArgs); + rManager.initialize(); OUString sel; if (!arguments.hasElements()) { @@ -80,16 +79,10 @@ X11SalInstance::CreateClipboard(const Sequence<Any>& arguments) } css::uno::Reference<css::datatransfer::dnd::XDragSource> -X11SalInstance::ImplCreateDragSource(const SystemEnvData* pSysEnv) +X11SalInstance::ImplCreateDragSource(const SystemEnvData*) { rtl::Reference<SelectionManagerHolder> xSelectionManagerHolder = new SelectionManagerHolder(); - - X11SalFrame* pFrame = static_cast<X11SalFrame*>(pSysEnv->pSalFrame); - ::Window aShellWindow = pFrame ? pFrame->GetShellWindow() : 0; - if (aShellWindow) - xSelectionManagerHolder->initialize( - { css::uno::Any(Application::GetDisplayConnection()), - css::uno::Any(static_cast<sal_uInt64>(aShellWindow)) }); + xSelectionManagerHolder->initialize(); return xSelectionManagerHolder; } commit 4f1df46b0b036ddd894de4e4aa40be0456ad46fe Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Fri Jul 4 09:13:41 2025 +0200 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Sat Jul 5 07:43:58 2025 +0200 gen: Inline InitializeDnD logic to callers While it adds some slight deduplication now, it prepares for simplification in upcoming commits (moving away from doing the initialization via the XInitialization UNO interface). Change-Id: I56ea4f1dc9f6a16e75e3daf7ec3f1548944c47c6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/187364 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> diff --git a/vcl/unx/generic/dtrans/X11_service.cxx b/vcl/unx/generic/dtrans/X11_service.cxx index c8f0a2b6c3b8..38487685cdde 100644 --- a/vcl/unx/generic/dtrans/X11_service.cxx +++ b/vcl/unx/generic/dtrans/X11_service.cxx @@ -34,18 +34,6 @@ using namespace com::sun::star::lang; using namespace com::sun::star::datatransfer::clipboard; using namespace x11; -namespace -{ -void InitializeDnD(const css::uno::Reference<css::lang::XInitialization>& xDnD, - const X11SalFrame* pFrame) -{ - ::Window aShellWindow = pFrame ? pFrame->GetShellWindow() : 0; - if (aShellWindow && xDnD) - xDnD->initialize({ css::uno::Any(Application::GetDisplayConnection()), - css::uno::Any(static_cast<sal_uInt64>(aShellWindow)) }); -} -} - Sequence< OUString > x11::X11Clipboard_getSupportedServiceNames() { return { u"com.sun.star.datatransfer.clipboard.SystemClipboard"_ustr }; @@ -95,7 +83,14 @@ css::uno::Reference<css::datatransfer::dnd::XDragSource> X11SalInstance::ImplCreateDragSource(const SystemEnvData* pSysEnv) { rtl::Reference<SelectionManagerHolder> xSelectionManagerHolder = new SelectionManagerHolder(); - InitializeDnD(xSelectionManagerHolder, static_cast<X11SalFrame*>(pSysEnv->pSalFrame)); + + X11SalFrame* pFrame = static_cast<X11SalFrame*>(pSysEnv->pSalFrame); + ::Window aShellWindow = pFrame ? pFrame->GetShellWindow() : 0; + if (aShellWindow) + xSelectionManagerHolder->initialize( + { css::uno::Any(Application::GetDisplayConnection()), + css::uno::Any(static_cast<sal_uInt64>(aShellWindow)) }); + return xSelectionManagerHolder; } @@ -103,7 +98,13 @@ css::uno::Reference<css::datatransfer::dnd::XDropTarget> X11SalInstance::ImplCreateDropTarget(const SystemEnvData* pSysEnv) { rtl::Reference<DropTarget> xDropTarget = new DropTarget(); - InitializeDnD(xDropTarget, static_cast<X11SalFrame*>(pSysEnv->pSalFrame)); + + X11SalFrame* pFrame = static_cast<X11SalFrame*>(pSysEnv->pSalFrame); + ::Window aShellWindow = pFrame ? pFrame->GetShellWindow() : 0; + if (aShellWindow) + xDropTarget->initialize({ css::uno::Any(Application::GetDisplayConnection()), + css::uno::Any(static_cast<sal_uInt64>(aShellWindow)) }); + return xDropTarget; }