[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-5.3' - include/vcl vcl/source

Pranav Kant pranavk at collabora.co.uk
Sat Dec 9 12:49:15 UTC 2017


 include/vcl/cursor.hxx       |    1 +
 include/vcl/window.hxx       |    1 -
 vcl/source/control/edit.cxx  |   38 --------------------------------------
 vcl/source/window/cursor.cxx |   40 ++++++++++++++++++++++++++++++++++++++++
 vcl/source/window/window.cxx |   11 -----------
 5 files changed, 41 insertions(+), 50 deletions(-)

New commits:
commit 0d5f4668e2b006eb4ca72bdf905393947d935cae
Author: Pranav Kant <pranavk at collabora.co.uk>
Date:   Fri Dec 8 16:23:45 2017 +0530

    lokdialog: Move lok cursor invalidation callbacks to vcl::Cursor
    
    Change-Id: I5cbb845259b6802fb2a0776f8d8f19f9680115ad
    (cherry picked from commit 782f8be6d4076b0152442e6200426010c1f6704f)
    Reviewed-on: https://gerrit.libreoffice.org/46113
    Reviewed-by: Michael Meeks <michael.meeks at collabora.com>
    Tested-by: Michael Meeks <michael.meeks at collabora.com>

diff --git a/include/vcl/cursor.hxx b/include/vcl/cursor.hxx
index 59cac2799a9f..be6dd45c56c4 100644
--- a/include/vcl/cursor.hxx
+++ b/include/vcl/cursor.hxx
@@ -95,6 +95,7 @@ public:
                         { return !(Cursor::operator==( rCursor )); }
 
 private:
+    void LOKNotify( vcl::Window* pWindow, const OUString& rAction );
     void ImplRestore();
     void ImplDoShow( bool bDrawDirect, bool bRestore );
     bool ImplDoHide( bool bStop );
diff --git a/include/vcl/window.hxx b/include/vcl/window.hxx
index b4323c185e93..476da58f5000 100644
--- a/include/vcl/window.hxx
+++ b/include/vcl/window.hxx
@@ -1227,7 +1227,6 @@ public:
 
     void LOKKeyInput(const KeyEvent& rKeyEvent);
     void LOKKeyUp(const KeyEvent& rKeyEvent);
-    void LOKCursor(const OUString& rAction, const std::vector<vcl::LOKPayloadItem>& rPayload);
 
     /** @name Accessibility
      */
diff --git a/vcl/source/control/edit.cxx b/vcl/source/control/edit.cxx
index 4a3123765ecd..cf0fe9ce0759 100644
--- a/vcl/source/control/edit.cxx
+++ b/vcl/source/control/edit.cxx
@@ -1150,23 +1150,6 @@ void Edit::ImplShowCursor( bool bOnlyIfVisible )
         pCursor->SetPos( Point( nCursorPosX, nCursorPosY ) );
         pCursor->SetSize( Size( nCursorWidth, nTextHeight ) );
         pCursor->Show();
-
-        if (comphelper::LibreOfficeKit::isActive())
-        {
-            const long X = GetOutOffXPixel() + pCursor->GetPos().X();
-            const long Y = GetOutOffYPixel() + pCursor->GetPos().Y();
-
-            if (nCursorWidth == 0)
-                nCursorWidth = 2;
-            const Rectangle aRect(Point(X, Y), Size(nCursorWidth, pCursor->GetHeight()));
-
-            std::vector<vcl::LOKPayloadItem> aPayload;
-            aPayload.push_back(std::make_pair("rectangle", aRect.toString()));
-
-            Dialog* pParentDlg = GetParentDialog();
-            if (pParentDlg)
-                pParentDlg->LOKCursor("cursor_invalidate", aPayload);
-        }
     }
 }
 
@@ -1905,16 +1888,6 @@ void Edit::GetFocus()
         SetInputContext( InputContext( GetFont(), !IsReadOnly() ? InputContextFlags::Text|InputContextFlags::ExtText : InputContextFlags::NONE ) );
     }
 
-    // notify dialog's cursor visible status
-    if (comphelper::LibreOfficeKit::isActive())
-    {
-        std::vector<vcl::LOKPayloadItem> aPayload;
-        aPayload.push_back(std::make_pair(OString("visible"), OString("true")));
-        Dialog* pParentDlg = GetParentDialog();
-        if (pParentDlg)
-            pParentDlg->LOKCursor("cursor_visible", aPayload);
-    }
-
     Control::GetFocus();
 }
 
@@ -1942,17 +1915,6 @@ void Edit::LoseFocus()
             ImplInvalidateOrRepaint();    // Selektion malen
     }
 
-
-    // notify dialog's cursor visible status
-    if (comphelper::LibreOfficeKit::isActive())
-    {
-        std::vector<vcl::LOKPayloadItem> aPayload;
-        aPayload.push_back(std::make_pair(OString("visible"), OString("false")));
-        Dialog* pParentDlg = GetParentDialog();
-        if (pParentDlg)
-            pParentDlg->LOKCursor("cursor_visible", aPayload);
-    }
-
     Control::LoseFocus();
 }
 
diff --git a/vcl/source/window/cursor.cxx b/vcl/source/window/cursor.cxx
index 2133f1821bfb..079d039a2f21 100644
--- a/vcl/source/window/cursor.cxx
+++ b/vcl/source/window/cursor.cxx
@@ -17,6 +17,9 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
+#include <memory>
+
+#include <comphelper/lok.hxx>
 #include <vcl/svapp.hxx>
 #include <vcl/timer.hxx>
 #include <vcl/settings.hxx>
@@ -186,6 +189,9 @@ void vcl::Cursor::ImplDoShow( bool bDrawDirect, bool bRestore )
                 mpData->mbCurVisible = false;
                 mpData->maTimer.SetTimeoutHdl( LINK( this, Cursor, ImplTimerHdl ) );
                 mpData->maTimer.SetDebugName( "vcl ImplCursorData maTimer" );
+
+                // tell about "initial" coordinates
+                LOKNotify( pWindow, "cursor_invalidate" );
             }
 
             mpData->mpWindow    = pWindow;
@@ -200,11 +206,43 @@ void vcl::Cursor::ImplDoShow( bool bDrawDirect, bool bRestore )
                     mpData->maTimer.Start();
                 else if ( !mpData->mbCurVisible )
                     ImplDraw();
+                LOKNotify( pWindow, "cursor_visible" );
             }
         }
     }
 }
 
+void vcl::Cursor::LOKNotify( vcl::Window* pWindow, const OUString& rAction )
+{
+    if (VclPtr<vcl::Window> pParent = pWindow->GetParentWithLOKNotifier())
+    {
+        assert(pWindow && "Cannot notify without a window");
+        assert(mpData && "Require ImplCursorData");
+        assert(comphelper::LibreOfficeKit::isActive());
+
+        if (comphelper::LibreOfficeKit::isDialogPainting())
+            return;
+
+        const vcl::ILibreOfficeKitNotifier* pNotifier = pParent->GetLOKNotifier();
+        std::vector<vcl::LOKPayloadItem> aItems;
+        if (rAction == "cursor_visible")
+            aItems.emplace_back("visible", mpData->mbCurVisible ? "true" : "false");
+        else if (rAction == "cursor_invalidate")
+        {
+            const long nX = pWindow->GetOutOffXPixel() + pWindow->LogicToPixel(GetPos()).X();
+            const long nY = pWindow->GetOutOffYPixel() + pWindow->LogicToPixel(GetPos()).Y();
+            Size aSize = pWindow->LogicToPixel(GetSize());
+            if (!aSize.Width())
+                aSize.Width() = pWindow->GetSettings().GetStyleSettings().GetCursorSize();
+
+            const Rectangle aRect(Point(nX, nY), aSize);
+            aItems.emplace_back("rectangle", aRect.toString());
+        }
+
+        pNotifier->notifyWindow(pParent->GetLOKWindowId(), rAction, aItems);
+    }
+}
+
 bool vcl::Cursor::ImplDoHide( bool bSuspend )
 {
     bool bWasCurVisible = false;
@@ -216,6 +254,7 @@ bool vcl::Cursor::ImplDoHide( bool bSuspend )
 
         if ( !bSuspend )
         {
+            LOKNotify( mpData->mpWindow, "cursor_visible" );
             mpData->maTimer.Stop();
             mpData->mpWindow = nullptr;
         }
@@ -253,6 +292,7 @@ void vcl::Cursor::ImplNew()
         ImplDraw();
         if ( !mpWindow )
         {
+            LOKNotify( mpData->mpWindow, "cursor_invalidate" );
             if ( mpData->maTimer.GetTimeout() != STYLE_CURSOR_NOBLINKTIME )
                 mpData->maTimer.Start();
         }
diff --git a/vcl/source/window/window.cxx b/vcl/source/window/window.cxx
index 962c90904c43..7eaa26482630 100644
--- a/vcl/source/window/window.cxx
+++ b/vcl/source/window/window.cxx
@@ -3297,17 +3297,6 @@ void Window::LOKKeyUp(const KeyEvent& rKeyEvent)
     ImplWindowFrameProc(this, SalEvent::ExternalKeyUp, &rKeyEvent);
 }
 
-void Window::LOKCursor(const OUString& rAction, const std::vector<vcl::LOKPayloadItem>& rPayload)
-{
-    assert(comphelper::LibreOfficeKit::isActive());
-
-    if (comphelper::LibreOfficeKit::isDialogPainting())
-        return;
-
-    if (const vcl::ILibreOfficeKitNotifier* pNotifier = GetLOKNotifier())
-        pNotifier->notifyWindow(GetLOKWindowId(), rAction, rPayload);
-}
-
 void Window::ImplCallDeactivateListeners( vcl::Window *pNew )
 {
     // no deactivation if the newly activated window is my child


More information about the Libreoffice-commits mailing list