summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPranav Kant <pranavk@collabora.co.uk>2018-02-24 12:19:57 +0530
committerAndras Timar <andras.timar@collabora.com>2018-03-25 23:02:35 +0200
commitcd71dcc35ef75117bcf3c66a176a5c7bf43e197b (patch)
tree4ce158edd373111a9b959599c3f9d257120ea163
parentaaf3a65db1b18ae7e1c240c5101bd16853eb56de (diff)
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@collabora.com> Tested-by: Aron Budea <aron.budea@collabora.com> (cherry picked from commit 3c3e07b51fb09d09cfef54193f93b07304f4ccda)
-rw-r--r--include/vcl/ITiledRenderable.hxx44
-rw-r--r--include/vcl/window.hxx7
-rw-r--r--sc/source/ui/inc/gridwin.hxx7
-rw-r--r--sc/source/ui/unoobj/docuno.cxx43
-rw-r--r--sc/source/ui/view/gridwin.cxx15
-rw-r--r--sd/qa/unit/tiledrendering/tiledrendering.cxx7
-rw-r--r--sd/source/ui/inc/ViewShell.hxx6
-rw-r--r--sd/source/ui/inc/Window.hxx6
-rw-r--r--sd/source/ui/unoidl/unomodel.cxx38
-rw-r--r--sd/source/ui/view/sdwindow.cxx39
-rw-r--r--sd/source/ui/view/viewshel.cxx39
-rw-r--r--sw/qa/extras/tiledrendering/tiledrendering.cxx44
-rw-r--r--sw/source/uibase/inc/edtwin.hxx6
-rw-r--r--sw/source/uibase/uno/unotxdoc.cxx34
14 files changed, 218 insertions, 117 deletions
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 9e728e4a10ab..6dc4ee3d8613 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 0646ef51c144..583665879932 100644
--- a/sc/source/ui/unoobj/docuno.cxx
+++ b/sc/source/ui/unoobj/docuno.cxx
@@ -602,6 +602,7 @@ Size ScModelObj::getDocumentSize()
return aSize;
}
+
void ScModelObj::postKeyEvent(int nType, int nCharCode, int nKeyCode)
{
SolarMutexGuard aGuard;
@@ -610,21 +611,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)
@@ -659,34 +661,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 03a330f0e27b..386e7388cb89 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 5229db8759a1..8676a09bb989 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 d94376e1764e..ec5ff6514bd9 100644
--- a/sd/source/ui/inc/ViewShell.hxx
+++ b/sd/source/ui/inc/ViewShell.hxx
@@ -409,12 +409,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 0d47a487035e..e60e35a89557 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 339fe46449d9..ae800a94f0ff 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 c46be7b78302..b3009d6f1b22 100644
--- a/sd/source/ui/view/sdwindow.cxx
+++ b/sd/source/ui/view/sdwindow.cxx
@@ -1015,6 +1015,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 82a6e67db3cc..bc732104f2b1 100644
--- a/sd/source/ui/view/viewshel.cxx
+++ b/sd/source/ui/view/viewshel.cxx
@@ -514,45 +514,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 3111b5ca2dd1..f75ca63e1c77 100644
--- a/sw/qa/extras/tiledrendering/tiledrendering.cxx
+++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx
@@ -313,6 +313,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());
}
@@ -331,6 +332,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);
@@ -935,20 +937,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();
@@ -1078,11 +1084,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();
@@ -1110,6 +1119,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());
@@ -1141,6 +1153,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());
@@ -1168,6 +1181,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();
@@ -1197,6 +1211,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);
@@ -1206,6 +1221,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();
@@ -1232,6 +1248,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);
@@ -1272,6 +1289,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();
@@ -1304,6 +1322,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();
@@ -1316,6 +1335,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);
@@ -1590,22 +1610,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);
@@ -1692,11 +1713,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);
@@ -1725,11 +1748,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 c8a9b7ec7092..a0b549b11329 100644
--- a/sw/source/uibase/uno/unotxdoc.cxx
+++ b/sw/source/uibase/uno/unotxdoc.cxx
@@ -3487,19 +3487,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)
@@ -3527,30 +3530,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)