Blame SOURCES/0083-lokdocview-setGraphicSelection-in-another-thread.patch

135360
From 3bb042ae678b26e234d19913846d695e8bfd8927 Mon Sep 17 00:00:00 2001
135360
From: Pranav Kant <pranavk@gnome.org>
135360
Date: Sun, 26 Jul 2015 22:39:43 +0530
135360
Subject: [PATCH 083/398] lokdocview: setGraphicSelection in another thread
135360
135360
Change-Id: Ib7a6bf63ee6f300c6c5d50d02a3465d0a075a5be
135360
(cherry picked from commit 7c45a57081a921b8f56812dd37c2fcd4b86d2a1a)
135360
---
135360
 libreofficekit/source/gtk/lokdocview.cxx | 68 ++++++++++++++++++++++++++++----
135360
 libreofficekit/source/gtk/tilebuffer.hxx | 10 ++++-
135360
 2 files changed, 70 insertions(+), 8 deletions(-)
135360
135360
diff --git a/libreofficekit/source/gtk/lokdocview.cxx b/libreofficekit/source/gtk/lokdocview.cxx
135360
index d23ac1af2fc1..edd2179495f0 100644
135360
--- a/libreofficekit/source/gtk/lokdocview.cxx
135360
+++ b/libreofficekit/source/gtk/lokdocview.cxx
135360
@@ -889,7 +889,17 @@ lok_doc_view_signal_button(GtkWidget* pWidget, GdkEventButton* pEvent)
135360
             {
135360
                 g_info("LOKDocView_Impl::signalButton: end of drag graphic handle #%d", i);
135360
                 priv->m_bInDragGraphicHandles[i] = false;
135360
-                priv->m_pDocument->pClass->setGraphicSelection(priv->m_pDocument, LOK_SETGRAPHICSELECTION_END, pixelToTwip(pEvent->x, priv->m_fZoom), pixelToTwip(pEvent->y, priv->m_fZoom));
135360
+
135360
+                GTask* task = g_task_new(pDocView, NULL, NULL, NULL);
135360
+                LOEvent* pLOEvent = new LOEvent(LOK_SET_GRAPHIC_SELECTION);
135360
+                pLOEvent->m_nSetGraphicSelectionType = LOK_SETGRAPHICSELECTION_END;
135360
+                pLOEvent->m_nSetGraphicSelectionX = pixelToTwip(pEvent->x, priv->m_fZoom);
135360
+                pLOEvent->m_nSetGraphicSelectionY = pixelToTwip(pEvent->y, priv->m_fZoom);
135360
+                g_task_set_task_data(task, pLOEvent, g_free);
135360
+
135360
+                g_thread_pool_push(lokThreadPool, g_object_ref(task), NULL);
135360
+                g_object_unref(task);
135360
+
135360
                 return FALSE;
135360
             }
135360
         }
135360
@@ -898,7 +908,17 @@ lok_doc_view_signal_button(GtkWidget* pWidget, GdkEventButton* pEvent)
135360
         {
135360
             g_info("LOKDocView_Impl::signalButton: end of drag graphic selection");
135360
             priv->m_bInDragGraphicSelection = false;
135360
-            priv->m_pDocument->pClass->setGraphicSelection(priv->m_pDocument, LOK_SETGRAPHICSELECTION_END, pixelToTwip(pEvent->x, priv->m_fZoom), pixelToTwip(pEvent->y, priv->m_fZoom));
135360
+
135360
+            GTask* task = g_task_new(pDocView, NULL, NULL, NULL);
135360
+            LOEvent* pLOEvent = new LOEvent(LOK_SET_GRAPHIC_SELECTION);
135360
+            pLOEvent->m_nSetGraphicSelectionType = LOK_SETGRAPHICSELECTION_END;
135360
+            pLOEvent->m_nSetGraphicSelectionX = pixelToTwip(pEvent->x, priv->m_fZoom);
135360
+            pLOEvent->m_nSetGraphicSelectionY = pixelToTwip(pEvent->y, priv->m_fZoom);
135360
+            g_task_set_task_data(task, pLOEvent, g_free);
135360
+
135360
+            g_thread_pool_push(lokThreadPool, g_object_ref(task), NULL);
135360
+            g_object_unref(task);
135360
+
135360
             return FALSE;
135360
         }
135360
     }
135360
@@ -937,10 +957,17 @@ lok_doc_view_signal_button(GtkWidget* pWidget, GdkEventButton* pEvent)
135360
                 {
135360
                     g_info("LOKDocView_Impl::signalButton: start of drag graphic handle #%d", i);
135360
                     priv->m_bInDragGraphicHandles[i] = true;
135360
-                    priv->m_pDocument->pClass->setGraphicSelection(priv->m_pDocument,
135360
-                                                             LOK_SETGRAPHICSELECTION_START,
135360
-                                                             pixelToTwip(priv->m_aGraphicHandleRects[i].x + priv->m_aGraphicHandleRects[i].width / 2, priv->m_fZoom),
135360
-                                                             pixelToTwip(priv->m_aGraphicHandleRects[i].y + priv->m_aGraphicHandleRects[i].height / 2, priv->m_fZoom));
135360
+
135360
+                    GTask* task = g_task_new(pDocView, NULL, NULL, NULL);
135360
+                    LOEvent* pLOEvent = new LOEvent(LOK_SET_GRAPHIC_SELECTION);
135360
+                    pLOEvent->m_nSetGraphicSelectionType = LOK_SETGRAPHICSELECTION_START;
135360
+                    pLOEvent->m_nSetGraphicSelectionX = pixelToTwip(priv->m_aGraphicHandleRects[i].x + priv->m_aGraphicHandleRects[i].width / 2, priv->m_fZoom);
135360
+                    pLOEvent->m_nSetGraphicSelectionY = pixelToTwip(priv->m_aGraphicHandleRects[i].y + priv->m_aGraphicHandleRects[i].height / 2, priv->m_fZoom);
135360
+                    g_task_set_task_data(task, pLOEvent, g_free);
135360
+
135360
+                    g_thread_pool_push(lokThreadPool, g_object_ref(task), NULL);
135360
+                    g_object_unref(task);
135360
+
135360
                     return FALSE;
135360
                 }
135360
             }
135360
@@ -1063,7 +1090,17 @@ lok_doc_view_signal_motion (GtkWidget* pWidget, GdkEventMotion* pEvent)
135360
     {
135360
         g_info("lcl_signalMotion: start of drag graphic selection");
135360
         priv->m_bInDragGraphicSelection = true;
135360
-        priv->m_pDocument->pClass->setGraphicSelection(priv->m_pDocument, LOK_SETGRAPHICSELECTION_START, pixelToTwip(pEvent->x, priv->m_fZoom), pixelToTwip(pEvent->y, priv->m_fZoom));
135360
+
135360
+        GTask* task = g_task_new(pDocView, NULL, NULL, NULL);
135360
+        LOEvent* pLOEvent = new LOEvent(LOK_SET_GRAPHIC_SELECTION);
135360
+        pLOEvent->m_nSetGraphicSelectionType = LOK_SETGRAPHICSELECTION_START;
135360
+        pLOEvent->m_nSetGraphicSelectionX = pixelToTwip(pEvent->x, priv->m_fZoom);
135360
+        pLOEvent->m_nSetGraphicSelectionY = pixelToTwip(pEvent->y, priv->m_fZoom);
135360
+        g_task_set_task_data(task, pLOEvent, g_free);
135360
+
135360
+        g_thread_pool_push(lokThreadPool, g_object_ref(task), NULL);
135360
+        g_object_unref(task);
135360
+
135360
         return FALSE;
135360
     }
135360
 
135360
@@ -1084,6 +1121,20 @@ lok_doc_view_signal_motion (GtkWidget* pWidget, GdkEventMotion* pEvent)
135360
 }
135360
 
135360
 static void
135360
+setGraphicSelectionInThread(gpointer data)
135360
+{
135360
+    GTask* task = G_TASK(data);
135360
+    LOKDocView* pDocView = LOK_DOC_VIEW(g_task_get_source_object(task));
135360
+    LOKDocViewPrivate *priv = static_cast<LOKDocViewPrivate*>(lok_doc_view_get_instance_private (pDocView));
135360
+    LOEvent* pLOEvent = static_cast<LOEvent*>(g_task_get_task_data(task));
135360
+
135360
+    priv->m_pDocument->pClass->setGraphicSelection(priv->m_pDocument,
135360
+                                                   pLOEvent->m_nSetGraphicSelectionType,
135360
+                                                   pLOEvent->m_nSetGraphicSelectionX,
135360
+                                                   pLOEvent->m_nSetGraphicSelectionY);
135360
+}
135360
+
135360
+static void
135360
 postMouseEventInThread(gpointer data)
135360
 {
135360
     GTask* task = G_TASK(data);
135360
@@ -1282,6 +1333,9 @@ lokThreadFunc(gpointer data, gpointer /*user_data*/)
135360
     case LOK_POST_MOUSE_EVENT:
135360
         postMouseEventInThread(task);
135360
         break;
135360
+    case LOK_SET_GRAPHIC_SELECTION:
135360
+        setGraphicSelectionInThread(task);
135360
+        break;
135360
     }
135360
 
135360
     g_object_unref(task);
135360
diff --git a/libreofficekit/source/gtk/tilebuffer.hxx b/libreofficekit/source/gtk/tilebuffer.hxx
135360
index aa496aaf3e8f..d2451b6c2290 100644
135360
--- a/libreofficekit/source/gtk/tilebuffer.hxx
135360
+++ b/libreofficekit/source/gtk/tilebuffer.hxx
135360
@@ -139,7 +139,8 @@ enum
135360
     LOK_SET_PART,
135360
     LOK_POST_KEY,
135360
     LOK_PAINT_TILE,
135360
-    LOK_POST_MOUSE_EVENT
135360
+    LOK_POST_MOUSE_EVENT,
135360
+    LOK_SET_GRAPHIC_SELECTION
135360
 };
135360
 
135360
 /**
135360
@@ -196,6 +197,13 @@ struct LOEvent
135360
     int m_nPostMouseEventCount;
135360
     ///@}
135360
 
135360
+    /// @name setGraphicSelection parameters
135360
+    ///@{
135360
+    int m_nSetGraphicSelectionType;
135360
+    int m_nSetGraphicSelectionX;
135360
+    int m_nSetGraphicSelectionY;
135360
+    ///@}
135360
+
135360
     /// Constructor to instantiate an object of type `type`.
135360
     LOEvent(int type)
135360
         : m_nType(type) {}
135360
-- 
135360
2.12.0
135360