diff options
author | Pranav Kant <pranavk@collabora.co.uk> | 2018-02-24 12:19:57 +0530 |
---|---|---|
committer | Aron Budea <aron.budea@collabora.com> | 2018-02-24 19:22:54 +0100 |
commit | 743aee0ad16449ba0ecf506e0a650b45b89628bc (patch) | |
tree | 30cf39241cb97324ad5001f0bf5d6c334a193427 /sc | |
parent | 86ea687d3f19c04192ee2b7a82736e110c7be334 (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 'sc')
-rw-r--r-- | sc/source/ui/inc/gridwin.hxx | 7 | ||||
-rw-r--r-- | sc/source/ui/unoobj/docuno.cxx | 43 | ||||
-rw-r--r-- | sc/source/ui/view/gridwin.cxx | 15 |
3 files changed, 42 insertions, 23 deletions
diff --git a/sc/source/ui/inc/gridwin.hxx b/sc/source/ui/inc/gridwin.hxx index 607f1fbd1697..9830834a4bbd 100644 --- a/sc/source/ui/inc/gridwin.hxx +++ b/sc/source/ui/inc/gridwin.hxx @@ -438,6 +438,13 @@ public: long nTileHeight); void updateLibreOfficeKitCellCursor(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 7a1af69926f3..8638ac08406f 100644 --- a/sc/source/ui/unoobj/docuno.cxx +++ b/sc/source/ui/unoobj/docuno.cxx @@ -611,6 +611,7 @@ Size ScModelObj::getDocumentSize() return aSize; } + void ScModelObj::postKeyEvent(int nType, int nCharCode, int nKeyCode) { SolarMutexGuard aGuard; @@ -619,21 +620,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 = VCLEVENT_WINDOW_KEYINPUT; break; case LOK_KEYEVENT_KEYUP: - Application::PostKeyEvent(VCLEVENT_WINDOW_KEYUP, pWindow, &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 ScModelObj::postMouseEvent(int nType, int nX, int nY, int nCount, int nButtons, int nModifier) @@ -668,34 +670,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 = VCLEVENT_WINDOW_MOUSEBUTTONDOWN; break; case LOK_MOUSEEVENT_MOUSEBUTTONUP: - Application::PostMouseEvent(VCLEVENT_WINDOW_MOUSEBUTTONUP, pGridWindow, &aEvent); + pLOKEv->mnEvent = VCLEVENT_WINDOW_MOUSEBUTTONUP; break; case LOK_MOUSEEVENT_MOUSEMOVE: - Application::PostMouseEvent(VCLEVENT_WINDOW_MOUSEMOVE, pGridWindow, &aEvent); + pLOKEv->mnEvent = VCLEVENT_WINDOW_MOUSEMOVE; 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 e26a1c5f2d1f..0a4c69ceded8 100644 --- a/sc/source/ui/view/gridwin.cxx +++ b/sc/source/ui/view/gridwin.cxx @@ -1521,6 +1521,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; |