sw lok: move filtering of callbacks during paint to desktop
This will be important when in the per-view case SwViewShell::libreOfficeKitCallback() won't be called anymore; as pointed out by online.git's TileCacheTests::testSimpleCombine() test. Change-Id: Ie68f8c51facdba127763df660e9220f820805ecc Reviewed-on: https://gerrit.libreoffice.org/26372 Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk> Tested-by: Jenkins <ci@libreoffice.org>
This commit is contained in:
@@ -30,7 +30,7 @@ namespace desktop {
|
|||||||
class DESKTOP_DLLPUBLIC CallbackFlushHandler : public Idle
|
class DESKTOP_DLLPUBLIC CallbackFlushHandler : public Idle
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit CallbackFlushHandler(LibreOfficeKitCallback pCallback, void* pData);
|
explicit CallbackFlushHandler(LibreOfficeKitDocument* pDocument, LibreOfficeKitCallback pCallback, void* pData);
|
||||||
virtual ~CallbackFlushHandler();
|
virtual ~CallbackFlushHandler();
|
||||||
virtual void Invoke() override;
|
virtual void Invoke() override;
|
||||||
static void callback(const int type, const char* payload, void* data);
|
static void callback(const int type, const char* payload, void* data);
|
||||||
@@ -44,6 +44,7 @@ namespace desktop {
|
|||||||
|
|
||||||
std::vector<std::pair<int, std::string>> m_queue;
|
std::vector<std::pair<int, std::string>> m_queue;
|
||||||
std::map<int, std::string> m_states;
|
std::map<int, std::string> m_states;
|
||||||
|
LibreOfficeKitDocument* m_pDocument;
|
||||||
LibreOfficeKitCallback m_pCallback;
|
LibreOfficeKitCallback m_pCallback;
|
||||||
void *m_pData;
|
void *m_pData;
|
||||||
bool m_bPartTilePainting;
|
bool m_bPartTilePainting;
|
||||||
|
@@ -1277,8 +1277,9 @@ static void callbackCompressionTest(const int type, const char* payload, void* d
|
|||||||
|
|
||||||
void DesktopLOKTest::testNotificationCompression()
|
void DesktopLOKTest::testNotificationCompression()
|
||||||
{
|
{
|
||||||
|
LibLODocument_Impl* pDocument = loadDoc("blank_text.odt");
|
||||||
std::vector<std::tuple<int, std::string>> notifs;
|
std::vector<std::tuple<int, std::string>> notifs;
|
||||||
std::unique_ptr<CallbackFlushHandler> handler(new CallbackFlushHandler(callbackCompressionTest, ¬ifs));
|
std::unique_ptr<CallbackFlushHandler> handler(new CallbackFlushHandler(pDocument, callbackCompressionTest, ¬ifs));
|
||||||
|
|
||||||
handler->queue(LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR, ""); // 0
|
handler->queue(LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR, ""); // 0
|
||||||
handler->queue(LOK_CALLBACK_TEXT_SELECTION, "15 25 15 10"); // Superseeded.
|
handler->queue(LOK_CALLBACK_TEXT_SELECTION, "15 25 15 10"); // Superseeded.
|
||||||
|
@@ -430,8 +430,9 @@ LibLODocument_Impl::~LibLODocument_Impl()
|
|||||||
mxComponent->dispose();
|
mxComponent->dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
CallbackFlushHandler::CallbackFlushHandler(LibreOfficeKitCallback pCallback, void* pData)
|
CallbackFlushHandler::CallbackFlushHandler(LibreOfficeKitDocument* pDocument, LibreOfficeKitCallback pCallback, void* pData)
|
||||||
: Idle( "lokit timer callback" ),
|
: Idle( "lokit timer callback" ),
|
||||||
|
m_pDocument(pDocument),
|
||||||
m_pCallback(pCallback),
|
m_pCallback(pCallback),
|
||||||
m_pData(pData),
|
m_pData(pData),
|
||||||
m_bPartTilePainting(false)
|
m_bPartTilePainting(false)
|
||||||
@@ -498,6 +499,10 @@ void CallbackFlushHandler::queue(const int type, const char* data)
|
|||||||
//SAL_WARN("lokevt", "Skipping while painting [" + std::to_string(type) + "]: [" + payload + "].");
|
//SAL_WARN("lokevt", "Skipping while painting [" + std::to_string(type) + "]: [" + payload + "].");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// In Writer we drop all notifications during painting.
|
||||||
|
if (doc_getDocumentType(m_pDocument) == LOK_DOCTYPE_TEXT)
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Supress invalid payloads.
|
// Supress invalid payloads.
|
||||||
@@ -1338,7 +1343,7 @@ static void doc_registerCallback(LibreOfficeKitDocument* pThis,
|
|||||||
LibLODocument_Impl* pDocument = static_cast<LibLODocument_Impl*>(pThis);
|
LibLODocument_Impl* pDocument = static_cast<LibLODocument_Impl*>(pThis);
|
||||||
|
|
||||||
std::size_t nView = comphelper::LibreOfficeKit::isViewCallback() ? SfxLokHelper::getView() : 0;
|
std::size_t nView = comphelper::LibreOfficeKit::isViewCallback() ? SfxLokHelper::getView() : 0;
|
||||||
pDocument->mpCallbackFlushHandlers[nView].reset(new CallbackFlushHandler(pCallback, pData));
|
pDocument->mpCallbackFlushHandlers[nView].reset(new CallbackFlushHandler(pThis, pCallback, pData));
|
||||||
|
|
||||||
if (comphelper::LibreOfficeKit::isViewCallback())
|
if (comphelper::LibreOfficeKit::isViewCallback())
|
||||||
{
|
{
|
||||||
|
@@ -124,9 +124,6 @@ void SwViewShell::registerLibreOfficeKitCallback(LibreOfficeKitCallback pCallbac
|
|||||||
|
|
||||||
void SwViewShell::libreOfficeKitCallback(int nType, const char* pPayload) const
|
void SwViewShell::libreOfficeKitCallback(int nType, const char* pPayload) const
|
||||||
{
|
{
|
||||||
if (mbInLibreOfficeKitCallback)
|
|
||||||
return;
|
|
||||||
|
|
||||||
getIDocumentDrawModelAccess().GetDrawModel()->libreOfficeKitCallback(nType, pPayload);
|
getIDocumentDrawModelAccess().GetDrawModel()->libreOfficeKitCallback(nType, pPayload);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user