[Libreoffice-commits] core.git: 3 commits - include/vcl vcl/source

Pranav Kant pranavk at collabora.co.uk
Fri Dec 8 18:52:52 UTC 2017


 include/vcl/cursor.hxx         |    1 +
 include/vcl/window.hxx         |    1 -
 vcl/source/control/edit.cxx    |   38 --------------------------------------
 vcl/source/window/cursor.cxx   |   39 +++++++++++++++++++++++++++++++++++++++
 vcl/source/window/floatwin.cxx |    6 +++---
 vcl/source/window/window.cxx   |   17 +++--------------
 6 files changed, 46 insertions(+), 56 deletions(-)

New commits:
commit 0898ced81a3129b4c36c08e0222f96c513f0fd77
Author: Pranav Kant <pranavk at collabora.co.uk>
Date:   Fri Dec 8 18:06:36 2017 +0530

    Use ImplIsFloatingWindow instead of dynamic_cast
    
    Change-Id: I09f351ae5d8d1b5c1a405d7aa8082be6014268b3

diff --git a/vcl/source/window/window.cxx b/vcl/source/window/window.cxx
index 3c56d46e6efc..fecc5530202c 100644
--- a/vcl/source/window/window.cxx
+++ b/vcl/source/window/window.cxx
@@ -3235,7 +3235,7 @@ void Window::LogicMouseButtonDown(const MouseEvent& rMouseEvent)
     // When we're not doing tiled rendering, then positions must be passed as pixels.
     assert(comphelper::LibreOfficeKit::isActive());
 
-    if (dynamic_cast<FloatingWindow*>(this) != nullptr)
+    if (ImplIsFloatingWindow())
         ImplWindowFrameProc(ImplGetBorderWindow(), SalEvent::ExternalMouseButtonDown, &rMouseEvent);
     else
         ImplWindowFrameProc(this, SalEvent::ExternalMouseButtonDown, &rMouseEvent);
@@ -3246,7 +3246,7 @@ void Window::LogicMouseButtonUp(const MouseEvent& rMouseEvent)
     // When we're not doing tiled rendering, then positions must be passed as pixels.
     assert(comphelper::LibreOfficeKit::isActive());
 
-    if (dynamic_cast<FloatingWindow*>(this) != nullptr)
+    if (ImplIsFloatingWindow())
         ImplWindowFrameProc(ImplGetBorderWindow(), SalEvent::ExternalMouseButtonUp, &rMouseEvent);
     else
         ImplWindowFrameProc(this, SalEvent::ExternalMouseButtonUp, &rMouseEvent);
@@ -3257,7 +3257,7 @@ void Window::LogicMouseMove(const MouseEvent& rMouseEvent)
     // When we're not doing tiled rendering, then positions must be passed as pixels.
     assert(comphelper::LibreOfficeKit::isActive());
 
-    if (dynamic_cast<FloatingWindow*>(this) != nullptr)
+    if (ImplIsFloatingWindow())
         ImplWindowFrameProc(ImplGetBorderWindow(), SalEvent::ExternalMouseMove, &rMouseEvent);
     else
         ImplWindowFrameProc(this, SalEvent::ExternalMouseMove, &rMouseEvent);
commit 782f8be6d4076b0152442e6200426010c1f6704f
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

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 f02acf125d23..0f2bc9024ea3 100644
--- a/include/vcl/window.hxx
+++ b/include/vcl/window.hxx
@@ -1226,7 +1226,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 add78c2f49b3..7560860de9de 100644
--- a/vcl/source/control/edit.cxx
+++ b/vcl/source/control/edit.cxx
@@ -1145,23 +1145,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 tools::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);
-        }
     }
 }
 
@@ -1908,16 +1891,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();
 }
 
@@ -1945,17 +1918,6 @@ void Edit::LoseFocus()
             ImplInvalidateOrRepaint();    // paint the selection
     }
 
-
-    // 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 a4c0187097e6..d3049640d07d 100644
--- a/vcl/source/window/cursor.cxx
+++ b/vcl/source/window/cursor.cxx
@@ -18,6 +18,8 @@
  */
 
 #include <memory>
+
+#include <comphelper/lok.hxx>
 #include <vcl/svapp.hxx>
 #include <vcl/timer.hxx>
 #include <vcl/settings.hxx>
@@ -187,6 +189,9 @@ void vcl::Cursor::ImplDoShow( bool bDrawDirect, bool bRestore )
                 mpData->mbCurVisible = false;
                 mpData->maTimer.SetInvokeHandler( LINK( this, Cursor, ImplTimerHdl ) );
                 mpData->maTimer.SetDebugName( "vcl ImplCursorData maTimer" );
+
+                // tell about "initial" coordinates
+                LOKNotify( pWindow, "cursor_invalidate" );
             }
 
             mpData->mpWindow    = pWindow;
@@ -201,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;
@@ -217,6 +254,7 @@ bool vcl::Cursor::ImplDoHide( bool bSuspend )
 
         if ( !bSuspend )
         {
+            LOKNotify( mpData->mpWindow, "cursor_visible" );
             mpData->maTimer.Stop();
             mpData->mpWindow = nullptr;
         }
@@ -254,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 4ca9e449e683..3c56d46e6efc 100644
--- a/vcl/source/window/window.cxx
+++ b/vcl/source/window/window.cxx
@@ -3277,17 +3277,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
commit 42fae43d70d3d1b8fcc9fc6328b1060d6d72abfc
Author: Pranav Kant <pranavk at collabora.co.uk>
Date:   Thu Dec 7 21:55:28 2017 +0530

    lokdialog: Open floating window on InitShow only
    
    Okay, my bad. InitShow happens after Visible. And InitShow also does
    some layouting. Emitting the created callback on InitShow means sending
    more accurate sizes, etc. The different in sizes is 0 for combo boxes,
    but significant for custom controls like color picker, etc. So emit
    created callback on InitShow to keep custom controls working.
    
    Change-Id: I40b6a18b917dff0eebcfd4c273f3399f3bdc7456

diff --git a/vcl/source/window/floatwin.cxx b/vcl/source/window/floatwin.cxx
index d6890e4823cc..d533f558ec6b 100644
--- a/vcl/source/window/floatwin.cxx
+++ b/vcl/source/window/floatwin.cxx
@@ -604,9 +604,9 @@ void FloatingWindow::StateChanged( StateChangedType nType )
     SystemWindow::StateChanged( nType );
 
     VclPtr<vcl::Window> pParent = GetParentWithLOKNotifier();
-    if (pParent && nType == StateChangedType::Visible)
+    if (pParent)
     {
-        if (IsVisible())
+        if (nType == StateChangedType::InitShow)
         {
             std::vector<vcl::LOKPayloadItem> aItems;
             if (pParent == this)
@@ -626,7 +626,7 @@ void FloatingWindow::StateChanged( StateChangedType nType )
             aItems.emplace_back(std::make_pair("position", mpImplData->maPos.toString()));
             GetLOKNotifier()->notifyWindow(GetLOKWindowId(), "created", aItems);
         }
-        else if (!IsVisible())
+        else if (!IsVisible() && nType == StateChangedType::Visible)
         {
             assert(GetLOKNotifier());
             GetLOKNotifier()->notifyWindow(GetLOKWindowId(), "close");


More information about the Libreoffice-commits mailing list