[Libreoffice-commits] core.git: Branch 'feature/tiled-editing' - libreofficekit/source
Miklos Vajna
vmiklos at collabora.co.uk
Fri Jan 16 02:18:40 PST 2015
libreofficekit/source/gtk/lokdocview.c | 45 ++++++++++++++++++---------------
1 file changed, 25 insertions(+), 20 deletions(-)
New commits:
commit 968759561aa56c036c0ae7b703f3acb45f12a668
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Thu Jan 15 15:16:48 2015 +0100
lokdocview: add LOKDocViewCallbackData
So that the callback code running on the main thread can be aware of the
event type and payload (necessary in the future to do partial repaints).
Change-Id: I790b2ce0b6f9f88ba71d94a17bf0c8fc1b567c5f
diff --git a/libreofficekit/source/gtk/lokdocview.c b/libreofficekit/source/gtk/lokdocview.c
index 5e6e790..d9be2df 100644
--- a/libreofficekit/source/gtk/lokdocview.c
+++ b/libreofficekit/source/gtk/lokdocview.c
@@ -178,20 +178,30 @@ void renderDocument( LOKDocView* pDocView )
}
}
+/// Callback data, allocated in lok_docview_callback_worker(), released in lok_docview_callback().
+typedef struct
+{
+ int m_nType;
+ const char* m_pPayload;
+ LOKDocView* m_pDocView;
+}
+LOKDocViewCallbackData;
+
/// Invoked on the main thread if lok_docview_callback_worker() requests so.
static gboolean lok_docview_callback(gpointer pData)
{
- LOKDocView* pDocView = pData;
-
-#if ! GTK_CHECK_VERSION(2,12,0)
- GDK_THREADS_ENTER();
-#endif
+ LOKDocViewCallbackData* pCallback = pData;
- renderDocument(pDocView);
+ switch (pCallback->m_nType)
+ {
+ case LOK_CALLBACK_INVALIDATE_TILES:
+ renderDocument(pCallback->m_pDocView);
+ break;
+ default:
+ break;
+ }
-#if ! GTK_CHECK_VERSION(2,12,0)
- GDK_THREADS_LEAVE();
-#endif
+ g_free(pCallback);
return G_SOURCE_REMOVE;
}
@@ -200,20 +210,15 @@ static void lok_docview_callback_worker(int nType, const char* pPayload, void* p
{
LOKDocView* pDocView = pData;
- switch (nType)
- {
- case LOK_CALLBACK_INVALIDATE_TILES:
- // TODO for now just always render the document.
- (void)pPayload;
+ LOKDocViewCallbackData* pCallback = g_new0(LOKDocViewCallbackData, 1);
+ pCallback->m_nType = nType;
+ pCallback->m_pPayload = pPayload;
+ pCallback->m_pDocView = pDocView;
#if GTK_CHECK_VERSION(2,12,0)
- gdk_threads_add_idle(lok_docview_callback, pDocView);
+ gdk_threads_add_idle(lok_docview_callback, pCallback);
#else
- g_idle_add(lok_docview_callback, pDocView);
+ g_idle_add(lok_docview_callback, pDocView);
#endif
- break;
- default:
- break;
- }
}
SAL_DLLPUBLIC_EXPORT gboolean lok_docview_open_document( LOKDocView* pDocView, char* pPath )
More information about the Libreoffice-commits
mailing list