kit/ChildSession.cpp | 44 +++++++++++++++++++++++++++++ kit/ChildSession.hpp | 1 loleaflet/src/control/Control.LokDialog.js | 34 ++++++++++++++++++++++ wsd/ClientSession.cpp | 1 4 files changed, 80 insertions(+)
New commits: commit 02a07d62a5afc62be9404fdf77f2cb43761414a4 Author: Tomaž Vajngerl <[email protected]> AuthorDate: Tue Mar 26 09:37:04 2019 +0900 Commit: Tomaž Vajngerl <[email protected]> CommitDate: Tue Mar 26 10:48:17 2019 +0100 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]> diff --git a/kit/ChildSession.cpp b/kit/ChildSession.cpp index 35144618c..88a02eb66 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); @@ -1097,6 +1102,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 0c3ec04c9..3222976e3 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 f2b602955..ad5d4b97a 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
