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>
This commit is contained in:
Tomaž Vajngerl 2019-03-26 09:37:04 +09:00 committed by Tomaž Vajngerl
parent d5c47ef986
commit 02a07d62a5
4 changed files with 80 additions and 0 deletions

View file

@ -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)

View file

@ -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);

View file

@ -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;

View file

@ -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" &&