[Libreoffice-commits] core.git: 2 commits - sfx2/source vcl/source

Pranav Kant pranavk at collabora.co.uk
Thu Dec 14 08:48:38 UTC 2017


 sfx2/source/dialog/basedlgs.cxx |   22 ++++++++++++--------
 vcl/source/window/window.cxx    |   44 +++++++++++++++++++++++++++++-----------
 2 files changed, 46 insertions(+), 20 deletions(-)

New commits:
commit 76de866e162502518acbc0ab020c257b80946c2d
Author: Pranav Kant <pranavk at collabora.co.uk>
Date:   Thu Dec 14 13:11:00 2017 +0530

    lokdialog: Send close callback when dialog dissappears too
    
    Change-Id: I88bea3dc1ae938d31462e85ca1a8f48dd13e8e89

diff --git a/sfx2/source/dialog/basedlgs.cxx b/sfx2/source/dialog/basedlgs.cxx
index f44ed4c15446..a11ddad63f02 100644
--- a/sfx2/source/dialog/basedlgs.cxx
+++ b/sfx2/source/dialog/basedlgs.cxx
@@ -161,10 +161,9 @@ void SfxModalDialog::dispose()
     SetDialogData_Impl();
     delete pOutputSet;
 
-    SfxViewShell* pViewShell = SfxViewShell::Current();
-    if (comphelper::LibreOfficeKit::isActive() && pViewShell)
+    if (comphelper::LibreOfficeKit::isActive() && GetLOKNotifier())
     {
-        pViewShell->notifyWindow(GetLOKWindowId(), "close");
+        SfxViewShell::Current()->notifyWindow(GetLOKWindowId(), "close");
         ReleaseLOKNotifier();
     }
 
@@ -208,13 +207,13 @@ void SfxModalDialog::CreateOutputItemSet( const SfxItemSet& rSet )
 
 void SfxModalDialog::StateChanged( StateChangedType nType )
 {
-    if (comphelper::LibreOfficeKit::isActive() && nType == StateChangedType::InitShow)
+    if (comphelper::LibreOfficeKit::isActive())
     {
-        // There are some dialogs, like Hyperlink dialog, which inherit from
-        // SfxModalDialog even though they are modeless, i.e., their Execute method
-        // isn't called.
-        if (!GetLOKNotifier())
+        if (nType == StateChangedType::InitShow && !GetLOKNotifier())
         {
+            // There are some dialogs, like Hyperlink dialog, which inherit from
+            // SfxModalDialog even though they are modeless, i.e., their Execute method
+            // isn't called.
             SetLOKNotifier(SfxViewShell::Current());
             const Size aSize = GetOptimalSize();
             std::vector<vcl::LOKPayloadItem> aItems;
@@ -222,6 +221,13 @@ void SfxModalDialog::StateChanged( StateChangedType nType )
             aItems.emplace_back(std::make_pair("size", aSize.toString()));
             SfxViewShell::Current()->notifyWindow(GetLOKWindowId(), "created", aItems);
         }
+        else if (nType == StateChangedType::Visible &&
+                 !IsVisible() &&
+                 GetLOKNotifier())
+        {
+            SfxViewShell::Current()->notifyWindow(GetLOKWindowId(), "close");
+            ReleaseLOKNotifier();
+        }
     }
 
     ModalDialog::StateChanged(nType);
commit 53f8f28c53391ef1cadefaf16c3a9e81e04ac7f5
Author: Pranav Kant <pranavk at collabora.co.uk>
Date:   Thu Dec 14 12:53:35 2017 +0530

    lokdialog: Unblock custom window mouse key events
    
    In some cases, the mouse event blocks. Eg: when the mouse event is
    responsible for launching a new dialog (cf. Spell dialog -> Options).
    We don't want any kind of blocking behavior whatsoever in LOK. Post all
    custom window mouse events back the main-loop thread and keep the
    current LOK thread free.
    
    Change-Id: I018870fadcb62dbb7b33a7d93f8af3a0000442b5

diff --git a/vcl/source/window/window.cxx b/vcl/source/window/window.cxx
index 1e76d47890a2..8075a6368784 100644
--- a/vcl/source/window/window.cxx
+++ b/vcl/source/window/window.cxx
@@ -3231,15 +3231,33 @@ VclPtr<vcl::Window> Window::GetParentWithLOKNotifier()
     return pWindow;
 }
 
+struct LOKAsyncEvent
+{
+    VclPtr<vcl::Window> mpWindow;
+    SalEvent mnEvent;
+    MouseEvent maMouseEvent;
+};
+
+static void LOKAsyncEventLink( void* pEvent, void* )
+{
+    LOKAsyncEvent* pLOKEv = static_cast<LOKAsyncEvent*>(pEvent);
+    if (!pLOKEv->mpWindow->IsDisposed())
+    {
+        ImplWindowFrameProc(pLOKEv->mpWindow, pLOKEv->mnEvent, &pLOKEv->maMouseEvent);
+    }
+}
+
 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 (ImplIsFloatingWindow())
-        ImplWindowFrameProc(ImplGetBorderWindow(), SalEvent::ExternalMouseButtonDown, &rMouseEvent);
-    else
-        ImplWindowFrameProc(this, SalEvent::ExternalMouseButtonDown, &rMouseEvent);
+    LOKAsyncEvent* pEv = new LOKAsyncEvent;
+    pEv->mpWindow = ImplIsFloatingWindow() ? ImplGetBorderWindow() : this;
+    pEv->mnEvent = SalEvent::ExternalMouseButtonDown;
+    pEv->maMouseEvent = rMouseEvent;
+    Application::PostUserEvent( Link<void*, void>(pEv, LOKAsyncEventLink) );
+
 }
 
 void Window::LogicMouseButtonUp(const MouseEvent& rMouseEvent)
@@ -3247,10 +3265,11 @@ 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 (ImplIsFloatingWindow())
-        ImplWindowFrameProc(ImplGetBorderWindow(), SalEvent::ExternalMouseButtonUp, &rMouseEvent);
-    else
-        ImplWindowFrameProc(this, SalEvent::ExternalMouseButtonUp, &rMouseEvent);
+    LOKAsyncEvent* pEv = new LOKAsyncEvent;
+    pEv->mpWindow = ImplIsFloatingWindow() ? ImplGetBorderWindow() : this;
+    pEv->mnEvent = SalEvent::ExternalMouseButtonUp;
+    pEv->maMouseEvent = rMouseEvent;
+    Application::PostUserEvent( Link<void*, void>(pEv, LOKAsyncEventLink) );
 }
 
 void Window::LogicMouseMove(const MouseEvent& rMouseEvent)
@@ -3258,10 +3277,11 @@ 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 (ImplIsFloatingWindow())
-        ImplWindowFrameProc(ImplGetBorderWindow(), SalEvent::ExternalMouseMove, &rMouseEvent);
-    else
-        ImplWindowFrameProc(this, SalEvent::ExternalMouseMove, &rMouseEvent);
+    LOKAsyncEvent* pEv = new LOKAsyncEvent;
+    pEv->mpWindow = ImplIsFloatingWindow() ? ImplGetBorderWindow() : this;
+    pEv->mnEvent = SalEvent::ExternalMouseMove;
+    pEv->maMouseEvent = rMouseEvent;
+    Application::PostUserEvent( Link<void*, void>(pEv, LOKAsyncEventLink) );
 }
 
 void Window::LOKKeyInput(const KeyEvent& rKeyEvent)


More information about the Libreoffice-commits mailing list