summaryrefslogtreecommitdiff
path: root/libreofficekit
diff options
context:
space:
mode:
authorPranav Kant <pranavk@gnome.org>2015-07-26 22:39:43 +0530
committerAshod Nakashian <ashod.nakashian@collabora.co.uk>2016-02-07 22:09:14 -0500
commit0f42780dee0ad34e37d78417d2c87214c43ae9c3 (patch)
treef8f10efce401812471bac90e526ccf91a358f4f7 /libreofficekit
parent871fd7a3bb384dcfd613f26db76df6c4f133c44d (diff)
lokdocview: setGraphicSelection in another thread
Change-Id: Ib7a6bf63ee6f300c6c5d50d02a3465d0a075a5be (cherry picked from commit 7c45a57081a921b8f56812dd37c2fcd4b86d2a1a)
Diffstat (limited to 'libreofficekit')
-rw-r--r--libreofficekit/source/gtk/lokdocview.cxx68
-rw-r--r--libreofficekit/source/gtk/tilebuffer.hxx10
2 files changed, 70 insertions, 8 deletions
diff --git a/libreofficekit/source/gtk/lokdocview.cxx b/libreofficekit/source/gtk/lokdocview.cxx
index 6a7297ed7baf..f5e86f2198af 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -909,7 +909,17 @@ lok_doc_view_signal_button(GtkWidget* pWidget, GdkEventButton* pEvent)
{
g_info("LOKDocView_Impl::signalButton: end of drag graphic handle #%d", i);
priv->m_bInDragGraphicHandles[i] = false;
- priv->m_pDocument->pClass->setGraphicSelection(priv->m_pDocument, LOK_SETGRAPHICSELECTION_END, pixelToTwip(pEvent->x, priv->m_fZoom), pixelToTwip(pEvent->y, priv->m_fZoom));
+
+ GTask* task = g_task_new(pDocView, NULL, NULL, NULL);
+ LOEvent* pLOEvent = new LOEvent(LOK_SET_GRAPHIC_SELECTION);
+ pLOEvent->m_nSetGraphicSelectionType = LOK_SETGRAPHICSELECTION_END;
+ pLOEvent->m_nSetGraphicSelectionX = pixelToTwip(pEvent->x, priv->m_fZoom);
+ pLOEvent->m_nSetGraphicSelectionY = pixelToTwip(pEvent->y, priv->m_fZoom);
+ g_task_set_task_data(task, pLOEvent, g_free);
+
+ g_thread_pool_push(lokThreadPool, g_object_ref(task), NULL);
+ g_object_unref(task);
+
return FALSE;
}
}
@@ -918,7 +928,17 @@ lok_doc_view_signal_button(GtkWidget* pWidget, GdkEventButton* pEvent)
{
g_info("LOKDocView_Impl::signalButton: end of drag graphic selection");
priv->m_bInDragGraphicSelection = false;
- priv->m_pDocument->pClass->setGraphicSelection(priv->m_pDocument, LOK_SETGRAPHICSELECTION_END, pixelToTwip(pEvent->x, priv->m_fZoom), pixelToTwip(pEvent->y, priv->m_fZoom));
+
+ GTask* task = g_task_new(pDocView, NULL, NULL, NULL);
+ LOEvent* pLOEvent = new LOEvent(LOK_SET_GRAPHIC_SELECTION);
+ pLOEvent->m_nSetGraphicSelectionType = LOK_SETGRAPHICSELECTION_END;
+ pLOEvent->m_nSetGraphicSelectionX = pixelToTwip(pEvent->x, priv->m_fZoom);
+ pLOEvent->m_nSetGraphicSelectionY = pixelToTwip(pEvent->y, priv->m_fZoom);
+ g_task_set_task_data(task, pLOEvent, g_free);
+
+ g_thread_pool_push(lokThreadPool, g_object_ref(task), NULL);
+ g_object_unref(task);
+
return FALSE;
}
}
@@ -957,10 +977,17 @@ lok_doc_view_signal_button(GtkWidget* pWidget, GdkEventButton* pEvent)
{
g_info("LOKDocView_Impl::signalButton: start of drag graphic handle #%d", i);
priv->m_bInDragGraphicHandles[i] = true;
- priv->m_pDocument->pClass->setGraphicSelection(priv->m_pDocument,
- LOK_SETGRAPHICSELECTION_START,
- pixelToTwip(priv->m_aGraphicHandleRects[i].x + priv->m_aGraphicHandleRects[i].width / 2, priv->m_fZoom),
- pixelToTwip(priv->m_aGraphicHandleRects[i].y + priv->m_aGraphicHandleRects[i].height / 2, priv->m_fZoom));
+
+ GTask* task = g_task_new(pDocView, NULL, NULL, NULL);
+ LOEvent* pLOEvent = new LOEvent(LOK_SET_GRAPHIC_SELECTION);
+ pLOEvent->m_nSetGraphicSelectionType = LOK_SETGRAPHICSELECTION_START;
+ pLOEvent->m_nSetGraphicSelectionX = pixelToTwip(priv->m_aGraphicHandleRects[i].x + priv->m_aGraphicHandleRects[i].width / 2, priv->m_fZoom);
+ pLOEvent->m_nSetGraphicSelectionY = pixelToTwip(priv->m_aGraphicHandleRects[i].y + priv->m_aGraphicHandleRects[i].height / 2, priv->m_fZoom);
+ g_task_set_task_data(task, pLOEvent, g_free);
+
+ g_thread_pool_push(lokThreadPool, g_object_ref(task), NULL);
+ g_object_unref(task);
+
return FALSE;
}
}
@@ -1083,7 +1110,17 @@ lok_doc_view_signal_motion (GtkWidget* pWidget, GdkEventMotion* pEvent)
{
g_info("lcl_signalMotion: start of drag graphic selection");
priv->m_bInDragGraphicSelection = true;
- priv->m_pDocument->pClass->setGraphicSelection(priv->m_pDocument, LOK_SETGRAPHICSELECTION_START, pixelToTwip(pEvent->x, priv->m_fZoom), pixelToTwip(pEvent->y, priv->m_fZoom));
+
+ GTask* task = g_task_new(pDocView, NULL, NULL, NULL);
+ LOEvent* pLOEvent = new LOEvent(LOK_SET_GRAPHIC_SELECTION);
+ pLOEvent->m_nSetGraphicSelectionType = LOK_SETGRAPHICSELECTION_START;
+ pLOEvent->m_nSetGraphicSelectionX = pixelToTwip(pEvent->x, priv->m_fZoom);
+ pLOEvent->m_nSetGraphicSelectionY = pixelToTwip(pEvent->y, priv->m_fZoom);
+ g_task_set_task_data(task, pLOEvent, g_free);
+
+ g_thread_pool_push(lokThreadPool, g_object_ref(task), NULL);
+ g_object_unref(task);
+
return FALSE;
}
@@ -1104,6 +1141,20 @@ lok_doc_view_signal_motion (GtkWidget* pWidget, GdkEventMotion* pEvent)
}
static void
+setGraphicSelectionInThread(gpointer data)
+{
+ GTask* task = G_TASK(data);
+ LOKDocView* pDocView = LOK_DOC_VIEW(g_task_get_source_object(task));
+ LOKDocViewPrivate *priv = static_cast<LOKDocViewPrivate*>(lok_doc_view_get_instance_private (pDocView));
+ LOEvent* pLOEvent = static_cast<LOEvent*>(g_task_get_task_data(task));
+
+ priv->m_pDocument->pClass->setGraphicSelection(priv->m_pDocument,
+ pLOEvent->m_nSetGraphicSelectionType,
+ pLOEvent->m_nSetGraphicSelectionX,
+ pLOEvent->m_nSetGraphicSelectionY);
+}
+
+static void
postMouseEventInThread(gpointer data)
{
GTask* task = G_TASK(data);
@@ -1304,6 +1355,9 @@ lokThreadFunc(gpointer data, gpointer /*user_data*/)
case LOK_POST_MOUSE_EVENT:
postMouseEventInThread(task);
break;
+ case LOK_SET_GRAPHIC_SELECTION:
+ setGraphicSelectionInThread(task);
+ break;
}
g_object_unref(task);
diff --git a/libreofficekit/source/gtk/tilebuffer.hxx b/libreofficekit/source/gtk/tilebuffer.hxx
index 1eb921a67725..214f39652151 100644
--- a/libreofficekit/source/gtk/tilebuffer.hxx
+++ b/libreofficekit/source/gtk/tilebuffer.hxx
@@ -139,7 +139,8 @@ enum
LOK_SET_PART,
LOK_POST_KEY,
LOK_PAINT_TILE,
- LOK_POST_MOUSE_EVENT
+ LOK_POST_MOUSE_EVENT,
+ LOK_SET_GRAPHIC_SELECTION
};
/**
@@ -196,6 +197,13 @@ struct LOEvent
int m_nPostMouseEventCount;
///@}
+ /// @name setGraphicSelection parameters
+ ///@{
+ int m_nSetGraphicSelectionType;
+ int m_nSetGraphicSelectionX;
+ int m_nSetGraphicSelectionY;
+ ///@}
+
/// Constructor to instantiate an object of type `type`.
LOEvent(int type)
: m_nType(type) {}