[Libreoffice-commits] core.git: Branch 'feature/tiled-editing' - 2 commits - include/LibreOfficeKit libreofficekit/source sw/source

Miklos Vajna vmiklos at collabora.co.uk
Wed Mar 4 01:10:54 PST 2015


 include/LibreOfficeKit/LibreOfficeKitEnums.h |   11 ++++++++++-
 include/LibreOfficeKit/LibreOfficeKitGtk.h   |    4 +++-
 libreofficekit/source/gtk/lokdocview.c       |   20 ++++++++++++++------
 sw/source/core/crsr/viscrs.cxx               |    6 ++++++
 4 files changed, 33 insertions(+), 8 deletions(-)

New commits:
commit e65f81057950f2121b1c64890a7c687570b1969d
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Wed Mar 4 10:09:53 2015 +0100

    LOK: add LOK_CALLBACK_CURSOR_VISIBLE
    
    With this, if a Writer document contains an image, then clicking on the
    image then back to the text properly shows/hides the blinking cursor.
    
    Change-Id: I3313319ded614a2eb86e1c66c926189511a7cca6

diff --git a/include/LibreOfficeKit/LibreOfficeKitEnums.h b/include/LibreOfficeKit/LibreOfficeKitEnums.h
index a8aca2f..aed96d6 100644
--- a/include/LibreOfficeKit/LibreOfficeKitEnums.h
+++ b/include/LibreOfficeKit/LibreOfficeKitEnums.h
@@ -78,7 +78,16 @@ typedef enum
      * LOK_CALLBACK_TEXT_SELECTION one. Rectangle format is the same as
      * LOK_CALLBACK_INVALIDATE_TILES.
      */
-    LOK_CALLBACK_TEXT_SELECTION_END
+    LOK_CALLBACK_TEXT_SELECTION_END,
+    /**
+     * The blinking text cursor is now visible or not.
+     *
+     * Clients should assume that this is false initially and are expected to
+     * show a blinking cursor at the rectangle described by
+     * LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR once it becomes true. Payload is
+     * either the "true" or the "false" string.
+     */
+    LOK_CALLBACK_CURSOR_VISIBLE
 }
 LibreOfficeKitCallbackType;
 
diff --git a/include/LibreOfficeKit/LibreOfficeKitGtk.h b/include/LibreOfficeKit/LibreOfficeKitGtk.h
index dbd2f8d..c98b612 100644
--- a/include/LibreOfficeKit/LibreOfficeKitGtk.h
+++ b/include/LibreOfficeKit/LibreOfficeKitGtk.h
@@ -46,6 +46,8 @@ struct _LOKDocView
     GdkRectangle m_aVisibleCursor;
     /// Cursor overlay is visible or hidden (for blinking).
     gboolean m_bCursorOverlayVisible;
+    /// Cursor is visible or hidden (e.g. for graphic selection).
+    gboolean m_bCursorVisible;
     /// Time of the last button press.
     guint32 m_nLastButtonPressTime;
     /// Time of the last button release.
diff --git a/libreofficekit/source/gtk/lokdocview.c b/libreofficekit/source/gtk/lokdocview.c
index bbfee06..d9f0b19 100644
--- a/libreofficekit/source/gtk/lokdocview.c
+++ b/libreofficekit/source/gtk/lokdocview.c
@@ -247,6 +247,7 @@ static void lok_docview_init( LOKDocView* pDocView )
     pDocView->m_bEdit = FALSE;
     memset(&pDocView->m_aVisibleCursor, 0, sizeof(pDocView->m_aVisibleCursor));
     pDocView->m_bCursorOverlayVisible = FALSE;
+    pDocView->m_bCursorVisible = FALSE;
     pDocView->m_nLastButtonPressTime = 0;
     pDocView->m_nLastButtonReleaseTime = 0;
     pDocView->m_pTextSelectionRectangles = NULL;
@@ -355,7 +356,7 @@ static gboolean renderOverlay(GtkWidget* pWidget, GdkEventExpose* pEvent, gpoint
     (void)pEvent;
     pCairo = gdk_cairo_create(gtk_widget_get_window(pWidget));
 
-    if (pDocView->m_bCursorOverlayVisible && !lcl_isEmptyRectangle(&pDocView->m_aVisibleCursor))
+    if (pDocView->m_bCursorVisible && pDocView->m_bCursorOverlayVisible && !lcl_isEmptyRectangle(&pDocView->m_aVisibleCursor))
     {
         if (pDocView->m_aVisibleCursor.width == 0)
             // Set a minimal width if it would be 0.
@@ -371,7 +372,7 @@ static gboolean renderOverlay(GtkWidget* pWidget, GdkEventExpose* pEvent, gpoint
 
     }
 
-    if (!lcl_isEmptyRectangle(&pDocView->m_aVisibleCursor) && !pDocView->m_pTextSelectionRectangles)
+    if (pDocView->m_bCursorVisible && !lcl_isEmptyRectangle(&pDocView->m_aVisibleCursor) && !pDocView->m_pTextSelectionRectangles)
     {
         // Have a cursor, but no selection: we need the middle handle.
         if (!pDocView->m_pHandleMiddle)
@@ -603,6 +604,8 @@ static const gchar* lcl_LibreOfficeKitCallbackTypeToString(int nType)
         return "LOK_CALLBACK_TEXT_SELECTION_START";
     case LOK_CALLBACK_TEXT_SELECTION_END:
         return "LOK_CALLBACK_TEXT_SELECTION_END";
+    case LOK_CALLBACK_CURSOR_VISIBLE:
+        return "LOK_CALLBACK_CURSOR_VISIBLE";
     }
     return 0;
 }
@@ -664,6 +667,11 @@ static gboolean lok_docview_callback(gpointer pData)
         pCallback->m_pDocView->m_aTextSelectionEnd = lcl_payloadToRectangle(pCallback->m_pPayload);
     }
     break;
+    case LOK_CALLBACK_CURSOR_VISIBLE:
+    {
+        pCallback->m_pDocView->m_bCursorVisible = strcmp(pCallback->m_pPayload, "true") == 0;
+    }
+    break;
     default:
         break;
     }
diff --git a/sw/source/core/crsr/viscrs.cxx b/sw/source/core/crsr/viscrs.cxx
index c0b4a33..28f6a61 100644
--- a/sw/source/core/crsr/viscrs.cxx
+++ b/sw/source/core/crsr/viscrs.cxx
@@ -93,10 +93,16 @@ void SwVisCrsr::Show()
         if( m_pCrsrShell->VisArea().IsOver( m_pCrsrShell->m_aCharRect ) || m_pCrsrShell->isTiledRendering() )
             _SetPosAndShow();
     }
+
+    if (m_pCrsrShell->isTiledRendering())
+        m_pCrsrShell->libreOfficeKitCallback(LOK_CALLBACK_CURSOR_VISIBLE, OString::boolean(true).getStr());
 }
 
 void SwVisCrsr::Hide()
 {
+    if (m_pCrsrShell->isTiledRendering())
+        m_pCrsrShell->libreOfficeKitCallback(LOK_CALLBACK_CURSOR_VISIBLE, OString::boolean(false).getStr());
+
     if( m_bIsVisible )
     {
         m_bIsVisible = false;
commit b87d0bd2c8e0b73be70abcc5d1db95694297abb0
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Wed Mar 4 10:03:49 2015 +0100

    lokdocview: CursorVisible -> CursorOverlayVisible
    
    There are multiple levels of being hidden: if the cursor is not visible
    due to just blinking or in case it won't show up after some timeout,
    either.
    
    Let's use CursorOverlayVisible for the condition if the cursor should be
    painted right now or not, and CursorVisible for the long-term "is it
    visible" state.
    
    Change-Id: Ib583236c1429f25e14ba79fdabad4ea899bb4269

diff --git a/include/LibreOfficeKit/LibreOfficeKitGtk.h b/include/LibreOfficeKit/LibreOfficeKitGtk.h
index d6d720e..dbd2f8d 100644
--- a/include/LibreOfficeKit/LibreOfficeKitGtk.h
+++ b/include/LibreOfficeKit/LibreOfficeKitGtk.h
@@ -44,8 +44,8 @@ struct _LOKDocView
     gboolean m_bEdit;
     /// Position and size of the visible cursor.
     GdkRectangle m_aVisibleCursor;
-    /// Cursor is visible or hidden (for blinking).
-    gboolean m_bCursorVisible;
+    /// Cursor overlay is visible or hidden (for blinking).
+    gboolean m_bCursorOverlayVisible;
     /// Time of the last button press.
     guint32 m_nLastButtonPressTime;
     /// Time of the last button release.
diff --git a/libreofficekit/source/gtk/lokdocview.c b/libreofficekit/source/gtk/lokdocview.c
index 525bf84..bbfee06 100644
--- a/libreofficekit/source/gtk/lokdocview.c
+++ b/libreofficekit/source/gtk/lokdocview.c
@@ -246,7 +246,7 @@ static void lok_docview_init( LOKDocView* pDocView )
     pDocView->fZoom = 1;
     pDocView->m_bEdit = FALSE;
     memset(&pDocView->m_aVisibleCursor, 0, sizeof(pDocView->m_aVisibleCursor));
-    pDocView->m_bCursorVisible = FALSE;
+    pDocView->m_bCursorOverlayVisible = FALSE;
     pDocView->m_nLastButtonPressTime = 0;
     pDocView->m_nLastButtonReleaseTime = 0;
     pDocView->m_pTextSelectionRectangles = NULL;
@@ -304,10 +304,10 @@ static gboolean lcl_handleTimeout(gpointer pData)
 
     if (pDocView->m_bEdit)
     {
-        if (pDocView->m_bCursorVisible)
-            pDocView->m_bCursorVisible = FALSE;
+        if (pDocView->m_bCursorOverlayVisible)
+            pDocView->m_bCursorOverlayVisible = FALSE;
         else
-            pDocView->m_bCursorVisible = TRUE;
+            pDocView->m_bCursorOverlayVisible = TRUE;
         gtk_widget_queue_draw(GTK_WIDGET(pDocView->pEventBox));
     }
 
@@ -355,7 +355,7 @@ static gboolean renderOverlay(GtkWidget* pWidget, GdkEventExpose* pEvent, gpoint
     (void)pEvent;
     pCairo = gdk_cairo_create(gtk_widget_get_window(pWidget));
 
-    if (pDocView->m_bCursorVisible && !lcl_isEmptyRectangle(&pDocView->m_aVisibleCursor))
+    if (pDocView->m_bCursorOverlayVisible && !lcl_isEmptyRectangle(&pDocView->m_aVisibleCursor))
     {
         if (pDocView->m_aVisibleCursor.width == 0)
             // Set a minimal width if it would be 0.
@@ -629,7 +629,7 @@ static gboolean lok_docview_callback(gpointer pData)
     case LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR:
     {
         pCallback->m_pDocView->m_aVisibleCursor = lcl_payloadToRectangle(pCallback->m_pPayload);
-        pCallback->m_pDocView->m_bCursorVisible = TRUE;
+        pCallback->m_pDocView->m_bCursorOverlayVisible = TRUE;
         gtk_widget_queue_draw(GTK_WIDGET(pCallback->m_pDocView->pEventBox));
     }
     break;


More information about the Libreoffice-commits mailing list