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 <quikee@gmail.com>
Tested-by: Tomaž Vajngerl <quikee@gmail.com>
diff --git a/kit/ChildSession.cpp b/kit/ChildSession.cpp
index 3514461..88a02eb 100644
--- a/kit/ChildSession.cpp
+++ b/kit/ChildSession.cpp
@@ -263,6 +263,7 @@
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 @@
{
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 @@
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 f40110b..5970023 100644
--- a/kit/ChildSession.hpp
+++ b/kit/ChildSession.hpp
@@ -255,6 +255,7 @@
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 0c3ec04..3222976 100644
--- a/loleaflet/src/control/Control.LokDialog.js
+++ b/loleaflet/src/control/Control.LokDialog.js
@@ -8,6 +8,9 @@
};
var firstTouchPositionX = null;
var firstTouchPositionY = null;
function updateTransformation(target) {
if (target !== null && target !== undefined) {
var value = [
@@ -524,6 +527,12 @@
' 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 @@
_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 f2b6029..ad5d4b9 100644
--- a/wsd/ClientSession.cpp
+++ b/wsd/ClientSession.cpp
@@ -152,6 +152,7 @@
tokens[0] != "windowkey" &&
tokens[0] != "mouse" &&
tokens[0] != "windowmouse" &&
tokens[0] != "windowgesture" &&
tokens[0] != "partpagerectangles" &&
tokens[0] != "ping" &&
tokens[0] != "renderfont" &&