[Libreoffice-commits] core.git: Branch 'feature/tiled-editing' - desktop/source include/vcl sc/inc sc/source sd/source sw/inc sw/source
Miklos Vajna
vmiklos at collabora.co.uk
Fri Apr 3 03:31:26 PDT 2015
desktop/source/lib/init.cxx | 21 +++++++--------------
include/vcl/ITiledRenderable.hxx | 7 +++++++
sc/inc/docuno.hxx | 3 +++
sc/source/ui/inc/gridwin.hxx | 2 +-
sc/source/ui/unoobj/docuno.cxx | 28 ++++++++++++++++++++++++++++
sd/source/ui/inc/Window.hxx | 2 +-
sd/source/ui/inc/unomodel.hxx | 2 ++
sd/source/ui/unoidl/unomodel.cxx | 28 ++++++++++++++++++++++++++++
sw/inc/unotxdoc.hxx | 2 ++
sw/source/uibase/inc/edtwin.hxx | 2 +-
sw/source/uibase/uno/unotxdoc.cxx | 21 +++++++++++++++++++++
11 files changed, 101 insertions(+), 17 deletions(-)
New commits:
commit 4ab968500f911f37d2a620c5576e21546cf9b885
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Fri Apr 3 12:29:28 2015 +0200
LOK: reimplement lok::Document::postKeyEvent()
Instead of posting an event to the main loop of the soffice thread, do
what every other methods do: take the solar mutex and execute the task
on the thread. This fixes random lost/delayed key events on Android.
Change-Id: Ibe819282b5f3bb64e44d4b6f0a92611fe651bb39
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index bdab485..7d502af 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -687,23 +687,16 @@ static void doc_registerCallback(LibreOfficeKitDocument* pThis,
pDoc->registerCallback(pCallback, pData);
}
-static void doc_postKeyEvent(LibreOfficeKitDocument* /*pThis*/, int nType, int nCharCode, int nKeyCode)
+static void doc_postKeyEvent(LibreOfficeKitDocument* pThis, int nType, int nCharCode, int nKeyCode)
{
-#if defined(UNX) && !defined(MACOSX) && !defined(ENABLE_HEADLESS)
- if (SalFrame *pFocus = GetSvpFocusFrameForLibreOfficeKit())
+ ITiledRenderable* pDoc = getTiledRenderable(pThis);
+ if (!pDoc)
{
- KeyEvent aEvent(nCharCode, nKeyCode, 0);
- switch (nType)
- {
- case LOK_KEYEVENT_KEYINPUT:
- Application::PostKeyEvent(VCLEVENT_WINDOW_KEYINPUT, GetSalFrameWindowForLibreOfficeKit(pFocus), &aEvent);
- break;
- case LOK_KEYEVENT_KEYUP:
- Application::PostKeyEvent(VCLEVENT_WINDOW_KEYUP, GetSalFrameWindowForLibreOfficeKit(pFocus), &aEvent);
- break;
- }
+ gImpl->maLastExceptionMsg = "Document doesn't support tiled rendering";
+ return;
}
-#endif
+
+ pDoc->postKeyEvent(nType, nCharCode, nKeyCode);
}
static void doc_postUnoCommand(LibreOfficeKitDocument* /*pThis*/, const char* pCommand)
diff --git a/include/vcl/ITiledRenderable.hxx b/include/vcl/ITiledRenderable.hxx
index a10e448..5cac9b6 100644
--- a/include/vcl/ITiledRenderable.hxx
+++ b/include/vcl/ITiledRenderable.hxx
@@ -101,6 +101,13 @@ public:
virtual void registerCallback(LibreOfficeKitCallback pCallback, void* pData) = 0;
/**
+ * Posts a keyboard event on the document.
+ *
+ * @see lok::Document::postKeyEvent().
+ */
+ virtual void postKeyEvent(int nType, int nCharCode, int nKeyCode) = 0;
+
+ /**
* Posts a mouse event on the document.
*
* @see lok::Document::postMouseEvent().
diff --git a/sc/inc/docuno.hxx b/sc/inc/docuno.hxx
index 5642569..0e58087 100644
--- a/sc/inc/docuno.hxx
+++ b/sc/inc/docuno.hxx
@@ -394,6 +394,9 @@ public:
/// @see vcl::ITiledRenderable::registerCallback().
virtual void registerCallback(LibreOfficeKitCallback pCallback, void* pData) SAL_OVERRIDE;
+ /// @see vcl::ITiledRenderable::postKeyEvent().
+ virtual void postKeyEvent(int nType, int nCharCode, int nKeyCode) SAL_OVERRIDE;
+
/// @see vcl::ITiledRenderable::postMouseEvent().
virtual void postMouseEvent(int nType, int nX, int nY, int nCount) SAL_OVERRIDE;
diff --git a/sc/source/ui/inc/gridwin.hxx b/sc/source/ui/inc/gridwin.hxx
index 9d8965d..259844e 100644
--- a/sc/source/ui/inc/gridwin.hxx
+++ b/sc/source/ui/inc/gridwin.hxx
@@ -287,7 +287,6 @@ class ScGridWindow : public vcl::Window, public DropTargetHelper, public DragSou
protected:
virtual void PrePaint() SAL_OVERRIDE;
virtual void Paint( const Rectangle& rRect ) SAL_OVERRIDE;
- virtual void KeyInput(const KeyEvent& rKEvt) SAL_OVERRIDE;
virtual void GetFocus() SAL_OVERRIDE;
virtual void LoseFocus() SAL_OVERRIDE;
@@ -304,6 +303,7 @@ public:
ScGridWindow( vcl::Window* pParent, ScViewData* pData, ScSplitPos eWhichPos );
virtual ~ScGridWindow();
+ virtual void KeyInput(const KeyEvent& rKEvt) SAL_OVERRIDE;
// #i70788# flush and get overlay
rtl::Reference<sdr::overlay::OverlayManager> getOverlayManager();
void flushOverlayManager();
diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx
index 16e83e0..3ee089a 100644
--- a/sc/source/ui/unoobj/docuno.cxx
+++ b/sc/source/ui/unoobj/docuno.cxx
@@ -528,6 +528,34 @@ void ScModelObj::registerCallback(LibreOfficeKitCallback pCallback, void* pData)
pDocShell->GetDocument().GetDrawLayer()->registerLibreOfficeKitCallback(pCallback, pData);
}
+void ScModelObj::postKeyEvent(int nType, int nCharCode, int nKeyCode)
+{
+ SolarMutexGuard aGuard;
+
+ // There seems to be no clear way of getting the grid window for this
+ // particular document, hence we need to hope we get the right window.
+ ScViewData* pViewData = ScDocShell::GetViewData();
+ ScGridWindow* pGridWindow = pViewData->GetActiveWin();
+
+ if (!pGridWindow)
+ return;
+
+ KeyEvent aEvent(nCharCode, nKeyCode, 0);
+
+ switch (nType)
+ {
+ case LOK_KEYEVENT_KEYINPUT:
+ pGridWindow->KeyInput(aEvent);
+ break;
+ case LOK_KEYEVENT_KEYUP:
+ pGridWindow->KeyUp(aEvent);
+ break;
+ default:
+ assert(false);
+ break;
+ }
+}
+
void ScModelObj::postMouseEvent(int nType, int nX, int nY, int nCount)
{
SolarMutexGuard aGuard;
diff --git a/sd/source/ui/inc/Window.hxx b/sd/source/ui/inc/Window.hxx
index be2bb1a..dca72fb 100644
--- a/sd/source/ui/inc/Window.hxx
+++ b/sd/source/ui/inc/Window.hxx
@@ -147,6 +147,7 @@ public:
*/
void SetUseDropScroll (bool bUseDropScroll);
void DropScroll (const Point& rMousePos);
+ virtual void KeyInput(const KeyEvent& rKEvt) SAL_OVERRIDE;
protected:
::sd::Window* mpShareWin;
Point maWinPos;
@@ -171,7 +172,6 @@ protected:
virtual void Resize() SAL_OVERRIDE;
virtual void PrePaint() SAL_OVERRIDE;
virtual void Paint(const Rectangle& rRect) SAL_OVERRIDE;
- virtual void KeyInput(const KeyEvent& rKEvt) SAL_OVERRIDE;
virtual void MouseMove(const MouseEvent& rMEvt) SAL_OVERRIDE;
virtual void MouseButtonUp(const MouseEvent& rMEvt) SAL_OVERRIDE;
virtual void MouseButtonDown(const MouseEvent& rMEvt) SAL_OVERRIDE;
diff --git a/sd/source/ui/inc/unomodel.hxx b/sd/source/ui/inc/unomodel.hxx
index bb840f2..b9c17ac 100644
--- a/sd/source/ui/inc/unomodel.hxx
+++ b/sd/source/ui/inc/unomodel.hxx
@@ -245,6 +245,8 @@ public:
virtual void initializeForTiledRendering() SAL_OVERRIDE;
/// @see vcl::ITiledRenderable::registerCallback().
virtual void registerCallback(LibreOfficeKitCallback pCallback, void* pData) SAL_OVERRIDE;
+ /// @see vcl::ITiledRenderable::postKeyEvent().
+ virtual void postKeyEvent(int nType, int nCharCode, int nKeyCode) SAL_OVERRIDE;
/// @see vcl::ITiledRenderable::postMouseEvent().
virtual void postMouseEvent(int nType, int nX, int nY, int nCount) SAL_OVERRIDE;
/// @see vcl::ITiledRenderable::setTextSelection().
diff --git a/sd/source/ui/unoidl/unomodel.cxx b/sd/source/ui/unoidl/unomodel.cxx
index 9c9678b..b85de6a 100644
--- a/sd/source/ui/unoidl/unomodel.cxx
+++ b/sd/source/ui/unoidl/unomodel.cxx
@@ -2378,6 +2378,34 @@ void SdXImpressDocument::registerCallback(LibreOfficeKitCallback pCallback, void
mpDoc->registerLibreOfficeKitCallback(pCallback, pData);
}
+void SdXImpressDocument::postKeyEvent(int nType, int nCharCode, int nKeyCode)
+{
+ SolarMutexGuard aGuard;
+
+ DrawViewShell* pViewShell = GetViewShell();
+ if (!pViewShell)
+ return;
+
+ sd::Window* pWindow = pViewShell->GetActiveWindow();
+ if (!pWindow)
+ return;
+
+ KeyEvent aEvent(nCharCode, nKeyCode, 0);
+
+ switch (nType)
+ {
+ case LOK_KEYEVENT_KEYINPUT:
+ pWindow->KeyInput(aEvent);
+ break;
+ case LOK_KEYEVENT_KEYUP:
+ pWindow->KeyUp(aEvent);
+ break;
+ default:
+ assert(false);
+ break;
+ }
+}
+
void SdXImpressDocument::postMouseEvent(int nType, int nX, int nY, int nCount)
{
SolarMutexGuard aGuard;
diff --git a/sw/inc/unotxdoc.hxx b/sw/inc/unotxdoc.hxx
index 72025628..22375eb 100644
--- a/sw/inc/unotxdoc.hxx
+++ b/sw/inc/unotxdoc.hxx
@@ -409,6 +409,8 @@ public:
virtual void initializeForTiledRendering() SAL_OVERRIDE;
/// @see vcl::ITiledRenderable::registerCallback().
virtual void registerCallback(LibreOfficeKitCallback pCallback, void* pData) SAL_OVERRIDE;
+ /// @see vcl::ITiledRenderable::postKeyEvent().
+ virtual void postKeyEvent(int nType, int nCharCode, int nKeyCode) SAL_OVERRIDE;
/// @see vcl::ITiledRenderable::postMouseEvent().
virtual void postMouseEvent(int nType, int nX, int nY, int nCount) SAL_OVERRIDE;
/// @see vcl::ITiledRenderable::setTextSelection().
diff --git a/sw/source/uibase/inc/edtwin.hxx b/sw/source/uibase/inc/edtwin.hxx
index 5a4cf7a..e8c2e5e 100644
--- a/sw/source/uibase/inc/edtwin.hxx
+++ b/sw/source/uibase/inc/edtwin.hxx
@@ -189,7 +189,6 @@ protected:
virtual void DataChanged( const DataChangedEvent& ) SAL_OVERRIDE;
virtual void PrePaint() SAL_OVERRIDE;
virtual void Paint( const Rectangle& rRect ) SAL_OVERRIDE;
- virtual void KeyInput(const KeyEvent &rKEvt) SAL_OVERRIDE;
virtual void GetFocus() SAL_OVERRIDE;
virtual void LoseFocus() SAL_OVERRIDE;
@@ -218,6 +217,7 @@ protected:
bool IsOverHeaderFooterFly( const Point& rDocPos, FrameControlType& rControl, bool& bOverFly, bool& bPageAnchored ) const;
public:
+ virtual void KeyInput(const KeyEvent &rKEvt) SAL_OVERRIDE;
void UpdatePointer(const Point &, sal_uInt16 nButtons = 0);
bool IsDrawSelMode();
diff --git a/sw/source/uibase/uno/unotxdoc.cxx b/sw/source/uibase/uno/unotxdoc.cxx
index cdf2577..2564cf9 100644
--- a/sw/source/uibase/uno/unotxdoc.cxx
+++ b/sw/source/uibase/uno/unotxdoc.cxx
@@ -3186,6 +3186,27 @@ void SwXTextDocument::registerCallback(LibreOfficeKitCallback pCallback, void* p
pViewShell->registerLibreOfficeKitCallback(pCallback, pData);
}
+void SwXTextDocument::postKeyEvent(int nType, int nCharCode, int nKeyCode)
+{
+ SolarMutexGuard aGuard;
+
+ SwEditWin& rEditWin = pDocShell->GetView()->GetEditWin();
+ KeyEvent aEvent(nCharCode, nKeyCode, 0);
+
+ switch (nType)
+ {
+ case LOK_KEYEVENT_KEYINPUT:
+ rEditWin.KeyInput(aEvent);
+ break;
+ case LOK_KEYEVENT_KEYUP:
+ rEditWin.KeyUp(aEvent);
+ break;
+ default:
+ assert(false);
+ break;
+ }
+}
+
void SwXTextDocument::postMouseEvent(int nType, int nX, int nY, int nCount)
{
SolarMutexGuard aGuard;
More information about the Libreoffice-commits
mailing list