summaryrefslogtreecommitdiff
path: root/sd
diff options
context:
space:
mode:
authorPranav Kant <pranavk@collabora.co.uk>2018-02-24 12:19:57 +0530
committerAron Budea <aron.budea@collabora.com>2018-02-24 19:22:54 +0100
commit743aee0ad16449ba0ecf506e0a650b45b89628bc (patch)
tree30cf39241cb97324ad5001f0bf5d6c334a193427 /sd
parent86ea687d3f19c04192ee2b7a82736e110c7be334 (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>
Diffstat (limited to 'sd')
-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.cxx39
-rw-r--r--sd/source/ui/view/sdwindow.cxx39
-rw-r--r--sd/source/ui/view/viewshel.cxx39
6 files changed, 69 insertions, 67 deletions
diff --git a/sd/qa/unit/tiledrendering/tiledrendering.cxx b/sd/qa/unit/tiledrendering/tiledrendering.cxx
index 8b7a7ee89293..f2372fc711a7 100644
--- a/sd/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sd/qa/unit/tiledrendering/tiledrendering.cxx
@@ -343,6 +343,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();
@@ -357,6 +358,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();
@@ -366,6 +368,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()
@@ -396,6 +399,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);
@@ -1338,6 +1342,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();
@@ -1431,6 +1436,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();
@@ -1546,7 +1552,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 fa1a6962cece..075cb634389c 100644
--- a/sd/source/ui/inc/ViewShell.hxx
+++ b/sd/source/ui/inc/ViewShell.hxx
@@ -419,12 +419,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 5c3e08a9a4a6..a91a71ea70d3 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 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 d9ea81e4982e..597787533010 100644
--- a/sd/source/ui/unoidl/unomodel.cxx
+++ b/sd/source/ui/unoidl/unomodel.cxx
@@ -2506,20 +2506,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 = VCLEVENT_WINDOW_KEYINPUT;
break;
case LOK_KEYEVENT_KEYUP:
- pWindow->KeyUp(aEvent);
+ pLOKEv->mnEvent = VCLEVENT_WINDOW_KEYUP;
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)
@@ -2547,33 +2549,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 = VCLEVENT_WINDOW_MOUSEBUTTONDOWN;
break;
case LOK_MOUSEEVENT_MOUSEBUTTONUP:
- pViewShell->LogicMouseButtonUp(aEvent);
+ pLOKEv->mnEvent = VCLEVENT_WINDOW_MOUSEBUTTONUP;
break;
case LOK_MOUSEEVENT_MOUSEMOVE:
- pViewShell->LogicMouseMove(aEvent);
+ pLOKEv->mnEvent = VCLEVENT_WINDOW_MOUSEMOVE;
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 e1b4fa5267b3..7472695ee728 100644
--- a/sd/source/ui/view/sdwindow.cxx
+++ b/sd/source/ui/view/sdwindow.cxx
@@ -1016,6 +1016,45 @@ void Window::LogicInvalidate(const 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 2a6fd8b2c4bc..4ffa61f7cdf4 100644
--- a/sd/source/ui/view/viewshel.cxx
+++ b/sd/source/ui/view/viewshel.cxx
@@ -499,45 +499,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())