From af8419fa1d3cea57481e0e53518237eea2d9cdad Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Fri, 8 Jul 2016 15:13:13 +0200 Subject: sw lok: add LOK_CALLBACK_VIEW_CURSOR_VISIBLE With this, in case a text cursor is turned into a graphic selection in view#0, then view#1 can also hide the text cursor of view#0. Change-Id: I7de89b8537ef8b0985336793b719d93733604bff Reviewed-on: https://gerrit.libreoffice.org/27044 Reviewed-by: Miklos Vajna Tested-by: Jenkins --- libreofficekit/source/gtk/lokdocview.cxx | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'libreofficekit') diff --git a/libreofficekit/source/gtk/lokdocview.cxx b/libreofficekit/source/gtk/lokdocview.cxx index 8bf889ff9f79..667b4d4feb98 100644 --- a/libreofficekit/source/gtk/lokdocview.cxx +++ b/libreofficekit/source/gtk/lokdocview.cxx @@ -83,6 +83,9 @@ struct LOKDocViewPrivateImpl gboolean m_bCursorOverlayVisible; /// Cursor is visible or hidden (e.g. for graphic selection). gboolean m_bCursorVisible; + /// Visibility of view selections. The current view can only see / them, + /// can't modify them. Key is the view id. + std::map m_aViewCursorVisibilities; /// Time of the last button press. guint32 m_nLastButtonPressTime; /// Time of the last button release. @@ -324,6 +327,8 @@ callbackTypeToString (int nType) return "LOK_CALLBACK_TEXT_SELECTION_END"; case LOK_CALLBACK_CURSOR_VISIBLE: return "LOK_CALLBACK_CURSOR_VISIBLE"; + case LOK_CALLBACK_VIEW_CURSOR_VISIBLE: + return "LOK_CALLBACK_VIEW_CURSOR_VISIBLE"; case LOK_CALLBACK_GRAPHIC_SELECTION: return "LOK_CALLBACK_GRAPHIC_SELECTION"; case LOK_CALLBACK_GRAPHIC_VIEW_SELECTION: @@ -1222,6 +1227,18 @@ callback (gpointer pData) gtk_widget_queue_draw(GTK_WIDGET(pDocView)); break; } + case LOK_CALLBACK_VIEW_CURSOR_VISIBLE: + { + std::stringstream aStream(pCallback->m_aPayload); + boost::property_tree::ptree aTree; + boost::property_tree::read_json(aStream, aTree); + int nViewId = aTree.get("viewId"); + const std::string& rVisible = aTree.get("visible"); + priv->m_aViewCursorVisibilities[nViewId] = rVisible == "true"; + gtk_widget_queue_draw(GTK_WIDGET(pDocView)); + break; + } + break; case LOK_CALLBACK_CELL_VIEW_CURSOR: { std::stringstream aStream(pCallback->m_aPayload); @@ -1523,6 +1540,10 @@ renderOverlay(LOKDocView* pDocView, cairo_t* pCairo) { for (auto& rPair : priv->m_aViewCursors) { + auto itVisibility = priv->m_aViewCursorVisibilities.find(rPair.first); + if (itVisibility != priv->m_aViewCursorVisibilities.end() && !itVisibility->second) + continue; + GdkRectangle& rCursor = rPair.second; if (rCursor.width < 30) // Set a minimal width if it would be 0. -- cgit