[Libreoffice-commits] core.git: 5 commits - desktop/source include/LibreOfficeKit include/vcl sc/qa sc/source sd/qa sd/source sw/qa sw/source vcl/source

Pranav Kant pranavk at collabora.co.uk
Tue Feb 27 14:14:31 UTC 2018


 desktop/source/lib/init.cxx                    |   82 +------------------
 include/LibreOfficeKit/LibreOfficeKit.h        |   10 +-
 include/LibreOfficeKit/LibreOfficeKit.hxx      |    6 -
 include/vcl/IDialogRenderable.hxx              |    2 
 include/vcl/ITiledRenderable.hxx               |  105 +++++++++++++++++++++++++
 include/vcl/window.hxx                         |    7 +
 sc/qa/unit/tiledrendering/tiledrendering.cxx   |    3 
 sc/source/ui/inc/gridwin.hxx                   |    7 +
 sc/source/ui/unoobj/docuno.cxx                 |   47 ++++-------
 sc/source/ui/view/gridwin.cxx                  |   15 +++
 sd/qa/unit/tiledrendering/tiledrendering.cxx   |    7 +
 sd/source/ui/inc/ViewShell.hxx                 |    6 -
 sd/source/ui/inc/Window.hxx                    |    6 +
 sd/source/ui/unoidl/unomodel.cxx               |   38 ++++-----
 sd/source/ui/view/sdwindow.cxx                 |   39 +++++++++
 sd/source/ui/view/viewshel.cxx                 |   39 ---------
 sw/qa/extras/tiledrendering/tiledrendering.cxx |   44 ++++++++--
 sw/source/uibase/inc/edtwin.hxx                |    6 -
 sw/source/uibase/uno/unotxdoc.cxx              |   34 ++++----
 vcl/source/window/mouse.cxx                    |   17 ++++
 20 files changed, 315 insertions(+), 205 deletions(-)

New commits:
commit 3c3e07b51fb09d09cfef54193f93b07304f4ccda
Author: Pranav Kant <pranavk at collabora.co.uk>
Date:   Sat Feb 24 12:19:57 2018 +0530

    lok: All mouse,key events async
    
    custom posting of mouse,key events on main thread
    
    This still bypasses vcl while keeping the processing of events on the
    main thread which is what we want.
    
    Change-Id: Ia7a6f5ef1ac546245715abe418d261b49df12d4c
    Reviewed-on: https://gerrit.libreoffice.org/50274
    Reviewed-by: Aron Budea <aron.budea at collabora.com>
    Tested-by: Aron Budea <aron.budea at collabora.com>

diff --git a/include/vcl/ITiledRenderable.hxx b/include/vcl/ITiledRenderable.hxx
index ab7b4f027a45..9b0e7dbe8e3a 100644
--- a/include/vcl/ITiledRenderable.hxx
+++ b/include/vcl/ITiledRenderable.hxx
@@ -14,6 +14,8 @@
 #include <LibreOfficeKit/LibreOfficeKitTypes.h>
 #include <tools/gen.hxx>
 #include <svx/ruler.hxx>
+#include <vcl/event.hxx>
+#include <vcl/vclevent.hxx>
 #include <vcl/pointr.hxx>
 #include <vcl/ptrstyle.hxx>
 #include <vcl/virdev.hxx>
@@ -88,6 +90,48 @@ protected:
     int mnTilePixelWidth, mnTilePixelHeight;
     int mnTileTwipWidth, mnTileTwipHeight;
 public:
+    struct LOKAsyncEventData
+    {
+        VclPtr<vcl::Window> mpWindow;
+        VclEventId mnEvent;
+        MouseEvent maMouseEvent;
+        KeyEvent maKeyEvent;
+    };
+
+    static void LOKPostAsyncEvent(void* pEv, void*)
+    {
+        LOKAsyncEventData* pLOKEv = static_cast<LOKAsyncEventData*>(pEv);
+        switch (pLOKEv->mnEvent)
+        {
+        case VclEventId::WindowKeyInput:
+            pLOKEv->mpWindow->KeyInput(pLOKEv->maKeyEvent);
+            break;
+        case VclEventId::WindowKeyUp:
+            pLOKEv->mpWindow->KeyUp(pLOKEv->maKeyEvent);
+            break;
+        case VclEventId::WindowMouseButtonDown:
+            pLOKEv->mpWindow->LogicMouseButtonDown(pLOKEv->maMouseEvent);
+            // Invoke the context menu
+            if (pLOKEv->maMouseEvent.GetButtons() & MOUSE_RIGHT)
+            {
+                const CommandEvent aCEvt(pLOKEv->maMouseEvent.GetPosPixel(), CommandEventId::ContextMenu, true, nullptr);
+                pLOKEv->mpWindow->Command(aCEvt);
+            }
+            break;
+        case VclEventId::WindowMouseButtonUp:
+            pLOKEv->mpWindow->LogicMouseButtonUp(pLOKEv->maMouseEvent);
+            break;
+        case VclEventId::WindowMouseMove:
+            pLOKEv->mpWindow->LogicMouseMove(pLOKEv->maMouseEvent);
+            break;
+        default:
+            assert(false);
+            break;
+        }
+
+        delete pLOKEv;
+    }
+
     virtual ~ITiledRenderable();
 
     /**
diff --git a/include/vcl/window.hxx b/include/vcl/window.hxx
index 9acf3450a391..e6a56466d6e6 100644
--- a/include/vcl/window.hxx
+++ b/include/vcl/window.hxx
@@ -1229,6 +1229,13 @@ public:
     /// Dialog / window tunneling related methods.
     Size PaintActiveFloatingWindow(VirtualDevice& rDevice) const;
 
+    /// Same as MouseButtonDown(), but coordinates are in logic unit. used for LOK
+    virtual void LogicMouseButtonDown(const MouseEvent&) {};
+    /// Same as MouseButtonUp(), but coordinates are in logic unit. used for LOK
+    virtual void LogicMouseButtonUp(const MouseEvent&) {};
+    /// Same as MouseMove(), but coordinates are in logic unit. used for LOK
+    virtual void LogicMouseMove(const MouseEvent&) {};
+
     /** @name Accessibility
      */
     ///@{
diff --git a/sc/source/ui/inc/gridwin.hxx b/sc/source/ui/inc/gridwin.hxx
index f0cd3c4ce7d3..5190385de016 100644
--- a/sc/source/ui/inc/gridwin.hxx
+++ b/sc/source/ui/inc/gridwin.hxx
@@ -437,6 +437,13 @@ public:
                                   long nTileHeight);
     void updateLibreOfficeKitCellCursor(const SfxViewShell* pOtherShell) const;
 
+    /// Same as MouseButtonDown(), but coordinates are in logic unit.
+    virtual void LogicMouseButtonDown(const MouseEvent& rMouseEvent) override;
+    /// Same as MouseButtonUp(), but coordinates are in logic unit.
+    virtual void LogicMouseButtonUp(const MouseEvent& rMouseEvent) override;
+    /// Same as MouseMove(), but coordinates are in logic unit.
+    virtual void LogicMouseMove(const MouseEvent& rMouseEvent) override;
+
     ScViewData* getViewData();
     virtual FactoryFunction GetUITestFactory() const override;
 
diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx
index 46a2ac32eb76..8d3881bb99b1 100644
--- a/sc/source/ui/unoobj/docuno.cxx
+++ b/sc/source/ui/unoobj/docuno.cxx
@@ -601,6 +601,7 @@ Size ScModelObj::getDocumentSize()
     return aSize;
 }
 
+
 void ScModelObj::postKeyEvent(int nType, int nCharCode, int nKeyCode)
 {
     SolarMutexGuard aGuard;
@@ -609,21 +610,22 @@ void ScModelObj::postKeyEvent(int nType, int nCharCode, int nKeyCode)
     if (!pWindow)
         return;
 
-    if (!pWindow->HasFocus())
-        pWindow->GrabFocus();
-    KeyEvent aEvent(nCharCode, nKeyCode, 0);
+    LOKAsyncEventData* pLOKEv = new LOKAsyncEventData;
+    pLOKEv->mpWindow = pWindow;
     switch (nType)
     {
     case LOK_KEYEVENT_KEYINPUT:
-        Application::PostKeyEvent(VCLEVENT_WINDOW_KEYINPUT, pWindow, &aEvent);
+        pLOKEv->mnEvent = VclEventId::WindowKeyInput;
         break;
     case LOK_KEYEVENT_KEYUP:
-        Application::PostKeyEvent(VCLEVENT_WINDOW_KEYUP, pWindow, &aEvent);
+        pLOKEv->mnEvent = VclEventId::WindowKeyUp;
         break;
     default:
         assert(false);
-        break;
     }
+
+    pLOKEv->maKeyEvent = KeyEvent(nCharCode, nKeyCode, 0);
+    Application::PostUserEvent(Link<void*, void>(pLOKEv, ITiledRenderable::LOKPostAsyncEvent));
 }
 
 void ScModelObj::postMouseEvent(int nType, int nX, int nY, int nCount, int nButtons, int nModifier)
@@ -658,34 +660,29 @@ void ScModelObj::postMouseEvent(int nType, int nX, int nY, int nCount, int nButt
             return;
     }
 
-
-    // Calc operates in pixels...
-    Point aPos(nX * pViewData->GetPPTX(), nY * pViewData->GetPPTY());
-    MouseEvent aEvent(aPos, nCount,
-            MouseEventModifiers::SIMPLECLICK, nButtons, nModifier);
-
+    LOKAsyncEventData* pLOKEv = new LOKAsyncEventData;
+    pLOKEv->mpWindow = pGridWindow;
     switch (nType)
     {
     case LOK_MOUSEEVENT_MOUSEBUTTONDOWN:
-        Application::PostMouseEvent(VCLEVENT_WINDOW_MOUSEBUTTONDOWN, pGridWindow, &aEvent);
-
-        // Invoke the context menu
-        if (nButtons & MOUSE_RIGHT)
-        {
-            const CommandEvent aCEvt(aPos, CommandEventId::ContextMenu, true, nullptr);
-            pGridWindow->Command(aCEvt);
-        }
+        pLOKEv->mnEvent = VclEventId::WindowMouseButtonDown;
         break;
     case LOK_MOUSEEVENT_MOUSEBUTTONUP:
-        Application::PostMouseEvent(VCLEVENT_WINDOW_MOUSEBUTTONUP, pGridWindow, &aEvent);
+        pLOKEv->mnEvent = VclEventId::WindowMouseButtonUp;
         break;
     case LOK_MOUSEEVENT_MOUSEMOVE:
-        Application::PostMouseEvent(VCLEVENT_WINDOW_MOUSEMOVE, pGridWindow, &aEvent);
+        pLOKEv->mnEvent = VclEventId::WindowMouseMove;
         break;
     default:
         assert(false);
-        break;
     }
+
+    // Calc operates in pixels...
+    const Point aPos(nX * pViewData->GetPPTX(), nY * pViewData->GetPPTY());
+    pLOKEv->maMouseEvent = MouseEvent(aPos, nCount,
+                                      MouseEventModifiers::SIMPLECLICK,
+                                      nButtons, nModifier);
+    Application::PostUserEvent(Link<void*, void>(pLOKEv, ITiledRenderable::LOKPostAsyncEvent));
 }
 
 void ScModelObj::setTextSelection(int nType, int nX, int nY)
diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx
index 007522ec6324..4795290aa909 100644
--- a/sc/source/ui/view/gridwin.cxx
+++ b/sc/source/ui/view/gridwin.cxx
@@ -1330,6 +1330,21 @@ bool ScGridWindow::TestMouse( const MouseEvent& rMEvt, bool bAction )
     return bNewPointer;
 }
 
+void ScGridWindow::LogicMouseButtonDown(const MouseEvent& rMouseEvent)
+{
+    MouseButtonDown(rMouseEvent);
+}
+
+void ScGridWindow::LogicMouseButtonUp(const MouseEvent& rMouseEvent)
+{
+    MouseButtonUp(rMouseEvent);
+}
+
+void ScGridWindow::LogicMouseMove(const MouseEvent& rMouseEvent)
+{
+    MouseMove(rMouseEvent);
+}
+
 void ScGridWindow::MouseButtonDown( const MouseEvent& rMEvt )
 {
     nNestedButtonState = ScNestedButtonState::Down;
diff --git a/sd/qa/unit/tiledrendering/tiledrendering.cxx b/sd/qa/unit/tiledrendering/tiledrendering.cxx
index 310dd90f1910..b0ea2340574a 100644
--- a/sd/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sd/qa/unit/tiledrendering/tiledrendering.cxx
@@ -358,6 +358,7 @@ void SdTiledRenderingTest::testRegisterCallback()
 
 void SdTiledRenderingTest::testPostKeyEvent()
 {
+    comphelper::LibreOfficeKit::setActive();
     SdXImpressDocument* pXImpressDocument = createDoc("dummy.odp");
     sd::ViewShell* pViewShell = pXImpressDocument->GetDocShell()->GetViewShell();
     SdPage* pActualPage = pViewShell->GetActualPage();
@@ -372,6 +373,7 @@ void SdTiledRenderingTest::testPostKeyEvent()
 
     pXImpressDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 'x', 0);
     pXImpressDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 'x', 0);
+    Scheduler::ProcessEventsToIdle();
 
     CPPUNIT_ASSERT(pView->GetTextEditObject());
     EditView& rEditView = pView->GetTextEditOutlinerView()->GetEditView();
@@ -381,6 +383,7 @@ void SdTiledRenderingTest::testPostKeyEvent()
     rEditView.SetSelection(aWordSelection);
     // Did we enter the expected character?
     CPPUNIT_ASSERT_EQUAL(OUString("xx"), rEditView.GetSelected());
+    comphelper::LibreOfficeKit::setActive(false);
 }
 
 void SdTiledRenderingTest::testPostMouseEvent()
@@ -411,6 +414,7 @@ void SdTiledRenderingTest::testPostMouseEvent()
     pXImpressDocument->postMouseEvent(LOK_MOUSEEVENT_MOUSEBUTTONUP,
                                       convertMm100ToTwip(aPosition.getX()), convertMm100ToTwip(aPosition.getY()),
                                       1, MOUSE_LEFT, 0);
+    Scheduler::ProcessEventsToIdle();
     CPPUNIT_ASSERT(pView->GetTextEditObject());
     // The new cursor position must be before the first word.
     CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0), rEditView.GetSelection().nStartPos);
@@ -1353,6 +1357,7 @@ void SdTiledRenderingTest::testTdf102223()
     pXImpressDocument->postMouseEvent(LOK_MOUSEEVENT_MOUSEBUTTONUP,
                                       convertMm100ToTwip(aRect.getX() + 2), convertMm100ToTwip(aRect.getY() + 2),
                                       1, MOUSE_LEFT, 0);
+    Scheduler::ProcessEventsToIdle();
     pView->SdrBeginTextEdit(pTableObject);
     CPPUNIT_ASSERT(pView->GetTextEditObject());
     EditView& rEditView = pView->GetTextEditOutlinerView()->GetEditView();
@@ -1447,6 +1452,7 @@ void SdTiledRenderingTest::testTdf103083()
     pXImpressDocument->postMouseEvent(LOK_MOUSEEVENT_MOUSEBUTTONUP,
                                       convertMm100ToTwip(aRect.getX() + 2), convertMm100ToTwip(aRect.getY() + 2),
                                       1, MOUSE_LEFT, 0);
+    Scheduler::ProcessEventsToIdle();
     pView->SdrBeginTextEdit(pTextObject);
     CPPUNIT_ASSERT(pView->GetTextEditObject());
     EditView& rEditView = pView->GetTextEditOutlinerView()->GetEditView();
@@ -1563,7 +1569,6 @@ void SdTiledRenderingTest::testTdf81754()
 
     pXImpressDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 'x', 0);
     pXImpressDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 'x', 0);
-
     Scheduler::ProcessEventsToIdle();
 
     // now save, reload, and assert that we did not lose the edit
diff --git a/sd/source/ui/inc/ViewShell.hxx b/sd/source/ui/inc/ViewShell.hxx
index 0686db158ea6..c3219dd4db52 100644
--- a/sd/source/ui/inc/ViewShell.hxx
+++ b/sd/source/ui/inc/ViewShell.hxx
@@ -416,12 +416,6 @@ public:
         SdPage* pPage,
         const sal_Int32 nInsertPosition = -1);
 
-    /// Same as MouseButtonDown(), but coordinates are in logic unit.
-    void LogicMouseButtonDown(const MouseEvent& rMouseEvent);
-    /// Same as MouseButtonUp(), but coordinates are in logic unit.
-    void LogicMouseButtonUp(const MouseEvent& rMouseEvent);
-    /// Same as MouseMove(), but coordinates are in logic unit.
-    void LogicMouseMove(const MouseEvent& rMouseEvent);
     /// Allows adjusting the point or mark of the selection to a document coordinate.
     void SetCursorMm100Position(const Point& rPosition, bool bPoint, bool bClearMark);
     /// Gets the currently selected text.
diff --git a/sd/source/ui/inc/Window.hxx b/sd/source/ui/inc/Window.hxx
index 487255ae8c40..d1aa74a91602 100644
--- a/sd/source/ui/inc/Window.hxx
+++ b/sd/source/ui/inc/Window.hxx
@@ -192,6 +192,12 @@ protected:
     Selection GetSurroundingTextSelection() const override;
     /// @see OutputDevice::LogicInvalidate().
     void LogicInvalidate(const ::tools::Rectangle* pRectangle) override;
+    /// Same as MouseButtonDown(), but coordinates are in logic unit.
+    virtual void LogicMouseButtonDown(const MouseEvent& rMouseEvent) override;
+    /// Same as MouseButtonUp(), but coordinates are in logic unit.
+    virtual void LogicMouseButtonUp(const MouseEvent& rMouseEvent) override;
+    /// Same as MouseMove(), but coordinates are in logic unit.
+    virtual void LogicMouseMove(const MouseEvent& rMouseEvent) override;
 
     FactoryFunction GetUITestFactory() const override;
 };
diff --git a/sd/source/ui/unoidl/unomodel.cxx b/sd/source/ui/unoidl/unomodel.cxx
index 3dc5e2839c74..8c8569a1a009 100644
--- a/sd/source/ui/unoidl/unomodel.cxx
+++ b/sd/source/ui/unoidl/unomodel.cxx
@@ -2476,19 +2476,22 @@ void SdXImpressDocument::postKeyEvent(int nType, int nCharCode, int nKeyCode)
     if (!pWindow)
         return;
 
-    KeyEvent aEvent(nCharCode, nKeyCode, 0);
+    LOKAsyncEventData* pLOKEv = new LOKAsyncEventData;
+    pLOKEv->mpWindow = pWindow;
     switch (nType)
     {
     case LOK_KEYEVENT_KEYINPUT:
-        pWindow->KeyInput(aEvent);
+        pLOKEv->mnEvent = VclEventId::WindowKeyInput;
         break;
     case LOK_KEYEVENT_KEYUP:
-        pWindow->KeyUp(aEvent);
+        pLOKEv->mnEvent = VclEventId::WindowKeyUp;
         break;
     default:
         assert(false);
-        break;
     }
+
+    pLOKEv->maKeyEvent = KeyEvent(nCharCode, nKeyCode, 0);
+    Application::PostUserEvent(Link<void*, void>(pLOKEv, ITiledRenderable::LOKPostAsyncEvent));
 }
 
 void SdXImpressDocument::postMouseEvent(int nType, int nX, int nY, int nCount, int nButtons, int nModifier)
@@ -2516,33 +2519,28 @@ void SdXImpressDocument::postMouseEvent(int nType, int nX, int nY, int nCount, i
             return;
     }
 
-    Window* pWindow = pViewShell->GetActiveWindow();
-
-    Point aPos(Point(convertTwipToMm100(nX), convertTwipToMm100(nY)));
-    MouseEvent aEvent(aPos, nCount,
-            MouseEventModifiers::SIMPLECLICK, nButtons, nModifier);
-
+    LOKAsyncEventData* pLOKEv = new LOKAsyncEventData;
+    pLOKEv->mpWindow = pViewShell->GetActiveWindow();
     switch (nType)
     {
     case LOK_MOUSEEVENT_MOUSEBUTTONDOWN:
-        pViewShell->LogicMouseButtonDown(aEvent);
-
-        if (nButtons & MOUSE_RIGHT)
-        {
-            const CommandEvent aCEvt(aPos, CommandEventId::ContextMenu, true, nullptr);
-            pViewShell->Command(aCEvt, pWindow);
-        }
+        pLOKEv->mnEvent = VclEventId::WindowMouseButtonDown;
         break;
     case LOK_MOUSEEVENT_MOUSEBUTTONUP:
-        pViewShell->LogicMouseButtonUp(aEvent);
+        pLOKEv->mnEvent = VclEventId::WindowMouseButtonUp;
         break;
     case LOK_MOUSEEVENT_MOUSEMOVE:
-        pViewShell->LogicMouseMove(aEvent);
+        pLOKEv->mnEvent = VclEventId::WindowMouseMove;
         break;
     default:
         assert(false);
-        break;
     }
+
+    const Point aPos(Point(convertTwipToMm100(nX), convertTwipToMm100(nY)));
+    pLOKEv->maMouseEvent = MouseEvent(aPos, nCount,
+                                      MouseEventModifiers::SIMPLECLICK,
+                                      nButtons, nModifier);
+    Application::PostUserEvent(Link<void*, void>(pLOKEv, ITiledRenderable::LOKPostAsyncEvent));
 }
 
 void SdXImpressDocument::setTextSelection(int nType, int nX, int nY)
diff --git a/sd/source/ui/view/sdwindow.cxx b/sd/source/ui/view/sdwindow.cxx
index 8d4a634c60de..b81249061b87 100644
--- a/sd/source/ui/view/sdwindow.cxx
+++ b/sd/source/ui/view/sdwindow.cxx
@@ -1014,6 +1014,45 @@ void Window::LogicInvalidate(const ::tools::Rectangle* pRectangle)
     SfxLokHelper::notifyInvalidation(&rSfxViewShell, sRectangle);
 }
 
+void Window::LogicMouseButtonDown(const MouseEvent& rMouseEvent)
+{
+    // When we're not doing tiled rendering, then positions must be passed as pixels.
+    assert(comphelper::LibreOfficeKit::isActive());
+
+    Point aPoint = GetPointerPosPixel();
+    SetLastMousePos(rMouseEvent.GetPosPixel());
+
+    mpViewShell->MouseButtonDown(rMouseEvent, this);
+
+    SetPointerPosPixel(aPoint);
+}
+
+void Window::LogicMouseButtonUp(const MouseEvent& rMouseEvent)
+{
+    // When we're not doing tiled rendering, then positions must be passed as pixels.
+    assert(comphelper::LibreOfficeKit::isActive());
+
+    Point aPoint = GetPointerPosPixel();
+    SetLastMousePos(rMouseEvent.GetPosPixel());
+
+    mpViewShell->MouseButtonUp(rMouseEvent, this);
+
+    SetPointerPosPixel(aPoint);
+}
+
+void Window::LogicMouseMove(const MouseEvent& rMouseEvent)
+{
+    // When we're not doing tiled rendering, then positions must be passed as pixels.
+    assert(comphelper::LibreOfficeKit::isActive());
+
+    Point aPoint = GetPointerPosPixel();
+    SetLastMousePos(rMouseEvent.GetPosPixel());
+
+    mpViewShell->MouseMove(rMouseEvent, this);
+
+    SetPointerPosPixel(aPoint);
+}
+
 FactoryFunction Window::GetUITestFactory() const
 {
     if (get_id() == "impress_win")
diff --git a/sd/source/ui/view/viewshel.cxx b/sd/source/ui/view/viewshel.cxx
index 9a8c4e856198..f9fdeb1c76a8 100644
--- a/sd/source/ui/view/viewshel.cxx
+++ b/sd/source/ui/view/viewshel.cxx
@@ -513,45 +513,6 @@ void ViewShell::MouseButtonDown(const MouseEvent& rMEvt, ::sd::Window* pWin)
     }
 }
 
-void ViewShell::LogicMouseButtonDown(const MouseEvent& rMouseEvent)
-{
-    // When we're not doing tiled rendering, then positions must be passed as pixels.
-    assert(comphelper::LibreOfficeKit::isActive());
-
-    Point aPoint = mpActiveWindow->GetPointerPosPixel();
-    mpActiveWindow->SetLastMousePos(rMouseEvent.GetPosPixel());
-
-    MouseButtonDown(rMouseEvent, mpActiveWindow);
-
-    mpActiveWindow->SetPointerPosPixel(aPoint);
-}
-
-void ViewShell::LogicMouseButtonUp(const MouseEvent& rMouseEvent)
-{
-    // When we're not doing tiled rendering, then positions must be passed as pixels.
-    assert(comphelper::LibreOfficeKit::isActive());
-
-    Point aPoint = mpActiveWindow->GetPointerPosPixel();
-    mpActiveWindow->SetLastMousePos(rMouseEvent.GetPosPixel());
-
-    MouseButtonUp(rMouseEvent, mpActiveWindow);
-
-    mpActiveWindow->SetPointerPosPixel(aPoint);
-}
-
-void ViewShell::LogicMouseMove(const MouseEvent& rMouseEvent)
-{
-    // When we're not doing tiled rendering, then positions must be passed as pixels.
-    assert(comphelper::LibreOfficeKit::isActive());
-
-    Point aPoint = mpActiveWindow->GetPointerPosPixel();
-    mpActiveWindow->SetLastMousePos(rMouseEvent.GetPosPixel());
-
-    MouseMove(rMouseEvent, mpActiveWindow);
-
-    mpActiveWindow->SetPointerPosPixel(aPoint);
-}
-
 void ViewShell::SetCursorMm100Position(const Point& rPosition, bool bPoint, bool bClearMark)
 {
     if (SdrView* pSdrView = GetView())
diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx b/sw/qa/extras/tiledrendering/tiledrendering.cxx
index 226291ac7422..b3cdea7541f7 100644
--- a/sw/qa/extras/tiledrendering/tiledrendering.cxx
+++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx
@@ -314,6 +314,7 @@ void SwTiledRenderingTest::testPostKeyEvent()
 
     pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 'x', 0);
     pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 'x', 0);
+    Scheduler::ProcessEventsToIdle();
     // Did we manage to insert the character after the first one?
     CPPUNIT_ASSERT_EQUAL(OUString("Axaa bbb."), pShellCursor->GetPoint()->nNode.GetNode().GetTextNode()->GetText());
 }
@@ -332,6 +333,7 @@ void SwTiledRenderingTest::testPostMouseEvent()
     aStart.setX(aStart.getX() - 1000);
     pXTextDocument->postMouseEvent(LOK_MOUSEEVENT_MOUSEBUTTONDOWN, aStart.getX(), aStart.getY(), 1, MOUSE_LEFT, 0);
     pXTextDocument->postMouseEvent(LOK_MOUSEEVENT_MOUSEBUTTONUP, aStart.getX(), aStart.getY(), 1, MOUSE_LEFT, 0);
+    Scheduler::ProcessEventsToIdle();
     // The new cursor position must be before the first word.
     CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0), pShellCursor->GetPoint()->nContent.GetIndex());
     comphelper::LibreOfficeKit::setActive(false);
@@ -936,20 +938,24 @@ void SwTiledRenderingTest::testShapeViewCursors()
     pWrtShell2->GetView().BeginTextEdit(pObject, pView->GetSdrPageView(), pWrtShell2->GetWin());
     pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 'x', 0);
     pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 'x', 0);
-
+    Scheduler::ProcessEventsToIdle();
     // Press a key in the second view, while the first one observes this.
-    aView1.m_bOwnCursorInvalidated = false;
     aView1.m_bViewCursorInvalidated = false;
     aView2.m_bOwnCursorInvalidated = false;
-    aView2.m_bViewCursorInvalidated = false;
+    const tools::Rectangle aLastOwnCursor1 = aView1.m_aOwnCursor;
+    const tools::Rectangle aLastViewCursor1 = aView1.m_aViewCursor;
+    const tools::Rectangle aLastOwnCursor2 = aView2.m_aOwnCursor;
+    const tools::Rectangle aLastViewCursor2 = aView2.m_aViewCursor;
+
     pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 'y', 0);
     pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 'y', 0);
+    Scheduler::ProcessEventsToIdle();
     // Make sure that aView1 gets a view-only cursor notification, while
     // aView2 gets a real cursor notification.
-    CPPUNIT_ASSERT(!aView1.m_bOwnCursorInvalidated);
-    CPPUNIT_ASSERT(aView1.m_bViewCursorInvalidated);
-    CPPUNIT_ASSERT(aView2.m_bOwnCursorInvalidated);
-    CPPUNIT_ASSERT(!aView2.m_bViewCursorInvalidated);
+    CPPUNIT_ASSERT(aView1.m_aOwnCursor == aLastOwnCursor1);
+    CPPUNIT_ASSERT(aView1.m_bViewCursorInvalidated && aLastViewCursor1 != aView1.m_aViewCursor);
+    CPPUNIT_ASSERT(aView2.m_bOwnCursorInvalidated && aLastOwnCursor2 != aView2.m_aOwnCursor);
+    CPPUNIT_ASSERT(aLastViewCursor2 == aView2.m_aViewCursor);
     mxComponent->dispose();
     mxComponent.clear();
 
@@ -1079,11 +1085,14 @@ void SwTiledRenderingTest::testTextEditViewInvalidations()
     pWrtShell->GetView().BeginTextEdit(pObject, pView->GetSdrPageView(), pWrtShell->GetWin());
     pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 'x', 0);
     pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 'x', 0);
+    Scheduler::ProcessEventsToIdle();
 
     // Assert that both views are invalidated when pressing a key while in text edit.
     aView1.m_bTilesInvalidated = false;
     pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 'y', 0);
     pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 'y', 0);
+    Scheduler::ProcessEventsToIdle();
+
     CPPUNIT_ASSERT(aView1.m_bTilesInvalidated);
 
     pWrtShell->EndTextEdit();
@@ -1111,6 +1120,9 @@ void SwTiledRenderingTest::testUndoInvalidations()
     pWrtShell->EndDoc();
     pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 'c', 0);
     pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 'c', 0);
+    Scheduler::ProcessEventsToIdle();
+    // ProcessEventsToIdle resets the view; set it again
+    SfxLokHelper::setView(nView1);
     SwShellCursor* pShellCursor = pWrtShell->getShellCursor(false);
     CPPUNIT_ASSERT_EQUAL(OUString("Aaa bbb.c"), pShellCursor->GetPoint()->nNode.GetNode().GetTextNode()->GetText());
 
@@ -1142,6 +1154,7 @@ void SwTiledRenderingTest::testUndoLimiting()
     pWrtShell2->EndDoc();
     pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 'c', 0);
     pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 'c', 0);
+    Scheduler::ProcessEventsToIdle();
     SwShellCursor* pShellCursor = pWrtShell2->getShellCursor(false);
     CPPUNIT_ASSERT_EQUAL(OUString("Aaa bbb.c"), pShellCursor->GetPoint()->nNode.GetNode().GetTextNode()->GetText());
 
@@ -1169,6 +1182,7 @@ void SwTiledRenderingTest::testUndoShapeLimiting()
     pWrtShell2->GetView().BeginTextEdit(pObject, pView->GetSdrPageView(), pWrtShell2->GetWin());
     pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 'x', 0);
     pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 'x', 0);
+    Scheduler::ProcessEventsToIdle();
 
     // Assert that the first view can't and the second view can undo the insertion.
     SwDoc* pDoc = pXTextDocument->GetDocShell()->GetDoc();
@@ -1198,6 +1212,7 @@ void SwTiledRenderingTest::testUndoDispatch()
     SfxLokHelper::setView(nView1);
     pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 'c', 0);
     pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 'c', 0);
+    Scheduler::ProcessEventsToIdle();
 
     // Click before the first word in the second view.
     SfxLokHelper::setView(nView2);
@@ -1207,6 +1222,7 @@ void SwTiledRenderingTest::testUndoDispatch()
     aStart.setX(aStart.getX() - 1000);
     pXTextDocument->postMouseEvent(LOK_MOUSEEVENT_MOUSEBUTTONDOWN, aStart.getX(), aStart.getY(), 1, MOUSE_LEFT, 0);
     pXTextDocument->postMouseEvent(LOK_MOUSEEVENT_MOUSEBUTTONUP, aStart.getX(), aStart.getY(), 1, MOUSE_LEFT, 0);
+    Scheduler::ProcessEventsToIdle();
     uno::Reference<frame::XDesktop2> xDesktop = frame::Desktop::create(comphelper::getProcessComponentContext());
     uno::Reference<frame::XFrame> xFrame2 = xDesktop->getActiveFrame();
 
@@ -1233,6 +1249,7 @@ void SwTiledRenderingTest::testUndoRepairDispatch()
     SfxLokHelper::setView(nView1);
     pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 'c', 0);
     pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 'c', 0);
+    Scheduler::ProcessEventsToIdle();
 
     // Assert that by default the second view can't undo the action.
     SfxLokHelper::setView(nView2);
@@ -1273,6 +1290,7 @@ void SwTiledRenderingTest::testShapeTextUndoShells()
     pWrtShell->GetView().BeginTextEdit(pObject, pView->GetSdrPageView(), pWrtShell->GetWin());
     pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 'x', 0);
     pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 'x', 0);
+    Scheduler::ProcessEventsToIdle();
 
     // Make sure that the undo item remembers who created it.
     SwDoc* pDoc = pXTextDocument->GetDocShell()->GetDoc();
@@ -1305,6 +1323,7 @@ void SwTiledRenderingTest::testShapeTextUndoGroupShells()
     pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 'x', 0);
     pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, awt::Key::BACKSPACE);
     pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 0, awt::Key::BACKSPACE);
+    Scheduler::ProcessEventsToIdle();
 
     // Make sure that the undo item remembers who created it.
     SwDoc* pDoc = pXTextDocument->GetDocShell()->GetDoc();
@@ -1317,6 +1336,7 @@ void SwTiledRenderingTest::testShapeTextUndoGroupShells()
     EditView& rEditView = pView->GetTextEditOutlinerView()->GetEditView();
     pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 'x', 0);
     pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 'x', 0);
+    Scheduler::ProcessEventsToIdle();
     // 0th para, 0th char -> 0th para, 1st char.
     ESelection aWordSelection(0, 0, 0, 1);
     rEditView.SetSelection(aWordSelection);
@@ -1591,22 +1611,23 @@ void SwTiledRenderingTest::testCommentEndTextEdit()
     SfxViewShell::Current()->registerLibreOfficeKitViewCallback(&ViewCallback::callback, &aView1);
     pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 'x', 0);
     pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 'x', 0);
+    Scheduler::ProcessEventsToIdle();
     tools::Rectangle aBodyCursor = aView1.m_aOwnCursor;
 
     // Create a comment and type a character there as well.
     const int nCtrlAltC = KEY_MOD1 + KEY_MOD2 + 512 + 'c' - 'a';
     pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 'c', nCtrlAltC);
     pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 'c', nCtrlAltC);
-    Scheduler::ProcessEventsToIdle();
     pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 'x', 0);
     pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 'x', 0);
-
+    Scheduler::ProcessEventsToIdle();
     // End comment text edit by clicking in the body text area, and assert that
     // no unexpected cursor callbacks are emitted at origin (top left corner of
     // the document).
     aView1.m_bOwnCursorAtOrigin = false;
     pXTextDocument->postMouseEvent(LOK_MOUSEEVENT_MOUSEBUTTONDOWN, aBodyCursor.getX(), aBodyCursor.getY(), 1, MOUSE_LEFT, 0);
     pXTextDocument->postMouseEvent(LOK_MOUSEEVENT_MOUSEBUTTONUP, aBodyCursor.getX(), aBodyCursor.getY(), 1, MOUSE_LEFT, 0);
+    Scheduler::ProcessEventsToIdle();
     // This failed, the cursor was at 0, 0 at some point during end text edit
     // of the comment.
     CPPUNIT_ASSERT(!aView1.m_bOwnCursorAtOrigin);
@@ -1693,11 +1714,13 @@ void SwTiledRenderingTest::testUndoRepairResult()
     SfxLokHelper::setView(nView2);
     pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 'b', 0);
     pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 'b', 0);
+    Scheduler::ProcessEventsToIdle();
 
     // Insert a character in the first view.
     SfxLokHelper::setView(nView1);
     pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 'a', 0);
     pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 'a', 0);
+    Scheduler::ProcessEventsToIdle();
 
     // Assert that by default the second view can't undo the action.
     SfxLokHelper::setView(nView2);
@@ -1726,11 +1749,14 @@ void SwTiledRenderingTest::testRedoRepairResult()
     SfxLokHelper::setView(nView2);
     pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 'b', 0);
     pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 'b', 0);
+    Scheduler::ProcessEventsToIdle();
 
     // Insert a character in the first view.
     SfxLokHelper::setView(nView1);
     pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 'a', 0);
     pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 'a', 0);
+    Scheduler::ProcessEventsToIdle();
+
     comphelper::dispatchCommand(".uno:Undo", {}, xListener);
     CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt32>(0), pResult2->m_nDocRepair);
 
diff --git a/sw/source/uibase/inc/edtwin.hxx b/sw/source/uibase/inc/edtwin.hxx
index 2956783d1a7c..71e3f9a7b34d 100644
--- a/sw/source/uibase/inc/edtwin.hxx
+++ b/sw/source/uibase/inc/edtwin.hxx
@@ -284,11 +284,11 @@ public:
     /// @see OutputDevice::LogicInvalidate().
     void LogicInvalidate(const tools::Rectangle* pRectangle) override;
     /// Same as MouseButtonDown(), but coordinates are in logic unit.
-    void LogicMouseButtonDown(const MouseEvent& rMouseEvent);
+    virtual void LogicMouseButtonDown(const MouseEvent& rMouseEvent) override;
     /// Same as MouseButtonUp(), but coordinates are in logic unit.
-    void LogicMouseButtonUp(const MouseEvent& rMouseEvent);
+    virtual void LogicMouseButtonUp(const MouseEvent& rMouseEvent) override;
     /// Same as MouseMove(), but coordinates are in logic unit.
-    void LogicMouseMove(const MouseEvent& rMouseEvent);
+    virtual void LogicMouseMove(const MouseEvent& rMouseEvent) override;
     /// Allows adjusting the point or mark of the selection to a document coordinate.
     void SetCursorTwipPosition(const Point& rPosition, bool bPoint, bool bClearMark);
     /// Allows starting or ending a graphic move or resize action.
diff --git a/sw/source/uibase/uno/unotxdoc.cxx b/sw/source/uibase/uno/unotxdoc.cxx
index 39c9ad4a4ad7..ef3ed6b4d431 100644
--- a/sw/source/uibase/uno/unotxdoc.cxx
+++ b/sw/source/uibase/uno/unotxdoc.cxx
@@ -3489,19 +3489,22 @@ void SwXTextDocument::postKeyEvent(int nType, int nCharCode, int nKeyCode)
     if (!pWindow)
         return;
 
-    KeyEvent aEvent(nCharCode, nKeyCode, 0);
+    LOKAsyncEventData* pLOKEv = new LOKAsyncEventData;
+    pLOKEv->mpWindow = pWindow;
     switch (nType)
     {
     case LOK_KEYEVENT_KEYINPUT:
-        pWindow->KeyInput(aEvent);
+        pLOKEv->mnEvent = VclEventId::WindowKeyInput;
         break;
     case LOK_KEYEVENT_KEYUP:
-        pWindow->KeyUp(aEvent);
+        pLOKEv->mnEvent = VclEventId::WindowKeyUp;
         break;
     default:
         assert(false);
-        break;
     }
+
+    pLOKEv->maKeyEvent = KeyEvent(nCharCode, nKeyCode, 0);
+    Application::PostUserEvent(Link<void*, void>(pLOKEv, ITiledRenderable::LOKPostAsyncEvent));
 }
 
 void SwXTextDocument::postMouseEvent(int nType, int nX, int nY, int nCount, int nButtons, int nModifier)
@@ -3529,30 +3532,29 @@ void SwXTextDocument::postMouseEvent(int nType, int nX, int nY, int nCount, int
     }
 
     SwEditWin& rEditWin = pDocShell->GetView()->GetEditWin();
-    Point aPos(nX , nY);
-    MouseEvent aEvent(aPos, nCount, MouseEventModifiers::SIMPLECLICK, nButtons, nModifier);
 
+
+    LOKAsyncEventData* pLOKEv = new LOKAsyncEventData;
+    pLOKEv->mpWindow = &rEditWin;
     switch (nType)
     {
     case LOK_MOUSEEVENT_MOUSEBUTTONDOWN:
-        rEditWin.LogicMouseButtonDown(aEvent);
-
-        if (nButtons & MOUSE_RIGHT)
-        {
-            const CommandEvent aCEvt(aPos, CommandEventId::ContextMenu, true, nullptr);
-            rEditWin.Command(aCEvt);
-        }
+        pLOKEv->mnEvent = VclEventId::WindowMouseButtonDown;
         break;
     case LOK_MOUSEEVENT_MOUSEBUTTONUP:
-        rEditWin.LogicMouseButtonUp(aEvent);
+        pLOKEv->mnEvent = VclEventId::WindowMouseButtonUp;
         break;
     case LOK_MOUSEEVENT_MOUSEMOVE:
-        rEditWin.LogicMouseMove(aEvent);
+        pLOKEv->mnEvent = VclEventId::WindowMouseMove;
         break;
     default:
         assert(false);
-        break;
     }
+
+    pLOKEv->maMouseEvent = MouseEvent(Point(nX, nY), nCount,
+                                      MouseEventModifiers::SIMPLECLICK,
+                                      nButtons, nModifier);
+    Application::PostUserEvent(Link<void*, void>(pLOKEv, ITiledRenderable::LOKPostAsyncEvent));
 }
 
 void SwXTextDocument::setTextSelection(int nType, int nX, int nY)
commit 33acd925613117d98f8e2b1752fbd949860c792e
Author: Pranav Kant <pranavk at collabora.co.uk>
Date:   Fri Feb 23 21:27:50 2018 +0530

    lok sc: This is not needed now
    
    I guess since these events are routed through vcl now.
    
    Change-Id: Ib2a44c82d76a25ac5a3341c060a665c62e3d60a7
    Reviewed-on: https://gerrit.libreoffice.org/50254
    Reviewed-by: Jan Holesovsky <kendy at collabora.com>
    Tested-by: Jan Holesovsky <kendy at collabora.com>

diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx
index b427331fbbd7..46a2ac32eb76 100644
--- a/sc/source/ui/unoobj/docuno.cxx
+++ b/sc/source/ui/unoobj/docuno.cxx
@@ -678,12 +678,6 @@ void ScModelObj::postMouseEvent(int nType, int nX, int nY, int nCount, int nButt
         break;
     case LOK_MOUSEEVENT_MOUSEBUTTONUP:
         Application::PostMouseEvent(VCLEVENT_WINDOW_MOUSEBUTTONUP, pGridWindow, &aEvent);
-
-        // sometimes MouseButtonDown captures mouse and starts tracking, and VCL
-        // will not take care of releasing that with tiled rendering
-        if (pGridWindow->IsTracking())
-            pGridWindow->EndTracking(TrackingEventFlags::DontCallHdl);
-
         break;
     case LOK_MOUSEEVENT_MOUSEMOVE:
         Application::PostMouseEvent(VCLEVENT_WINDOW_MOUSEMOVE, pGridWindow, &aEvent);
commit f48c0d09990e9fa59d1d5f2d1d6e013feedb92d3
Author: Pranav Kant <pranavk at collabora.co.uk>
Date:   Fri Feb 23 21:27:33 2018 +0530

    lok sc: Post mouse events to main thread
    
    Change-Id: I1311938d7c01d0e3bfd239743e6cb2148da56cdf
    Reviewed-on: https://gerrit.libreoffice.org/50253
    Reviewed-by: Jan Holesovsky <kendy at collabora.com>
    Tested-by: Jan Holesovsky <kendy at collabora.com>

diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index d102d91d23f6..143ec46fdc63 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -194,57 +194,6 @@ static const ExtensionMap aDrawExtensionMap[] =
     { nullptr, nullptr }
 };
 
-/*
- * Map directly to css cursor styles to avoid further mapping in the client.
- * Gtk (via gdk_cursor_new_from_name) also supports the same css cursor styles.
- *
- * This was created partially with help of the mappings in gtkdata.cxx.
- * The list is incomplete as some cursor style simply aren't supported
- * by css, it might turn out to be worth mapping some of these missing cursors
- * to available cursors?
- */
-static const std::map <PointerStyle, OString> aPointerMap {
-    { PointerStyle::Arrow, "default" },
-    // PointerStyle::Null ?
-    { PointerStyle::Wait, "wait" },
-    { PointerStyle::Text, "text" },
-    { PointerStyle::Help, "help" },
-    { PointerStyle::Cross, "crosshair" },
-    { PointerStyle::Fill, "fill" },
-    { PointerStyle::Move, "move" },
-    { PointerStyle::NSize, "n-resize" },
-    { PointerStyle::SSize, "s-resize" },
-    { PointerStyle::WSize, "w-resize" },
-    { PointerStyle::ESize, "e-resize" },
-    { PointerStyle::NWSize, "ne-resize" },
-    { PointerStyle::NESize, "ne-resize" },
-    { PointerStyle::SWSize, "sw-resize" },
-    { PointerStyle::SESize, "se-resize" },
-    // WindowNSize through WindowSESize
-    { PointerStyle::HSplit, "col-resize" },
-    { PointerStyle::VSplit, "row-resize" },
-    { PointerStyle::HSizeBar, "col-resize" },
-    { PointerStyle::VSizeBar, "row-resize" },
-    { PointerStyle::Hand, "grab" },
-    { PointerStyle::RefHand, "grabbing" },
-    // Pen, Magnify, Fill, Rotate
-    // HShear, VShear
-    // Mirror, Crook, Crop, MovePoint, MoveBezierWeight
-    // MoveData
-    { PointerStyle::CopyData, "copy" },
-    { PointerStyle::LinkData, "alias" },
-    // MoveDataLink, CopyDataLink
-    //MoveFile, CopyFile, LinkFile
-    // MoveFileLink, CopyFileLink, MoveFiless, CopyFiles
-    { PointerStyle::NotAllowed, "not-allowed" },
-    // DrawLine through DrawCaption
-    // Chart, Detective, PivotCol, PivotRow, PivotField, Chain, ChainNotAllowed
-    // AutoScrollN through AutoScrollNSWE
-    { PointerStyle::TextVertical, "vertical-text" }
-    // Pivot Delete, TabSelectS through TabSelectSW
-    // PaintBrush, HideWhiteSpace, ShowWhiteSpace
-};
-
 static OUString getUString(const char* pString)
 {
     if (pString == nullptr)
@@ -2503,25 +2452,6 @@ static void doc_postMouseEvent(LibreOfficeKitDocument* pThis, int nType, int nX,
     }
 
     pDoc->postMouseEvent(nType, nX, nY, nCount, nButtons, nModifier);
-
-    Pointer aPointer = pDoc->getPointer();
-    // We don't map all possible pointers hence we need a default
-    OString aPointerString = "default";
-    auto aIt = aPointerMap.find(aPointer.GetStyle());
-    if (aIt != aPointerMap.end())
-    {
-        aPointerString = aIt->second;
-    }
-
-    LibLODocument_Impl* pLib = static_cast<LibLODocument_Impl*>(pThis);
-    int nView = SfxLokHelper::getView();
-    if (nView < 0)
-        return;
-
-    if (pLib->mpCallbackFlushHandlers[nView])
-    {
-        pLib->mpCallbackFlushHandlers[nView]->queue(LOK_CALLBACK_MOUSE_POINTER, aPointerString.getStr());
-    }
 }
 
 static void doc_postWindowMouseEvent(LibreOfficeKitDocument* /*pThis*/, unsigned nLOKWindowId, int nType, int nX, int nY, int nCount, int nButtons, int nModifier)
diff --git a/include/vcl/IDialogRenderable.hxx b/include/vcl/IDialogRenderable.hxx
index ef8d42a4a46c..a2c9b8416ccd 100644
--- a/include/vcl/IDialogRenderable.hxx
+++ b/include/vcl/IDialogRenderable.hxx
@@ -34,6 +34,8 @@ public:
     virtual void notifyWindow(vcl::LOKWindowId nLOKWindowId,
                               const OUString& rAction,
                               const std::vector<LOKPayloadItem>& rPayload = std::vector<LOKPayloadItem>()) const = 0;
+
+    virtual void libreOfficeKitViewCallback(int nType, const char* pPayload) const = 0;
 };
 
 } // namespace vcl
diff --git a/include/vcl/ITiledRenderable.hxx b/include/vcl/ITiledRenderable.hxx
index 5a7034d476d0..ab7b4f027a45 100644
--- a/include/vcl/ITiledRenderable.hxx
+++ b/include/vcl/ITiledRenderable.hxx
@@ -15,11 +15,72 @@
 #include <tools/gen.hxx>
 #include <svx/ruler.hxx>
 #include <vcl/pointr.hxx>
+#include <vcl/ptrstyle.hxx>
 #include <vcl/virdev.hxx>
 #include <com/sun/star/datatransfer/clipboard/XClipboardEx.hpp>
 
 namespace vcl
 {
+    /*
+     * Map directly to css cursor styles to avoid further mapping in the client.
+     * Gtk (via gdk_cursor_new_from_name) also supports the same css cursor styles.
+     *
+     * This was created partially with help of the mappings in gtkdata.cxx.
+     * The list is incomplete as some cursor style simply aren't supported
+     * by css, it might turn out to be worth mapping some of these missing cursors
+     * to available cursors?
+     */
+#ifdef _MSC_VER
+#pragma warning(push)
+#pragma warning( disable : 4592)
+#endif
+    static const std::map <PointerStyle, OString> gaLOKPointerMap {
+    { PointerStyle::Arrow, "default" },
+    // PointerStyle::Null ?
+    { PointerStyle::Wait, "wait" },
+    { PointerStyle::Text, "text" },
+    { PointerStyle::Help, "help" },
+    { PointerStyle::Cross, "crosshair" },
+    { PointerStyle::Fill, "fill" },
+    { PointerStyle::Move, "move" },
+    { PointerStyle::NSize, "n-resize" },
+    { PointerStyle::SSize, "s-resize" },
+    { PointerStyle::WSize, "w-resize" },
+    { PointerStyle::ESize, "e-resize" },
+    { PointerStyle::NWSize, "ne-resize" },
+    { PointerStyle::NESize, "ne-resize" },
+    { PointerStyle::SWSize, "sw-resize" },
+    { PointerStyle::SESize, "se-resize" },
+    // WindowNSize through WindowSESize
+    { PointerStyle::HSplit, "col-resize" },
+    { PointerStyle::VSplit, "row-resize" },
+    { PointerStyle::HSizeBar, "col-resize" },
+    { PointerStyle::VSizeBar, "row-resize" },
+    { PointerStyle::Hand, "grab" },
+    { PointerStyle::RefHand, "grabbing" },
+    // Pen, Magnify, Fill, Rotate
+    // HShear, VShear
+    // Mirror, Crook, Crop, MovePoint, MoveBezierWeight
+    // MoveData
+    { PointerStyle::CopyData, "copy" },
+    { PointerStyle::LinkData, "alias" },
+    // MoveDataLink, CopyDataLink
+    //MoveFile, CopyFile, LinkFile
+    // MoveFileLink, CopyFileLink, MoveFiless, CopyFiles
+    { PointerStyle::NotAllowed, "not-allowed" },
+    // DrawLine through DrawCaption
+    // Chart, Detective, PivotCol, PivotRow, PivotField, Chain, ChainNotAllowed
+    // TimeEventMove, TimeEventSize
+    // AutoScrollN through AutoScrollNSWE
+    // Airbrush
+    { PointerStyle::TextVertical, "vertical-text" }
+    // Pivot Delete, TabSelectS through TabSelectSW
+    // PaintBrush, HideWhiteSpace, ShowWhiteSpace
+    };
+#ifdef _MSC_VER
+#pragma warning(pop)
+#endif
+
 
 class VCL_DLLPUBLIC ITiledRenderable
 {
diff --git a/sc/qa/unit/tiledrendering/tiledrendering.cxx b/sc/qa/unit/tiledrendering/tiledrendering.cxx
index 7ac4f6121d89..2eba19977076 100644
--- a/sc/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sc/qa/unit/tiledrendering/tiledrendering.cxx
@@ -316,6 +316,7 @@ void ScTiledRenderingTest::testSortAscendingDescending()
     pModelObj->postMouseEvent(LOK_MOUSEEVENT_MOUSEBUTTONDOWN, 551, 129, 1, MOUSE_LEFT, 0);
     pModelObj->postMouseEvent(LOK_MOUSEEVENT_MOUSEMOVE, 820, 1336, 1, MOUSE_LEFT, 0);
     pModelObj->postMouseEvent(LOK_MOUSEEVENT_MOUSEBUTTONUP, 820, 1359, 1, MOUSE_LEFT, 0);
+    Scheduler::ProcessEventsToIdle();
 
     // sort ascending
     uno::Sequence<beans::PropertyValue> aArgs;
@@ -865,6 +866,7 @@ void ScTiledRenderingTest::testGraphicInvalidate()
     aView.m_bGraphicSelection = false;
     pModelObj->postMouseEvent(LOK_MOUSEEVENT_MOUSEBUTTONDOWN, /*x=*/ 1,/*y=*/ 1,/*count=*/ 1, /*buttons=*/ 1, /*modifier=*/0);
     pModelObj->postMouseEvent(LOK_MOUSEEVENT_MOUSEBUTTONUP, /*x=*/ 1, /*y=*/ 1, /*count=*/ 1, /*buttons=*/ 1, /*modifier=*/0);
+    Scheduler::ProcessEventsToIdle();
     CPPUNIT_ASSERT(aView.m_bGraphicSelection);
 
     // Drag Drop graphic
diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx
index 5fb2b88cad65..b427331fbbd7 100644
--- a/sc/source/ui/unoobj/docuno.cxx
+++ b/sc/source/ui/unoobj/docuno.cxx
@@ -667,7 +667,7 @@ void ScModelObj::postMouseEvent(int nType, int nX, int nY, int nCount, int nButt
     switch (nType)
     {
     case LOK_MOUSEEVENT_MOUSEBUTTONDOWN:
-        pGridWindow->MouseButtonDown(aEvent);
+        Application::PostMouseEvent(VCLEVENT_WINDOW_MOUSEBUTTONDOWN, pGridWindow, &aEvent);
 
         // Invoke the context menu
         if (nButtons & MOUSE_RIGHT)
@@ -677,7 +677,7 @@ void ScModelObj::postMouseEvent(int nType, int nX, int nY, int nCount, int nButt
         }
         break;
     case LOK_MOUSEEVENT_MOUSEBUTTONUP:
-        pGridWindow->MouseButtonUp(aEvent);
+        Application::PostMouseEvent(VCLEVENT_WINDOW_MOUSEBUTTONUP, pGridWindow, &aEvent);
 
         // sometimes MouseButtonDown captures mouse and starts tracking, and VCL
         // will not take care of releasing that with tiled rendering
@@ -686,7 +686,7 @@ void ScModelObj::postMouseEvent(int nType, int nX, int nY, int nCount, int nButt
 
         break;
     case LOK_MOUSEEVENT_MOUSEMOVE:
-        pGridWindow->MouseMove(aEvent);
+        Application::PostMouseEvent(VCLEVENT_WINDOW_MOUSEMOVE, pGridWindow, &aEvent);
         break;
     default:
         assert(false);
diff --git a/vcl/source/window/mouse.cxx b/vcl/source/window/mouse.cxx
index ccf463a49c36..f073c9739a65 100644
--- a/vcl/source/window/mouse.cxx
+++ b/vcl/source/window/mouse.cxx
@@ -22,6 +22,9 @@
 
 #include <tools/time.hxx>
 
+#include <LibreOfficeKit/LibreOfficeKitEnums.h>
+
+#include <vcl/ITiledRenderable.hxx>
 #include <vcl/svapp.hxx>
 #include <vcl/salgtype.hxx>
 #include <vcl/window.hxx>
@@ -481,6 +484,20 @@ void Window::SetPointer( const Pointer& rPointer )
     // possibly immediately move pointer
     if ( !mpWindowImpl->mpFrameData->mbInMouseMove && ImplTestMousePointerSet() )
         mpWindowImpl->mpFrame->SetPointer( ImplGetMousePointer() );
+
+    if (VclPtr<vcl::Window> pWin = GetParentWithLOKNotifier())
+    {
+        Pointer aPointer = GetPointer();
+        // We don't map all possible pointers hence we need a default
+        OString aPointerString = "default";
+        auto aIt = vcl::gaLOKPointerMap.find(aPointer.GetStyle());
+        if (aIt != vcl::gaLOKPointerMap.end())
+        {
+            aPointerString = aIt->second;
+        }
+
+        pWin->GetLOKNotifier()->libreOfficeKitViewCallback(LOK_CALLBACK_MOUSE_POINTER, aPointerString.getStr());
+    }
 }
 
 void Window::EnableChildPointerOverwrite( bool bOverwrite )
commit fa80f03899a4c28b6abf0b4fa65e8e5c5e312b91
Author: Pranav Kant <pranavk at collabora.co.uk>
Date:   Fri Feb 23 02:58:59 2018 +0530

    lokdialog sc: post key events to the main thread
    
    This also fixes the problem when some dialog is executed inside the key
    handler.
    
    Change-Id: I831ed4b886c1a5eac13dffd8e881a07045458e44
    Reviewed-on: https://gerrit.libreoffice.org/50244
    Reviewed-by: Jan Holesovsky <kendy at collabora.com>
    Tested-by: Jan Holesovsky <kendy at collabora.com>

diff --git a/sc/qa/unit/tiledrendering/tiledrendering.cxx b/sc/qa/unit/tiledrendering/tiledrendering.cxx
index e70d4f17b3f7..7ac4f6121d89 100644
--- a/sc/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sc/qa/unit/tiledrendering/tiledrendering.cxx
@@ -1599,6 +1599,7 @@ void ScTiledRenderingTest::testIMESupport()
     // commit the string to the cell
     pModelObj->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, awt::Key::RETURN);
     pModelObj->postKeyEvent(LOK_KEYEVENT_KEYUP, 0, awt::Key::RETURN);
+    Scheduler::ProcessEventsToIdle();
 
     CPPUNIT_ASSERT_EQUAL(aInputs[aInputs.size() - 1], pDoc->GetString(ScAddress(0, 0, 0)));
 
diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx
index 9ba07778b89b..5fb2b88cad65 100644
--- a/sc/source/ui/unoobj/docuno.cxx
+++ b/sc/source/ui/unoobj/docuno.cxx
@@ -609,14 +609,16 @@ void ScModelObj::postKeyEvent(int nType, int nCharCode, int nKeyCode)
     if (!pWindow)
         return;
 
+    if (!pWindow->HasFocus())
+        pWindow->GrabFocus();
     KeyEvent aEvent(nCharCode, nKeyCode, 0);
     switch (nType)
     {
     case LOK_KEYEVENT_KEYINPUT:
-        pWindow->KeyInput(aEvent);
+        Application::PostKeyEvent(VCLEVENT_WINDOW_KEYINPUT, pWindow, &aEvent);
         break;
     case LOK_KEYEVENT_KEYUP:
-        pWindow->KeyUp(aEvent);
+        Application::PostKeyEvent(VCLEVENT_WINDOW_KEYUP, pWindow, &aEvent);
         break;
     default:
         assert(false);
commit 0a1a3a64823c0509c4b5f1edc6ee51ca991d3501
Author: Pranav Kant <pranavk at collabora.co.uk>
Date:   Wed Feb 21 22:09:09 2018 +0530

    postExtTextInputEvent() -> postWindowExtTextInputEvent()
    
    Let's avoid the confusion and name all these new APIs that can post both
    to document and window to have 'Window' in their name. The ones without
    window are the old APIs. In future, we can have
    postWindow{Key,Mouse}Event() to post to both document and window and
    deprecate the existing post{Key,Mouse}Event()s.
    
    Change-Id: I1f55386e7790e9c5b5d023b8831f3cd1e6faa2bb

diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index fdc02e3128d3..d102d91d23f6 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -542,10 +542,10 @@ static void doc_postKeyEvent(LibreOfficeKitDocument* pThis,
                              int nType,
                              int nCharCode,
                              int nKeyCode);
-static void doc_postExtTextInputEvent(LibreOfficeKitDocument* pThis,
-                                      unsigned nWindowId,
-                                      int nType,
-                                      const char* pText);
+static void doc_postWindowExtTextInputEvent(LibreOfficeKitDocument* pThis,
+                                            unsigned nWindowId,
+                                            int nType,
+                                            const char* pText);
 static void doc_postWindowKeyEvent(LibreOfficeKitDocument* pThis,
                                    unsigned nLOKWindowId,
                                    int nType,
@@ -639,7 +639,7 @@ LibLODocument_Impl::LibLODocument_Impl(const uno::Reference <css::lang::XCompone
         m_pDocumentClass->initializeForRendering = doc_initializeForRendering;
         m_pDocumentClass->registerCallback = doc_registerCallback;
         m_pDocumentClass->postKeyEvent = doc_postKeyEvent;
-        m_pDocumentClass->postExtTextInputEvent = doc_postExtTextInputEvent;
+        m_pDocumentClass->postWindowExtTextInputEvent = doc_postWindowExtTextInputEvent;
         m_pDocumentClass->postWindowKeyEvent = doc_postWindowKeyEvent;
         m_pDocumentClass->postMouseEvent = doc_postMouseEvent;
         m_pDocumentClass->postWindowMouseEvent = doc_postWindowMouseEvent;
@@ -2300,7 +2300,7 @@ static void doc_postKeyEvent(LibreOfficeKitDocument* pThis, int nType, int nChar
     pDoc->postKeyEvent(nType, nCharCode, nKeyCode);
 }
 
-static void doc_postExtTextInputEvent(LibreOfficeKitDocument* pThis, unsigned nWindowId, int nType, const char* pText)
+static void doc_postWindowExtTextInputEvent(LibreOfficeKitDocument* pThis, unsigned nWindowId, int nType, const char* pText)
 {
     SolarMutexGuard aGuard;
     VclPtr<vcl::Window> pWindow;
diff --git a/include/LibreOfficeKit/LibreOfficeKit.h b/include/LibreOfficeKit/LibreOfficeKit.h
index 7492fcc7a561..d465d541b0e0 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.h
+++ b/include/LibreOfficeKit/LibreOfficeKit.h
@@ -300,11 +300,11 @@ struct _LibreOfficeKitDocumentClass
     /// @see lok::Document::setViewLanguage().
     void (*setViewLanguage) (LibreOfficeKitDocument* pThis, int nId, const char* language);
 
-    /// @see lok::Document::postExtTextInputEvent
-    void (*postExtTextInputEvent) (LibreOfficeKitDocument* pThis,
-                                   unsigned nWindowId,
-                                   int nType,
-                                   const char* pText);
+    /// @see lok::Document::postWindowExtTextInputEvent
+    void (*postWindowExtTextInputEvent) (LibreOfficeKitDocument* pThis,
+                                         unsigned nWindowId,
+                                         int nType,
+                                         const char* pText);
 
 #endif // defined LOK_USE_UNSTABLE_API || defined LIBO_INTERNAL_ONLY
 };
diff --git a/include/LibreOfficeKit/LibreOfficeKit.hxx b/include/LibreOfficeKit/LibreOfficeKit.hxx
index 55e29ebda1c8..232eada69821 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.hxx
+++ b/include/LibreOfficeKit/LibreOfficeKit.hxx
@@ -538,16 +538,16 @@ public:
     }
 
     /**
-     * Post the text input from external input window, like IME
+     * Post the text input from external input window, like IME, to given windowId
      *
      * @param nWindowId Specify the window id to post the input event to. If
      * nWindow is 0, the event is posted into the document
      * @param nType see LibreOfficeKitExtTextInputType
      * @param pText Text for LOK_EXT_TEXTINPUT
      */
-    void postExtTextInputEvent(unsigned nWindowId, int nType, const char* pText)
+    void postWindowExtTextInputEvent(unsigned nWindowId, int nType, const char* pText)
     {
-        mpDoc->pClass->postExtTextInputEvent(mpDoc, nWindowId, nType, pText);
+        mpDoc->pClass->postWindowExtTextInputEvent(mpDoc, nWindowId, nType, pText);
     }
 
 #endif // defined LOK_USE_UNSTABLE_API || defined LIBO_INTERNAL_ONLY


More information about the Libreoffice-commits mailing list