bundled/include/LibreOfficeKit/LibreOfficeKit.h | 9 ++++ bundled/include/LibreOfficeKit/LibreOfficeKit.hxx | 16 ++++++++ kit/ChildSession.cpp | 44 ++++++++++++++++++++++ kit/ChildSession.hpp | 1 loleaflet/src/control/Control.LokDialog.js | 35 +++++++++++++++++ wsd/ClientSession.cpp | 1 6 files changed, 106 insertions(+)
New commits: commit 8cab62e344198715df11f2f9fffaf79fc331ff0c Author: Tor Lillqvist <[email protected]> AuthorDate: Tue Mar 26 18:25:29 2019 +0200 Commit: Tomaž Vajngerl <[email protected]> CommitDate: Wed Mar 27 11:23:00 2019 +0900 Scroll in correct direction with gesture It is the combobox contents you are dragging with the gesture, so it should move in the same direction, not opposite. (If you would be draging the scrollbar's "thumb", then the contents of the combobox would indeed move in the other direction. But on a touch device, it definitely is the contents that the user is dragging.) Change-Id: I9dc9e3cc7e3a1412176fd1d84c5587c86410d191 (cherry picked from commit d124e3e5aaedd48c7f83f000fcbd682489b45b60) diff --git a/loleaflet/src/control/Control.LokDialog.js b/loleaflet/src/control/Control.LokDialog.js index a2d90b7ee..7ad6ccade 100644 --- a/loleaflet/src/control/Control.LokDialog.js +++ b/loleaflet/src/control/Control.LokDialog.js @@ -687,14 +687,14 @@ L.Control.LokDialog = L.Control.extend({ } else if (e.type === 'touchend') { - this._postWindowGestureEvent(childId, 'panEnd', firstTouchPositionX, firstTouchPositionY, touchY - firstTouchPositionY); + this._postWindowGestureEvent(childId, 'panEnd', firstTouchPositionX, firstTouchPositionY, firstTouchPositionY - touchY); firstTouchPositionX = null; firstTouchPositionY = null; } else if (e.type === 'touchmove') { - this._postWindowGestureEvent(childId, 'panUpdate', firstTouchPositionX, firstTouchPositionY, touchY - firstTouchPositionY); + this._postWindowGestureEvent(childId, 'panUpdate', firstTouchPositionX, firstTouchPositionY, firstTouchPositionY - touchY); } }, this); commit 898fa8551e061fff0fb420939a481e5155bf6d83 Author: Tor Lillqvist <[email protected]> AuthorDate: Tue Mar 26 18:01:16 2019 +0200 Commit: Tomaž Vajngerl <[email protected]> CommitDate: Wed Mar 27 11:22:25 2019 +0900 Update to match core master Change-Id: I8932f9ea8ebd1addd9679f2f325b4dbafa48578c (cherry picked from commit d0186aadee756882cf77fc5366b3298731c40923) diff --git a/bundled/include/LibreOfficeKit/LibreOfficeKit.h b/bundled/include/LibreOfficeKit/LibreOfficeKit.h index fe1b25bc3..b694dc522 100644 --- a/bundled/include/LibreOfficeKit/LibreOfficeKit.h +++ b/bundled/include/LibreOfficeKit/LibreOfficeKit.h @@ -356,6 +356,7 @@ struct _LibreOfficeKitDocumentClass /// @see lok::Document::getSignatureState(). int (*getSignatureState) (LibreOfficeKitDocument* pThis); +// END CERTIFICATE AND SIGNING /// @see lok::Document::renderShapeSelection size_t (*renderShapeSelection)(LibreOfficeKitDocument* pThis, char** pOutput); @@ -363,6 +364,14 @@ struct _LibreOfficeKitDocumentClass /// @see lok::Document::createViewWithOptions(). int (*createViewWithOptions) (LibreOfficeKitDocument* pThis, const char* pOptions); + /// @see lok::Document::postWindowGestureEvent(). + void (*postWindowGestureEvent) (LibreOfficeKitDocument* pThis, + unsigned nWindowId, + const char* pType, + int nX, + int nY, + int nOffset); + #endif // defined LOK_USE_UNSTABLE_API || defined LIBO_INTERNAL_ONLY }; diff --git a/bundled/include/LibreOfficeKit/LibreOfficeKit.hxx b/bundled/include/LibreOfficeKit/LibreOfficeKit.hxx index 72824be0f..f2163cd1f 100644 --- a/bundled/include/LibreOfficeKit/LibreOfficeKit.hxx +++ b/bundled/include/LibreOfficeKit/LibreOfficeKit.hxx @@ -633,6 +633,22 @@ public: return mpDoc->pClass->renderShapeSelection(mpDoc, pOutput); } + /** + * Posts a gesture event to the window with given id. + * + * @param nWindowId + * @param pType Event type, like panStart, panEnd, panUpdate. + * @param nX horizontal position in document coordinates + * @param nY vertical position in document coordinates + * @param nOffset difference value from when the gesture started to current value + */ + void postWindowGestureEvent(unsigned nWindowId, + const char* pType, + int nX, int nY, int nOffset) + { + return mpDoc->pClass->postWindowGestureEvent(mpDoc, nWindowId, pType, nX, nY, nOffset); + } + #endif // defined LOK_USE_UNSTABLE_API || defined LIBO_INTERNAL_ONLY }; commit 963cdb65d4df91ea14470b6717da740eb24f11d0 Author: Tomaž Vajngerl <[email protected]> AuthorDate: Tue Mar 26 21:02:01 2019 +0900 Commit: Tomaž Vajngerl <[email protected]> CommitDate: Wed Mar 27 11:20:09 2019 +0900 allow to pan outside of widget bounds Always pass firstTouchPosition{X,Y} instead of current X,Y position to _postWindowGestureEvent so that panning is continued even when you go out of widget (combobox) bounds. Change-Id: I769b013f933881d8d1294ffd094e1cf7871cb701 (cherry picked from commit 397249b9f3c41bc506ac116283aa34a1e5fdd883) diff --git a/loleaflet/src/control/Control.LokDialog.js b/loleaflet/src/control/Control.LokDialog.js index ca915c7c4..a2d90b7ee 100644 --- a/loleaflet/src/control/Control.LokDialog.js +++ b/loleaflet/src/control/Control.LokDialog.js @@ -687,14 +687,14 @@ L.Control.LokDialog = L.Control.extend({ } else if (e.type === 'touchend') { - this._postWindowGestureEvent(childId, 'panEnd', touchX, touchY, touchY - firstTouchPositionY); + this._postWindowGestureEvent(childId, 'panEnd', firstTouchPositionX, firstTouchPositionY, touchY - firstTouchPositionY); firstTouchPositionX = null; firstTouchPositionY = null; } else if (e.type === 'touchmove') { - this._postWindowGestureEvent(childId, 'panUpdate', touchX, touchY, touchY - firstTouchPositionY); + this._postWindowGestureEvent(childId, 'panUpdate', firstTouchPositionX, firstTouchPositionY, touchY - firstTouchPositionY); } }, this); commit 2d6f3685aff5ae8a52469639c1df21456c3bf1ca Author: Tor Lillqvist <[email protected]> AuthorDate: Tue Mar 26 12:52:08 2019 +0200 Commit: Tomaž Vajngerl <[email protected]> CommitDate: Wed Mar 27 11:19:58 2019 +0900 Prevent whole page from scrolling when dragging in a combo box in a dialog Change-Id: Ifcc256f0a882be6afe7a82cd7c95c5059b107bf7 (cherry picked from commit bced2a313af42dc1c3eaef552bf66869d15ff856) diff --git a/loleaflet/src/control/Control.LokDialog.js b/loleaflet/src/control/Control.LokDialog.js index 7e5c5950c..ca915c7c4 100644 --- a/loleaflet/src/control/Control.LokDialog.js +++ b/loleaflet/src/control/Control.LokDialog.js @@ -673,6 +673,7 @@ L.Control.LokDialog = L.Control.extend({ L.DomEvent.on(canvas, 'contextmenu', L.DomEvent.preventDefault); L.DomEvent.on(canvas, 'touchstart touchmove touchend', function(e) { + L.DomEvent.preventDefault(e); var rect = canvas.getBoundingClientRect(); var touchX = (e.type === 'touchend') ? e.changedTouches[0].clientX : e.targetTouches[0].clientX; var touchY = (e.type === 'touchend') ? e.changedTouches[0].clientY : e.targetTouches[0].clientY; commit fc9e265b90c33a68132453391dade33b301e180a Author: Tomaž Vajngerl <[email protected]> AuthorDate: Tue Mar 26 09:37:04 2019 +0900 Commit: Tomaž Vajngerl <[email protected]> CommitDate: Wed Mar 27 11:19:19 2019 +0900 tdf#124146 touch gesture support, send pan gesture in dialogs Pan gesture should work for comboboxes, for which panning is implemented in core. Change-Id: I0a7e49e9335159a302716f666e2334a9d532c115 Reviewed-on: https://gerrit.libreoffice.org/69720 Reviewed-by: Tomaž Vajngerl <[email protected]> Tested-by: Tomaž Vajngerl <[email protected]> (cherry picked from commit 02a07d62a5afc62be9404fdf77f2cb43761414a4) diff --git a/kit/ChildSession.cpp b/kit/ChildSession.cpp index 662b0a664..31e978894 100644 --- a/kit/ChildSession.cpp +++ b/kit/ChildSession.cpp @@ -263,6 +263,7 @@ bool ChildSession::_handleInput(const char *buffer, int length) tokens[0] == "windowkey" || tokens[0] == "mouse" || tokens[0] == "windowmouse" || + tokens[0] == "windowgesture" || tokens[0] == "uno" || tokens[0] == "selecttext" || tokens[0] == "selectgraphic" || @@ -329,6 +330,10 @@ bool ChildSession::_handleInput(const char *buffer, int length) { return mouseEvent(buffer, length, tokens, LokEventTargetEnum::Window); } + else if (tokens[0] == "windowgesture") + { + return gestureEvent(buffer, length, tokens); + } else if (tokens[0] == "uno") { return unoCommand(buffer, length, tokens); @@ -1094,6 +1099,45 @@ bool ChildSession::keyEvent(const char* /*buffer*/, int /*length*/, return true; } +bool ChildSession::gestureEvent(const char* /*buffer*/, int /*length*/, + const std::vector<std::string>& tokens) +{ + bool success = true; + + unsigned int windowID = 0; + int x; + int y; + int offset; + std::string type; + + if (tokens.size() < 6) + success = false; + + if (!success || + !getTokenUInt32(tokens[1], "id", windowID) || + !getTokenString(tokens[2], "type", type) || + !getTokenInteger(tokens[3], "x", x) || + !getTokenInteger(tokens[4], "y", y) || + !getTokenInteger(tokens[5], "offset", offset)) + { + success = false; + } + + if (!success) + { + sendTextFrame("error: cmd=" + std::string(tokens[0]) + " kind=syntax"); + return false; + } + + std::unique_lock<std::mutex> lock(_docManager.getDocumentMutex()); + + getLOKitDocument()->setView(_viewId); + + getLOKitDocument()->postWindowGestureEvent(windowID, type.c_str(), x, y, offset); + + return true; +} + bool ChildSession::mouseEvent(const char* /*buffer*/, int /*length*/, const std::vector<std::string>& tokens, const LokEventTargetEnum target) diff --git a/kit/ChildSession.hpp b/kit/ChildSession.hpp index f40110b15..597002336 100644 --- a/kit/ChildSession.hpp +++ b/kit/ChildSession.hpp @@ -255,6 +255,7 @@ private: bool extTextInputEvent(const char* /*buffer*/, int /*length*/, const std::vector<std::string>& tokens); bool dialogKeyEvent(const char* buffer, int length, const std::vector<std::string>& tokens); bool mouseEvent(const char* buffer, int length, const std::vector<std::string>& tokens, const LokEventTargetEnum target); + bool gestureEvent(const char* buffer, int length, const std::vector<std::string>& tokens); bool unoCommand(const char* buffer, int length, const std::vector<std::string>& tokens); bool selectText(const char* buffer, int length, const std::vector<std::string>& tokens); bool selectGraphic(const char* buffer, int length, const std::vector<std::string>& tokens); diff --git a/loleaflet/src/control/Control.LokDialog.js b/loleaflet/src/control/Control.LokDialog.js index c7917d8cb..7e5c5950c 100644 --- a/loleaflet/src/control/Control.LokDialog.js +++ b/loleaflet/src/control/Control.LokDialog.js @@ -8,6 +8,9 @@ L.WinUtil = { }; +var firstTouchPositionX = null; +var firstTouchPositionY = null; + function updateTransformation(target) { if (target !== null && target !== undefined) { var value = [ @@ -524,6 +527,12 @@ L.Control.LokDialog = L.Control.extend({ ' buttons=' + buttons + ' modifier=' + modifier); }, + _postWindowGestureEvent: function(winid, type, x, y, offset) { + console.log('x ' + x + ' y ' + y + ' o ' + offset); + this._map._socket.sendMessage('windowgesture id=' + winid + ' type=' + type + + ' x=' + x + ' y=' + y + ' offset=' + offset); + }, + _postWindowKeyboardEvent: function(winid, type, charcode, keycode) { this._map._socket.sendMessage('windowkey id=' + winid + ' type=' + type + ' char=' + charcode + ' key=' + keycode); @@ -663,6 +672,31 @@ L.Control.LokDialog = L.Control.extend({ _setupChildEvents: function(childId, canvas) { L.DomEvent.on(canvas, 'contextmenu', L.DomEvent.preventDefault); + L.DomEvent.on(canvas, 'touchstart touchmove touchend', function(e) { + var rect = canvas.getBoundingClientRect(); + var touchX = (e.type === 'touchend') ? e.changedTouches[0].clientX : e.targetTouches[0].clientX; + var touchY = (e.type === 'touchend') ? e.changedTouches[0].clientY : e.targetTouches[0].clientY; + touchX = touchX - rect.x; + touchY = touchY - rect.y; + if (e.type === 'touchstart') + { + firstTouchPositionX = touchX; + firstTouchPositionY = touchY; + this._postWindowGestureEvent(childId, 'panBegin', firstTouchPositionX, firstTouchPositionY, 0); + } + else if (e.type === 'touchend') + { + this._postWindowGestureEvent(childId, 'panEnd', touchX, touchY, touchY - firstTouchPositionY); + firstTouchPositionX = null; + firstTouchPositionY = null; + + } + else if (e.type === 'touchmove') + { + this._postWindowGestureEvent(childId, 'panUpdate', touchX, touchY, touchY - firstTouchPositionY); + } + }, this); + L.DomEvent.on(canvas, 'mousedown mouseup', function(e) { var buttons = 0; buttons |= e.button === this._map['mouse'].JSButtons.left ? this._map['mouse'].LOButtons.left : 0; diff --git a/wsd/ClientSession.cpp b/wsd/ClientSession.cpp index 665056f30..35f446c53 100644 --- a/wsd/ClientSession.cpp +++ b/wsd/ClientSession.cpp @@ -152,6 +152,7 @@ bool ClientSession::_handleInput(const char *buffer, int length) tokens[0] != "windowkey" && tokens[0] != "mouse" && tokens[0] != "windowmouse" && + tokens[0] != "windowgesture" && tokens[0] != "partpagerectangles" && tokens[0] != "ping" && tokens[0] != "renderfont" && _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
