summaryrefslogtreecommitdiff
path: root/desktop
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2019-03-25 18:23:36 +0900
committerTomaž Vajngerl <quikee@gmail.com>2019-03-26 01:31:46 +0100
commit4a68361d578fe3bf313f80d8e186079bd34b2300 (patch)
tree980cec2b2daac79f3f807774c23ba3a00a2c6bf5 /desktop
parent2ccc0a9e24e3f02bfce39af922b5a4972baa2968 (diff)
tdf#124146 support posting of gesture event for LOKit
Change-Id: I51845f2e41dbcbe1ae6cb0a18cf9f42d5549968b Reviewed-on: https://gerrit.libreoffice.org/69657 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'desktop')
-rw-r--r--desktop/qa/desktop_lib/test_desktop_lib.cxx3
-rw-r--r--desktop/source/lib/init.cxx45
2 files changed, 47 insertions, 1 deletions
diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index 445901108ed4..413b697be70a 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -2696,9 +2696,10 @@ void DesktopLOKTest::testABI()
CPPUNIT_ASSERT_EQUAL(documentClassOffset(44), offsetof(struct _LibreOfficeKitDocumentClass, addCertificate));
CPPUNIT_ASSERT_EQUAL(documentClassOffset(45), offsetof(struct _LibreOfficeKitDocumentClass, getSignatureState));
CPPUNIT_ASSERT_EQUAL(documentClassOffset(46), offsetof(struct _LibreOfficeKitDocumentClass, renderShapeSelection));
+ CPPUNIT_ASSERT_EQUAL(documentClassOffset(47), offsetof(struct _LibreOfficeKitDocumentClass, postWindowGestureEvent));
// Extending is fine, update this, and add new assert for the offsetof the
// new method
- CPPUNIT_ASSERT_EQUAL(documentClassOffset(47), sizeof(struct _LibreOfficeKitDocumentClass));
+ CPPUNIT_ASSERT_EQUAL(documentClassOffset(48), sizeof(struct _LibreOfficeKitDocumentClass));
}
CPPUNIT_TEST_SUITE_REGISTRATION(DesktopLOKTest);
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index a83af85d4441..dfbbdd8386dc 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -107,6 +107,7 @@
#include <svx/svxids.hrc>
#include <svx/ucsubset.hxx>
#include <vcl/vclevent.hxx>
+#include <vcl/GestureEvent.hxx>
#include <vcl/svapp.hxx>
#include <unotools/resmgr.hxx>
#include <tools/fract.hxx>
@@ -744,6 +745,12 @@ static void doc_postWindowMouseEvent (LibreOfficeKitDocument* pThis,
int nCount,
int nButtons,
int nModifier);
+static void doc_postWindowGestureEvent(LibreOfficeKitDocument* pThis,
+ unsigned nLOKWindowId,
+ const char* pType,
+ int nX,
+ int nY,
+ int nOffset);
static void doc_postUnoCommand(LibreOfficeKitDocument* pThis,
const char* pCommand,
const char* pArguments,
@@ -879,6 +886,7 @@ LibLODocument_Impl::LibLODocument_Impl(const uno::Reference <css::lang::XCompone
m_pDocumentClass->getSignatureState = doc_getSignatureState;
m_pDocumentClass->renderShapeSelection = doc_renderShapeSelection;
+ m_pDocumentClass->postWindowGestureEvent = doc_postWindowGestureEvent;
gDocumentClass = m_pDocumentClass;
}
@@ -3020,6 +3028,43 @@ static void doc_postWindowMouseEvent(LibreOfficeKitDocument* /*pThis*/, unsigned
}
}
+static void doc_postWindowGestureEvent(LibreOfficeKitDocument* /*pThis*/, unsigned nLOKWindowId, const char* pType, int nX, int nY, int nOffset)
+{
+ SolarMutexGuard aGuard;
+ if (gImpl)
+ gImpl->maLastExceptionMsg.clear();
+
+ VclPtr<Window> pWindow = vcl::Window::FindLOKWindow(nLOKWindowId);
+ if (!pWindow)
+ {
+ gImpl->maLastExceptionMsg = "Document doesn't support dialog rendering, or window not found.";
+ return;
+ }
+
+ OString aType(pType);
+ GestureEventType eEventType = GestureEventType::PanningUpdate;
+
+ if (aType == "panBegin")
+ eEventType = GestureEventType::PanningBegin;
+ else if (aType == "panEnd")
+ eEventType = GestureEventType::PanningEnd;
+
+ GestureEvent aEvent {
+ sal_Int32(nX),
+ sal_Int32(nY),
+ eEventType,
+ sal_Int32(nOffset),
+ PanningOrientation::Vertical,
+ };
+
+ if (Dialog* pDialog = dynamic_cast<Dialog*>(pWindow.get()))
+ {
+ pDialog->EnableInput();
+ }
+
+ Application::PostGestureEvent(VclEventId::WindowGestureEvent, pWindow, &aEvent);
+}
+
static void doc_setTextSelection(LibreOfficeKitDocument* pThis, int nType, int nX, int nY)
{
SolarMutexGuard aGuard;