vcl/inc/displayconnectiondispatch.hxx | 5 +- vcl/inc/salinst.hxx | 2 vcl/source/app/salvtables.cxx | 4 - vcl/source/helper/displayconnectiondispatch.cxx | 10 +--- vcl/unx/generic/app/saldisp.cxx | 2 vcl/unx/generic/dtrans/X11_selection.cxx | 50 +++++++++--------------- vcl/unx/generic/dtrans/X11_selection.hxx | 9 +--- 7 files changed, 33 insertions(+), 49 deletions(-)
New commits: commit d407de929a10a2ce0d15d7a9c60c7f6195b1ebba Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Fri Jul 4 16:09:21 2025 +0200 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Sat Jul 5 07:45:32 2025 +0200 vcl: Avoid pointer -> Sequence -> pointer conversion In SalInstance::CallEventCallback and DisplayConnectionDispatch::dispatchEvent, stop converting the pointer to a Sequence<sal_Int8>, just to reinterpret_cast it as a pointer again later in SelectionManager::handleEvent. This might have made sense in the past when data still had to be passed over UNO interfaces, but that's no longer the case after Change-Id: Iaf08f4aee3fea99d9d5d5c907d107452812d187d Author: Michael Weghorn <m.wegh...@posteo.de> Date: Fri Jul 4 14:51:17 2025 +0200 vcl: No longer use css::awt::XEventHandler , so simply pass a single `const void*` argument and cast it to the expected XEvent* again. Change-Id: I54e3a85884a0e0a727f8bf0a5505835d1fdd1b0c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/187404 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> diff --git a/vcl/inc/displayconnectiondispatch.hxx b/vcl/inc/displayconnectiondispatch.hxx index fd0a78a4ec90..f8d41393b03b 100644 --- a/vcl/inc/displayconnectiondispatch.hxx +++ b/vcl/inc/displayconnectiondispatch.hxx @@ -32,7 +32,7 @@ namespace vcl { class DisplayEventHandler : public cppu::WeakImplHelper<> { public: - virtual bool handleEvent(const css::uno::Sequence<sal_Int8>& rEvent) = 0; + virtual bool handleEvent(const void* pEvent) = 0; virtual void shutdown() noexcept = 0; }; @@ -48,7 +48,7 @@ public: void start(); void terminate(); - bool dispatchEvent( void const * pData, int nBytes ); + bool dispatchEvent(const void* pEvent); void addEventHandler(const rtl::Reference<DisplayEventHandler>& handler); void removeEventHandler(const rtl::Reference<DisplayEventHandler>& handler); diff --git a/vcl/inc/salinst.hxx b/vcl/inc/salinst.hxx index b43594341c3e..bc2e350df175 100644 --- a/vcl/inc/salinst.hxx +++ b/vcl/inc/salinst.hxx @@ -184,7 +184,7 @@ public: void SetEventCallback( rtl::Reference< vcl::DisplayConnectionDispatch > const & pInstance ) { m_pEventInst = pInstance; } - bool CallEventCallback( void const * pEvent, int nBytes ); + bool CallEventCallback(const void* pEvent); virtual OUString GetConnectionIdentifier(); diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx index fdce55ced8d4..4bc1989c4966 100644 --- a/vcl/source/app/salvtables.cxx +++ b/vcl/source/app/salvtables.cxx @@ -161,9 +161,9 @@ std::unique_ptr<SalMenu> SalInstance::CreateMenu(bool, Menu*) std::unique_ptr<SalMenuItem> SalInstance::CreateMenuItem(const SalItemParams&) { return nullptr; } -bool SalInstance::CallEventCallback(void const* pEvent, int nBytes) +bool SalInstance::CallEventCallback(const void* pEvent) { - return m_pEventInst.is() && m_pEventInst->dispatchEvent(pEvent, nBytes); + return m_pEventInst.is() && m_pEventInst->dispatchEvent(pEvent); } OUString SalInstance::GetConnectionIdentifier() { return OUString(); } diff --git a/vcl/source/helper/displayconnectiondispatch.cxx b/vcl/source/helper/displayconnectiondispatch.cxx index be8af465bf8f..54e0358b7146 100644 --- a/vcl/source/helper/displayconnectiondispatch.cxx +++ b/vcl/source/helper/displayconnectiondispatch.cxx @@ -81,18 +81,17 @@ OUString DisplayConnectionDispatch::getIdentifier() return m_ConnectionIdentifier; } -bool DisplayConnectionDispatch::dispatchEvent( void const * pData, int nBytes ) +bool DisplayConnectionDispatch::dispatchEvent(const void* pEvent) { SolarMutexReleaser aRel; - Sequence< sal_Int8 > aSeq( static_cast<const sal_Int8*>(pData), nBytes ); std::vector<rtl::Reference<DisplayEventHandler>> handlers; { std::scoped_lock aGuard( m_aMutex ); handlers = m_aHandlers; } for (auto const& handle : handlers) - if (handle->handleEvent(aSeq)) + if (handle->handleEvent(pEvent)) return true; return false; } diff --git a/vcl/unx/generic/app/saldisp.cxx b/vcl/unx/generic/app/saldisp.cxx index 46f97074bc26..cd55a26eef4c 100644 --- a/vcl/unx/generic/app/saldisp.cxx +++ b/vcl/unx/generic/app/saldisp.cxx @@ -1906,7 +1906,7 @@ void SalX11Display::Dispatch( XEvent *pEvent ) } SalInstance* pInstance = GetSalInstance(); - pInstance->CallEventCallback( pEvent, sizeof( XEvent ) ); + pInstance->CallEventCallback(pEvent); switch( pEvent->type ) { diff --git a/vcl/unx/generic/dtrans/X11_selection.cxx b/vcl/unx/generic/dtrans/X11_selection.cxx index ca90d2c7e13a..5a5f0a38fa42 100644 --- a/vcl/unx/generic/dtrans/X11_selection.cxx +++ b/vcl/unx/generic/dtrans/X11_selection.cxx @@ -3865,19 +3865,18 @@ void SelectionManager::shutdown() noexcept m_xDropTransferable.clear(); } -bool SelectionManager::handleEvent(const css::uno::Sequence<sal_Int8>& rEvent) +bool SelectionManager::handleEvent(const void* pEvent) { - Sequence<sal_Int8> aSeq = rEvent; - XEvent* pEvent = reinterpret_cast<XEvent*>(aSeq.getArray()); + const XEvent* pXEvent = static_cast<const XEvent*>(pEvent); Time nTimestamp = CurrentTime; - if (pEvent->type == ButtonPress || pEvent->type == ButtonRelease) - nTimestamp = pEvent->xbutton.time; - else if (pEvent->type == KeyPress || pEvent->type == KeyRelease) - nTimestamp = pEvent->xkey.time; - else if (pEvent->type == MotionNotify) - nTimestamp = pEvent->xmotion.time; - else if (pEvent->type == PropertyNotify) - nTimestamp = pEvent->xproperty.time; + if (pXEvent->type == ButtonPress || pXEvent->type == ButtonRelease) + nTimestamp = pXEvent->xbutton.time; + else if (pXEvent->type == KeyPress || pXEvent->type == KeyRelease) + nTimestamp = pXEvent->xkey.time; + else if (pXEvent->type == MotionNotify) + nTimestamp = pXEvent->xmotion.time; + else if (pXEvent->type == PropertyNotify) + nTimestamp = pXEvent->xproperty.time; if (nTimestamp != CurrentTime) { @@ -3886,7 +3885,7 @@ bool SelectionManager::handleEvent(const css::uno::Sequence<sal_Int8>& rEvent) m_nSelectionTimestamp = nTimestamp; } - return handleXEvent(*pEvent); + return handleXEvent(*pXEvent); } void SAL_CALL SelectionManager::disposing( const css::lang::EventObject& rEvt ) diff --git a/vcl/unx/generic/dtrans/X11_selection.hxx b/vcl/unx/generic/dtrans/X11_selection.hxx index 5ccafd8f973f..0f96f7f271a6 100644 --- a/vcl/unx/generic/dtrans/X11_selection.hxx +++ b/vcl/unx/generic/dtrans/X11_selection.hxx @@ -440,7 +440,7 @@ namespace x11 { void initialize(); - virtual bool handleEvent(const css::uno::Sequence<sal_Int8>& rEvent) override; + virtual bool handleEvent(const void* pEvent) override; void shutdown() noexcept override; // XDragSource commit bd61a94c415432cc6685973484e86d3e0a14dc80 Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Fri Jul 4 16:12:17 2025 +0200 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Sat Jul 5 07:45:25 2025 +0200 gen: Make some event ref params const Change-Id: I684eb3daa61b6e87d99c694df76870e7246be855 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/187403 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> diff --git a/vcl/unx/generic/dtrans/X11_selection.cxx b/vcl/unx/generic/dtrans/X11_selection.cxx index 839191e61ded..ca90d2c7e13a 100644 --- a/vcl/unx/generic/dtrans/X11_selection.cxx +++ b/vcl/unx/generic/dtrans/X11_selection.cxx @@ -1566,7 +1566,7 @@ bool SelectionManager::sendData( SelectionAdaptor* pAdaptor, return bConverted; } -bool SelectionManager::handleSelectionRequest( XSelectionRequestEvent& rRequest ) +bool SelectionManager::handleSelectionRequest(const XSelectionRequestEvent& rRequest) { osl::ResettableMutexGuard aGuard( m_aMutex ); @@ -3620,7 +3620,7 @@ void SelectionManager::transferablesFlavorsChanged() * dispatch loop */ -bool SelectionManager::handleXEvent( XEvent& rEvent ) +bool SelectionManager::handleXEvent(const XEvent& rEvent) { /* * since we are XConnectionListener to a second X display diff --git a/vcl/unx/generic/dtrans/X11_selection.hxx b/vcl/unx/generic/dtrans/X11_selection.hxx index 4ccd9563a863..5ccafd8f973f 100644 --- a/vcl/unx/generic/dtrans/X11_selection.hxx +++ b/vcl/unx/generic/dtrans/X11_selection.hxx @@ -354,7 +354,7 @@ namespace x11 { PixmapHolder* getPixmapHolder( Atom selection ); // handle various events - bool handleSelectionRequest( XSelectionRequestEvent& rRequest ); + bool handleSelectionRequest(const XSelectionRequestEvent& rRequest); bool handleSendPropertyNotify( XPropertyEvent const & rNotify ); bool handleReceivePropertyNotify( XPropertyEvent const & rNotify ); bool handleSelectionNotify( XSelectionEvent const & rNotify ); @@ -391,7 +391,7 @@ namespace x11 { static void runDragExecute( void* ); private: void dragDoDispatch(); - bool handleXEvent( XEvent& rEvent ); + bool handleXEvent(const XEvent& rEvent); // compound text conversion OString convertToCompound( const OUString& rText ); commit c9fc2348c101615ede1ba4de4ecc737b451adfe1 Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Fri Jul 4 15:57:02 2025 +0200 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Sat Jul 5 07:45:19 2025 +0200 vcl: Split DisplayEventHandler::handleEvent logic So far, DisplayEventHandler::handleEvent was used for 2 different things: 1) To notify about termination. In that case, an empty Any was passed as param 2) To notify of an event. In that case, the event's pointer was passed as a Sequence, wrapped in an Any. For 1), instead add a new DisplayEventHandler::shutdown to call and mark the existing implementation in the gen vcl plugin's SelectionManager as overriding the new base class method. Switch the param for DisplayEventHandler::handleEvent from Any to Sequence, as 2) is the only remaining scenario handled by that method now. Change-Id: I7c9dbe8236afe3b87b9b7573aa54bbf7a0589968 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/187402 Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> Tested-by: Jenkins diff --git a/vcl/inc/displayconnectiondispatch.hxx b/vcl/inc/displayconnectiondispatch.hxx index 8044b6d410ce..fd0a78a4ec90 100644 --- a/vcl/inc/displayconnectiondispatch.hxx +++ b/vcl/inc/displayconnectiondispatch.hxx @@ -32,7 +32,8 @@ namespace vcl { class DisplayEventHandler : public cppu::WeakImplHelper<> { public: - virtual bool handleEvent(const ::css::uno::Any& rEvent) = 0; + virtual bool handleEvent(const css::uno::Sequence<sal_Int8>& rEvent) = 0; + virtual void shutdown() noexcept = 0; }; class VCL_DLLPUBLIC DisplayConnectionDispatch final : public cppu::OWeakObject diff --git a/vcl/source/helper/displayconnectiondispatch.cxx b/vcl/source/helper/displayconnectiondispatch.cxx index f7b8692b07a9..be8af465bf8f 100644 --- a/vcl/source/helper/displayconnectiondispatch.cxx +++ b/vcl/source/helper/displayconnectiondispatch.cxx @@ -56,10 +56,9 @@ void DisplayConnectionDispatch::terminate() SolarMutexReleaser aRel; std::scoped_lock aGuard( m_aMutex ); - Any aEvent; std::vector<rtl::Reference<DisplayEventHandler>> aLocalList(m_aHandlers); for (auto const& elem : aLocalList) - elem->handleEvent( aEvent ); + elem->shutdown(); } void DisplayConnectionDispatch::addEventHandler(const rtl::Reference<DisplayEventHandler>& handler) @@ -87,15 +86,13 @@ bool DisplayConnectionDispatch::dispatchEvent( void const * pData, int nBytes ) SolarMutexReleaser aRel; Sequence< sal_Int8 > aSeq( static_cast<const sal_Int8*>(pData), nBytes ); - Any aEvent; - aEvent <<= aSeq; std::vector<rtl::Reference<DisplayEventHandler>> handlers; { std::scoped_lock aGuard( m_aMutex ); handlers = m_aHandlers; } for (auto const& handle : handlers) - if( handle->handleEvent( aEvent ) ) + if (handle->handleEvent(aSeq)) return true; return false; } diff --git a/vcl/unx/generic/dtrans/X11_selection.cxx b/vcl/unx/generic/dtrans/X11_selection.cxx index 0134cd006fbd..839191e61ded 100644 --- a/vcl/unx/generic/dtrans/X11_selection.cxx +++ b/vcl/unx/generic/dtrans/X11_selection.cxx @@ -3865,39 +3865,28 @@ void SelectionManager::shutdown() noexcept m_xDropTransferable.clear(); } -bool SelectionManager::handleEvent(const Any& event) +bool SelectionManager::handleEvent(const css::uno::Sequence<sal_Int8>& rEvent) { - Sequence< sal_Int8 > aSeq; - if( event >>= aSeq ) + Sequence<sal_Int8> aSeq = rEvent; + XEvent* pEvent = reinterpret_cast<XEvent*>(aSeq.getArray()); + Time nTimestamp = CurrentTime; + if (pEvent->type == ButtonPress || pEvent->type == ButtonRelease) + nTimestamp = pEvent->xbutton.time; + else if (pEvent->type == KeyPress || pEvent->type == KeyRelease) + nTimestamp = pEvent->xkey.time; + else if (pEvent->type == MotionNotify) + nTimestamp = pEvent->xmotion.time; + else if (pEvent->type == PropertyNotify) + nTimestamp = pEvent->xproperty.time; + + if (nTimestamp != CurrentTime) { - XEvent* pEvent = reinterpret_cast<XEvent*>(aSeq.getArray()); - Time nTimestamp = CurrentTime; - if( pEvent->type == ButtonPress || pEvent->type == ButtonRelease ) - nTimestamp = pEvent->xbutton.time; - else if( pEvent->type == KeyPress || pEvent->type == KeyRelease ) - nTimestamp = pEvent->xkey.time; - else if( pEvent->type == MotionNotify ) - nTimestamp = pEvent->xmotion.time; - else if( pEvent->type == PropertyNotify ) - nTimestamp = pEvent->xproperty.time; - - if( nTimestamp != CurrentTime ) - { - osl::MutexGuard aGuard(m_aMutex); - - m_nSelectionTimestamp = nTimestamp; - } + osl::MutexGuard aGuard(m_aMutex); - return handleXEvent( *pEvent ); - } - else - { -#if OSL_DEBUG_LEVEL > 1 - SAL_INFO("vcl.unx.dtrans", "SelectionManager got downing event."); -#endif - shutdown(); + m_nSelectionTimestamp = nTimestamp; } - return true; + + return handleXEvent(*pEvent); } void SAL_CALL SelectionManager::disposing( const css::lang::EventObject& rEvt ) diff --git a/vcl/unx/generic/dtrans/X11_selection.hxx b/vcl/unx/generic/dtrans/X11_selection.hxx index 03ad481b7116..4ccd9563a863 100644 --- a/vcl/unx/generic/dtrans/X11_selection.hxx +++ b/vcl/unx/generic/dtrans/X11_selection.hxx @@ -438,11 +438,10 @@ namespace x11 { void setCursor( sal_Int32 cursor, ::Window aDropXLIB_Window ); void transferablesFlavorsChanged(); - void shutdown() noexcept; - void initialize(); - virtual bool handleEvent(const css::uno::Any& event) override; + virtual bool handleEvent(const css::uno::Sequence<sal_Int8>& rEvent) override; + void shutdown() noexcept override; // XDragSource virtual sal_Bool SAL_CALL isDragImageSupported() override;