diff options
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/headless/svpinst.cxx | 32 | ||||
-rw-r--r-- | vcl/inc/headless/svpinst.hxx | 3 | ||||
-rw-r--r-- | vcl/inc/svdata.hxx | 6 | ||||
-rw-r--r-- | vcl/source/app/svapp.cxx | 19 |
4 files changed, 49 insertions, 11 deletions
diff --git a/vcl/headless/svpinst.cxx b/vcl/headless/svpinst.cxx index 324d976cb95e..69353b104fc3 100644 --- a/vcl/headless/svpinst.cxx +++ b/vcl/headless/svpinst.cxx @@ -51,6 +51,7 @@ #include <unx/gendata.hxx> // FIXME: remove when we re-work the svp mainloop #include <unx/salunxtime.h> +#include <comphelper/lok.hxx> SvpSalInstance* SvpSalInstance::s_pDefaultInstance = nullptr; @@ -175,12 +176,15 @@ void SvpSalInstance::Wakeup(SvpRequest const request) #ifdef IOS (void)request; #else + ImplSVData* pSVData = ImplGetSVData(); + + if (pSVData->mpWakeCallback) + pSVData->mpWakeCallback(pSVData->mpPollClosure); + SvpSalYieldMutex *const pMutex(static_cast<SvpSalYieldMutex*>(GetYieldMutex())); std::unique_lock<std::mutex> g(pMutex->m_WakeUpMainMutex); if (request != SvpRequest::NONE) - { pMutex->m_Request = request; - } pMutex->m_wakeUpMain = true; pMutex->m_WakeUpMainCond.notify_one(); #endif @@ -373,11 +377,8 @@ sal_uInt32 SvpSalYieldMutex::doRelease(bool const bUnlockAll) // read m_nCount before doRelease bool const isReleased(bUnlockAll || m_nCount == 1); nCount = comphelper::SolarMutex::doRelease( bUnlockAll ); - if (isReleased) { - std::unique_lock<std::mutex> g(m_WakeUpMainMutex); - m_wakeUpMain = true; - m_WakeUpMainCond.notify_one(); - } + if (isReleased && pInst) + pInst->Wakeup(SvpRequest::NONE); } return nCount; } @@ -420,8 +421,8 @@ bool SvpSalInstance::DoYield(bool bWait, bool bHandleAllCurrentEvents) #endif // first, process current user events - bool bEvent = DispatchUserEvents( bHandleAllCurrentEvents ); - if ( !bHandleAllCurrentEvents && bEvent ) + bool bEvent = DispatchUserEvents(bHandleAllCurrentEvents); + if (!bHandleAllCurrentEvents && bEvent) return true; bEvent = CheckTimeout() || bEvent; @@ -450,7 +451,20 @@ bool SvpSalInstance::DoYield(bool bWait, bool bHandleAllCurrentEvents) else nTimeoutMS = -1; // wait until something happens + ImplSVData* pSVData = ImplGetSVData(); sal_uInt32 nAcquireCount = ReleaseYieldMutexAll(); + + if (pSVData->mpPollCallback) + { + // Poll for events from the LOK client. + if (nTimeoutMS < 0) + nTimeoutMS = 5000; + + // External poll. + if (pSVData->mpPollCallback(pSVData->mpPollClosure, nTimeoutMS * 1000 /* us */) < 0) + pSVData->maAppData.mbAppQuit = true; + } + else { std::unique_lock<std::mutex> g(pMutex->m_WakeUpMainMutex); // wait for doRelease() or Wakeup() to set the condition diff --git a/vcl/inc/headless/svpinst.hxx b/vcl/inc/headless/svpinst.hxx index dcdd29fc8f07..b552dd9a59bf 100644 --- a/vcl/inc/headless/svpinst.hxx +++ b/vcl/inc/headless/svpinst.hxx @@ -93,7 +93,6 @@ public: virtual ~SvpSalYieldMutex() override; virtual bool IsCurrentThread() const override; - }; SalInstance* svp_create_SalInstance(); @@ -109,7 +108,6 @@ class VCL_DLLPUBLIC SvpSalInstance : public SalGenericInstance, public SalUserEv virtual void TriggerUserEventProcessing() override; virtual void ProcessEvent( SalUserEvent aEvent ) override; - void Wakeup(SvpRequest request = SvpRequest::NONE); public: static SvpSalInstance* s_pDefaultInstance; @@ -119,6 +117,7 @@ public: void CloseWakeupPipe(bool log); void CreateWakeupPipe(bool log); + void Wakeup(SvpRequest request = SvpRequest::NONE); void StartTimer( sal_uInt64 nMS ); void StopTimer(); diff --git a/vcl/inc/svdata.hxx b/vcl/inc/svdata.hxx index 714c7c5a36e7..6a98ff4e3185 100644 --- a/vcl/inc/svdata.hxx +++ b/vcl/inc/svdata.hxx @@ -29,6 +29,7 @@ #include <vcl/svapp.hxx> #include <vcl/window.hxx> #include <vcl/task.hxx> +#include <LibreOfficeKit/LibreOfficeKitTypes.h> #include <com/sun/star/lang/XComponent.hpp> #include <com/sun/star/i18n/XCharacterClassification.hpp> @@ -385,6 +386,11 @@ struct ImplSVData css::uno::Reference<css::i18n::XCharacterClassification> m_xCharClass; Link<LinkParamNone*,void> maDeInitHook; + + // LOK & headless backend specific hooks + LibreOfficeKitPollCallback mpPollCallback = nullptr; + LibreOfficeKitWakeCallback mpWakeCallback = nullptr; + void *mpPollClosure = nullptr; }; css::uno::Reference<css::i18n::XCharacterClassification> const& ImplGetCharClass(); diff --git a/vcl/source/app/svapp.cxx b/vcl/source/app/svapp.cxx index ca29108bc37e..0037d35443f9 100644 --- a/vcl/source/app/svapp.cxx +++ b/vcl/source/app/svapp.cxx @@ -38,6 +38,7 @@ #include <unotools/syslocaleoptions.hxx> #include <vcl/dialog.hxx> +#include <vcl/lok.hxx> #include <vcl/floatwin.hxx> #include <vcl/settings.hxx> #include <vcl/keycod.hxx> @@ -1658,4 +1659,22 @@ void Application::setDeInitHook(Link<LinkParamNone*,void> const & hook) { pSVData->maAppData.mbInAppMain = true; } +namespace vcl { namespace lok { + +void registerPollCallbacks( + LibreOfficeKitPollCallback pPollCallback, + LibreOfficeKitWakeCallback pWakeCallback, + void *pData) { + + ImplSVData * pSVData = ImplGetSVData(); + if (pSVData) + { + pSVData->mpPollCallback = pPollCallback; + pSVData->mpWakeCallback = pWakeCallback; + pSVData->mpPollClosure = pData; + } +} + +} } // namespace lok, namespace vcl + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |