[Libreoffice-commits] online.git: 11 commits - loleaflet/src

Henry Castro (via logerrit) logerrit at kemper.freedesktop.org
Wed Jul 10 06:06:51 UTC 2019


 loleaflet/src/control/Control.ContextMenu.js     |    1 
 loleaflet/src/control/Control.MobileInput.js     |    8 -
 loleaflet/src/core/Socket.js                     |    1 
 loleaflet/src/dom/Draggable.js                   |    8 -
 loleaflet/src/layer/marker/ClipboardContainer.js |    6 
 loleaflet/src/map/Map.js                         |   33 +++-
 loleaflet/src/map/handler/Map.BoxZoom.js         |    2 
 loleaflet/src/map/handler/Map.CalcTap.js         |  164 ++++++++++++-----------
 loleaflet/src/map/handler/Map.DoubleClickZoom.js |    2 
 loleaflet/src/map/handler/Map.Drag.js            |    2 
 loleaflet/src/map/handler/Map.Keyboard.js        |    2 
 loleaflet/src/map/handler/Map.Mouse.js           |    2 
 loleaflet/src/map/handler/Map.Scroll.js          |    2 
 loleaflet/src/map/handler/Map.Tap.js             |    4 
 loleaflet/src/map/handler/Map.TouchZoom.js       |    2 
 15 files changed, 133 insertions(+), 106 deletions(-)

New commits:
commit 2a318230e4fb08a72101deb3a4153ca7a88b27b7
Author:     Henry Castro <hcastro at collabora.com>
AuthorDate: Tue Jun 11 11:59:51 2019 -0400
Commit:     Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
CommitDate: Wed Jul 10 14:18:46 2019 +0900

    loleaflet: mobile: create Map.CalcTap handler when initialize L.Map
    
    Change-Id: If26278dc655ff4434bce0ca21d4b63623f2cdd17

diff --git a/loleaflet/src/dom/Draggable.js b/loleaflet/src/dom/Draggable.js
index 5c6e125fa..0c20f6824 100644
--- a/loleaflet/src/dom/Draggable.js
+++ b/loleaflet/src/dom/Draggable.js
@@ -28,7 +28,7 @@ L.Draggable = L.Evented.extend({
 	},
 
 	enable: function () {
-		if (this._enabled) { return; }
+		if (this._manualDrag || this._enabled) { return; }
 
 		L.DomEvent.on(this._dragStartTarget, L.Draggable.START.join(' '), this._onDown, this);
 
@@ -36,7 +36,7 @@ L.Draggable = L.Evented.extend({
 	},
 
 	disable: function () {
-		if (!this._enabled) { return; }
+		if (this._manualDrag || !this._enabled) { return; }
 
 		L.DomEvent.off(this._dragStartTarget, L.Draggable.START.join(' '), this._onDown, this);
 
@@ -80,8 +80,8 @@ L.Draggable = L.Evented.extend({
 		this.startOffset = this._startPoint.subtract(new L.Point(startBoundingRect.left, startBoundingRect.top));
 
 		L.DomEvent
-		    .on(document, L.Draggable.MOVE[e.type], this._onMove, this)
-		    .on(document, L.Draggable.END[e.type], this._onUp, this);
+			.on(document, L.Draggable.MOVE[e.type], this._onMove, this)
+			.on(document, L.Draggable.END[e.type], this._onUp, this);
 	},
 
 	_onMove: function (e) {
diff --git a/loleaflet/src/map/Map.js b/loleaflet/src/map/Map.js
index c88839020..c23b6b95a 100644
--- a/loleaflet/src/map/Map.js
+++ b/loleaflet/src/map/Map.js
@@ -109,6 +109,23 @@ L.Map = L.Evented.extend({
 
 		this.callInitHooks();
 
+		this.addHandler('keyboard', L.Map.Keyboard);
+		this.addHandler('dragging', L.Map.Drag);
+		if (L.Browser.touch && !L.Browser.pointer) {
+			//this.addHandler('tap', L.Map.Tap);
+			this.dragging.disable();
+			this.options.inertia = false;
+			this.dragging._draggable._manualDrag = true;
+			this._mainEvents('off');
+			this.addHandler('touchCalc', L.Map.CalcTap);
+			this.addHandler('touchZoom', L.Map.TouchZoom);
+		} else {
+			this.addHandler('mouse', L.Map.Mouse);
+			this.addHandler('boxZoom', L.Map.BoxZoom);
+			this.addHandler('scrollHandler', L.Map.Scroll);
+			this.addHandler('doubleClickZoom', L.Map.DoubleClickZoom);
+		}
+
 		if (this.options.imagePath) {
 			L.Icon.Default.imagePath = this.options.imagePath;
 		}
@@ -979,6 +996,11 @@ L.Map = L.Evented.extend({
 	},
 
 	// DOM event handling
+	_mainEvents: function (onOff) {
+		L.DomEvent[onOff](this._container, 'click dblclick mousedown mouseup ' +
+			'mouseover mouseout mousemove dragover drop ' +
+			'trplclick qdrplclick', this._handleDOMEvent, this);
+	},
 
 	_initEvents: function (remove) {
 		if (!L.DomEvent) { return; }
@@ -989,9 +1011,7 @@ L.Map = L.Evented.extend({
 
 		var onOff = remove ? 'off' : 'on';
 
-		L.DomEvent[onOff](this._container, 'click dblclick mousedown mouseup ' +
-			'mouseover mouseout mousemove dragover drop ' +
-			'trplclick qdrplclick', this._handleDOMEvent, this);
+		this._mainEvents(onOff);
 
 		if (this.options.trackResize && this._resizeDetector.contentWindow) {
 			L.DomEvent[onOff](this._resizeDetector.contentWindow, 'resize', this._onResize, this);
diff --git a/loleaflet/src/map/handler/Map.BoxZoom.js b/loleaflet/src/map/handler/Map.BoxZoom.js
index 2b84e9f6c..1ebad494c 100644
--- a/loleaflet/src/map/handler/Map.BoxZoom.js
+++ b/loleaflet/src/map/handler/Map.BoxZoom.js
@@ -97,5 +97,3 @@ L.Map.BoxZoom = L.Handler.extend({
 		}
 	}
 });
-
-L.Map.addInitHook('addHandler', 'boxZoom', L.Map.BoxZoom);
diff --git a/loleaflet/src/map/handler/Map.CalcTap.js b/loleaflet/src/map/handler/Map.CalcTap.js
index e10cff5a9..58613175a 100644
--- a/loleaflet/src/map/handler/Map.CalcTap.js
+++ b/loleaflet/src/map/handler/Map.CalcTap.js
@@ -3,6 +3,10 @@
  * L.Map.CalcTap is used to enable mobile taps.
  */
 
+L.Map.mergeOptions({
+	touchCalc: true,
+});
+
 /* global Hammer $ */
 L.Map.CalcTap = L.Handler.extend({
 
@@ -126,8 +130,8 @@ L.Map.CalcTap = L.Handler.extend({
 		    latlng = this._map.layerPointToLatLng(layerPoint),
 		    mousePos = this._map._docLayer._latLngToTwips(latlng);
 
-		this._map._docLayer._postMouseEvent('buttondown', mousePos.x, mousePos.y, 1, 1, 0);
-		this._map._docLayer._postMouseEvent('buttonup', mousePos.x, mousePos.y, 1, 1, 0);
+		this._map._docLayer._postMouseEvent('buttondown', mousePos.x, mousePos.y, 2, 1, 0);
+		this._map._docLayer._postMouseEvent('buttonup', mousePos.x, mousePos.y, 2, 1, 0);
 
 		if (!this._map.hasFocus()) {
 			setTimeout(L.bind(this._map.focus, this._map), 0);
diff --git a/loleaflet/src/map/handler/Map.DoubleClickZoom.js b/loleaflet/src/map/handler/Map.DoubleClickZoom.js
index 45edf9fdc..6e2717acb 100644
--- a/loleaflet/src/map/handler/Map.DoubleClickZoom.js
+++ b/loleaflet/src/map/handler/Map.DoubleClickZoom.js
@@ -28,5 +28,3 @@ L.Map.DoubleClickZoom = L.Handler.extend({
 		}
 	}
 });
-
-L.Map.addInitHook('addHandler', 'doubleClickZoom', L.Map.DoubleClickZoom);
diff --git a/loleaflet/src/map/handler/Map.Drag.js b/loleaflet/src/map/handler/Map.Drag.js
index f95e05f96..74a2fe64a 100644
--- a/loleaflet/src/map/handler/Map.Drag.js
+++ b/loleaflet/src/map/handler/Map.Drag.js
@@ -126,5 +126,3 @@ L.Map.Drag = L.Handler.extend({
 		}
 	}
 });
-
-L.Map.addInitHook('addHandler', 'dragging', L.Map.Drag);
diff --git a/loleaflet/src/map/handler/Map.Keyboard.js b/loleaflet/src/map/handler/Map.Keyboard.js
index 9ef49f1b9..d13cc37e2 100644
--- a/loleaflet/src/map/handler/Map.Keyboard.js
+++ b/loleaflet/src/map/handler/Map.Keyboard.js
@@ -563,5 +563,3 @@ L.Map.Keyboard = L.Handler.extend({
 		return false;
 	}
 });
-
-L.Map.addInitHook('addHandler', 'keyboard', L.Map.Keyboard);
diff --git a/loleaflet/src/map/handler/Map.Mouse.js b/loleaflet/src/map/handler/Map.Mouse.js
index 39d2cf722..e18fc6ad5 100644
--- a/loleaflet/src/map/handler/Map.Mouse.js
+++ b/loleaflet/src/map/handler/Map.Mouse.js
@@ -245,5 +245,3 @@ L.Map.Mouse = L.Handler.extend({
 		}
 	}
 });
-
-L.Map.addInitHook('addHandler', 'mouse', L.Map.Mouse);
diff --git a/loleaflet/src/map/handler/Map.Scroll.js b/loleaflet/src/map/handler/Map.Scroll.js
index 2b0e047c1..9090fb042 100644
--- a/loleaflet/src/map/handler/Map.Scroll.js
+++ b/loleaflet/src/map/handler/Map.Scroll.js
@@ -106,5 +106,3 @@ L.Map.Scroll = L.Handler.extend({
 		}
 	}
 });
-
-L.Map.addInitHook('addHandler', 'scrollHandler', L.Map.Scroll);
diff --git a/loleaflet/src/map/handler/Map.Tap.js b/loleaflet/src/map/handler/Map.Tap.js
index 5c10a0ef4..81565f2e4 100644
--- a/loleaflet/src/map/handler/Map.Tap.js
+++ b/loleaflet/src/map/handler/Map.Tap.js
@@ -144,7 +144,3 @@ L.Map.Tap = L.Handler.extend({
 		this._map._handleDOMEvent(simulatedEvent);
 	}
 });
-
-if (L.Browser.touch && !L.Browser.pointer) {
-	L.Map.addInitHook('addHandler', 'tap', L.Map.Tap);
-}
diff --git a/loleaflet/src/map/handler/Map.TouchZoom.js b/loleaflet/src/map/handler/Map.TouchZoom.js
index 5e33162dd..35b3cf839 100644
--- a/loleaflet/src/map/handler/Map.TouchZoom.js
+++ b/loleaflet/src/map/handler/Map.TouchZoom.js
@@ -120,5 +120,3 @@ L.Map.TouchZoom = L.Handler.extend({
 		return this._startCenter.add(centerOffset);
 	}
 });
-
-L.Map.addInitHook('addHandler', 'touchZoom', L.Map.TouchZoom);
commit dcb8ea10c11258f0ded919233c47871df0b2a056
Author:     Henry Castro <hcastro at collabora.com>
AuthorDate: Fri Jun 7 11:50:40 2019 -0400
Commit:     Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
CommitDate: Wed Jul 10 14:18:46 2019 +0900

    loleaflet: mobile: iuse initialize function in L.Map.CalcTap handler
    
    Change-Id: I201035a4c5a7a21853df97149c45f7a08d4553f2

diff --git a/loleaflet/src/map/handler/Map.CalcTap.js b/loleaflet/src/map/handler/Map.CalcTap.js
index f76a7a4f2..e10cff5a9 100644
--- a/loleaflet/src/map/handler/Map.CalcTap.js
+++ b/loleaflet/src/map/handler/Map.CalcTap.js
@@ -5,7 +5,10 @@
 
 /* global Hammer $ */
 L.Map.CalcTap = L.Handler.extend({
-	addHooks: function () {
+
+	initialize: function (map) {
+		L.Handler.prototype.initialize.call(this, map);
+
 		if (!this._toolbar) {
 			this._toolbar = L.control.contextToolbar();
 		}
@@ -19,12 +22,10 @@ L.Map.CalcTap = L.Handler.extend({
 				direction: Hammer.DIRECTION_ALL
 			});
 		}
-		this._hammer.on('hammer.input', L.bind(this._onHammer, this));
-		this._hammer.on('tap', L.bind(this._onTap, this));
-		this._hammer.on('panstart', L.bind(this._onPanStart, this));
-		this._hammer.on('pan', L.bind(this._onPan, this));
-		this._hammer.on('panend', L.bind(this._onPanEnd, this));
-		this._map.on('updatepermission', this._onPermission, this);
+
+		for (var events in L.Draggable.MOVE) {
+			L.DomEvent.on(document, L.Draggable.END[events], this._onDocUp, this);
+		}
 
 		/// $.contextMenu does not support touch events so,
 		/// attach 'touchend' menu clicks event handler
@@ -40,13 +41,25 @@ L.Map.CalcTap = L.Handler.extend({
 		}
 	},
 
+	addHooks: function () {
+		this._hammer.on('hammer.input', L.bind(this._onHammer, this));
+		this._hammer.on('tap', L.bind(this._onTap, this));
+		this._hammer.on('panstart', L.bind(this._onPanStart, this));
+		this._hammer.on('pan', L.bind(this._onPan, this));
+		this._hammer.on('panend', L.bind(this._onPanEnd, this));
+		this._map.on('updatepermission', this._onPermission, this);
+		this._onPermission({perm: this._map._permission});
+	},
+
 	removeHooks: function () {
-		this._hammer.off('doubletap', L.bind(this._onDoubleTap, this));
-		this._hammer.off('press', L.bind(this._onPress, this));
+		this._hammer.off('hammer.input', L.bind(this._onHammer, this));
 		this._hammer.off('tap', L.bind(this._onTap, this));
 		this._hammer.off('panstart', L.bind(this._onPanStart, this));
 		this._hammer.off('pan', L.bind(this._onPan, this));
 		this._hammer.off('panend', L.bind(this._onPanEnd, this));
+		this._hammer.off('doubletap', L.bind(this._onDoubleTap, this));
+		this._hammer.off('press', L.bind(this._onPress, this));
+		this._map.off('updatepermission', this._onPermission, this);
 	},
 
 	_onPermission: function (e) {
@@ -64,6 +77,12 @@ L.Map.CalcTap = L.Handler.extend({
 		L.DomEvent.stopPropagation(e.srcEvent);
 	},
 
+	_onDocUp: function () {
+		if (!this._map.touchCalc.enabled()) {
+			this._map.touchCalc.enable();
+		}
+	},
+
 	_onPress: function (e) {
 		var point = e.pointers[0],
 		    containerPoint = this._map.mouseEventToContainerPoint(point),
commit 42f94e962e877d9e8cc7ee008c8cf97e721f6a70
Author:     Henry Castro <hcastro at collabora.com>
AuthorDate: Thu Jun 6 09:56:28 2019 -0400
Commit:     Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
CommitDate: Wed Jul 10 14:18:46 2019 +0900

    loleaflet: mobile: attach 'touchend' event handler to $.contextMenu
    
    $.contextMenu does not support touch events so,
    attach 'touchend' menu clicks event handler
    
    Change-Id: Ia6ed0e4d6d5c9d425fd149652f453c192c70b412

diff --git a/loleaflet/src/map/handler/Map.CalcTap.js b/loleaflet/src/map/handler/Map.CalcTap.js
index 4d391039b..f76a7a4f2 100644
--- a/loleaflet/src/map/handler/Map.CalcTap.js
+++ b/loleaflet/src/map/handler/Map.CalcTap.js
@@ -3,7 +3,7 @@
  * L.Map.CalcTap is used to enable mobile taps.
  */
 
-/* global Hammer */
+/* global Hammer $ */
 L.Map.CalcTap = L.Handler.extend({
 	addHooks: function () {
 		if (!this._toolbar) {
@@ -25,6 +25,19 @@ L.Map.CalcTap = L.Handler.extend({
 		this._hammer.on('pan', L.bind(this._onPan, this));
 		this._hammer.on('panend', L.bind(this._onPanEnd, this));
 		this._map.on('updatepermission', this._onPermission, this);
+
+		/// $.contextMenu does not support touch events so,
+		/// attach 'touchend' menu clicks event handler
+		if (this._hammer.input instanceof Hammer.TouchInput) {
+			var $doc = $(document);
+			$doc.on('touchend.contextMenu', '.context-menu-item', function (e) {
+				var $elem = $(this);
+
+				if ($elem.data().contextMenu.selector === '.leaflet-layer') {
+					$.contextMenu.handle.itemClick.apply(this, [e]);
+				}
+			});
+		}
 	},
 
 	removeHooks: function () {
commit fddadc78a4b00e07f2c04482c1cffd41f42bc3f1
Author:     Henry Castro <hcastro at collabora.com>
AuthorDate: Wed Jun 5 12:35:42 2019 -0400
Commit:     Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
CommitDate: Wed Jul 10 14:18:46 2019 +0900

    loleaflet: mobile: enable panning events in read-only documents
    
    Change-Id: I94e496428173d487ecd1a3017863e2bbaefc667a

diff --git a/loleaflet/src/map/handler/Map.CalcTap.js b/loleaflet/src/map/handler/Map.CalcTap.js
index 50274d959..4d391039b 100644
--- a/loleaflet/src/map/handler/Map.CalcTap.js
+++ b/loleaflet/src/map/handler/Map.CalcTap.js
@@ -21,6 +21,9 @@ L.Map.CalcTap = L.Handler.extend({
 		}
 		this._hammer.on('hammer.input', L.bind(this._onHammer, this));
 		this._hammer.on('tap', L.bind(this._onTap, this));
+		this._hammer.on('panstart', L.bind(this._onPanStart, this));
+		this._hammer.on('pan', L.bind(this._onPan, this));
+		this._hammer.on('panend', L.bind(this._onPanEnd, this));
 		this._map.on('updatepermission', this._onPermission, this);
 	},
 
@@ -37,15 +40,9 @@ L.Map.CalcTap = L.Handler.extend({
 		if (e.perm == 'edit') {
 			this._hammer.on('doubletap', L.bind(this._onDoubleTap, this));
 			this._hammer.on('press', L.bind(this._onPress, this));
-			this._hammer.on('panstart', L.bind(this._onPanStart, this));
-			this._hammer.on('pan', L.bind(this._onPan, this));
-			this._hammer.on('panend', L.bind(this._onPanEnd, this));
 		} else {
 			this._hammer.off('doubletap', L.bind(this._onDoubleTap, this));
 			this._hammer.off('press', L.bind(this._onPress, this));
-			this._hammer.off('panstart', L.bind(this._onPanStart, this));
-			this._hammer.off('pan', L.bind(this._onPan, this));
-			this._hammer.off('panend', L.bind(this._onPanEnd, this));
 		}
 	},
 
commit b2311c31eb484c78a09f18413e55b2c7c9db999b
Author:     Henry Castro <hcastro at collabora.com>
AuthorDate: Wed Jun 5 11:55:58 2019 -0400
Commit:     Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
CommitDate: Wed Jul 10 14:18:46 2019 +0900

    loleaflet: mobile: hide the context toolbar on tap event
    
    Change-Id: I40d8d9f5e0ece04d3cd17d3b66ad17f89a0d67a4

diff --git a/loleaflet/src/core/Socket.js b/loleaflet/src/core/Socket.js
index 811506d4a..74b2cd3d1 100644
--- a/loleaflet/src/core/Socket.js
+++ b/loleaflet/src/core/Socket.js
@@ -761,6 +761,7 @@ L.Socket = L.Class.extend({
 					if (L.Browser.touch && !L.Browser.pointer) {
 						this._map.options.inertia = false;
 						this._map.removeHandler('tap');
+						this._map.removeHandler('mouse');
 						this._map.removeHandler('touchZoom');
 						if (this._map.dragging.enabled()) {
 							this._map.dragging.disable();
diff --git a/loleaflet/src/map/handler/Map.CalcTap.js b/loleaflet/src/map/handler/Map.CalcTap.js
index 43f3335ca..50274d959 100644
--- a/loleaflet/src/map/handler/Map.CalcTap.js
+++ b/loleaflet/src/map/handler/Map.CalcTap.js
@@ -61,10 +61,11 @@ L.Map.CalcTap = L.Handler.extend({
 		    latlng = this._map.layerPointToLatLng(layerPoint),
 		    mousePos = this._map._docLayer._latLngToTwips(latlng);
 
-		if (this._map._docLayer.containsSelection(latlng)) {
+		if (!this._toolbar._map && this._map._docLayer.containsSelection(latlng)) {
 			this._toolbar._pos = containerPoint;
 			this._toolbar.addTo(this._map);
 		} else {
+			this._toolbar.remove();
 			this._map._contextMenu._onMouseDown({originalEvent: e.srcEvent});
 			// send right click to trigger context menus
 			this._map._docLayer._postMouseEvent('buttondown', mousePos.x, mousePos.y, 1, 4, 0);
@@ -82,6 +83,7 @@ L.Map.CalcTap = L.Handler.extend({
 		    latlng = this._map.layerPointToLatLng(layerPoint),
 		    mousePos = this._map._docLayer._latLngToTwips(latlng);
 
+		this._toolbar.remove();
 		this._map._contextMenu._onMouseDown({originalEvent: e.srcEvent});
 		this._map._docLayer._postMouseEvent('buttondown', mousePos.x, mousePos.y, 1, 1, 0);
 		this._map._docLayer._postMouseEvent('buttonup', mousePos.x, mousePos.y, 1, 1, 0);
commit 045207282330a480246a05db8e523b3c80031980
Author:     Henry Castro <hcastro at collabora.com>
AuthorDate: Wed Jun 5 10:31:37 2019 -0400
Commit:     Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
CommitDate: Wed Jul 10 14:18:46 2019 +0900

    loleaflet: mobile: start cell selections when a drag inside ...
    
    the cursor cell
    
    Otherwise pan the sheet as before.
    
    Change-Id: I2b8d4278df4157229960930928da022872982022

diff --git a/loleaflet/src/map/handler/Map.CalcTap.js b/loleaflet/src/map/handler/Map.CalcTap.js
index f7174ad1b..43f3335ca 100644
--- a/loleaflet/src/map/handler/Map.CalcTap.js
+++ b/loleaflet/src/map/handler/Map.CalcTap.js
@@ -21,7 +21,6 @@ L.Map.CalcTap = L.Handler.extend({
 		}
 		this._hammer.on('hammer.input', L.bind(this._onHammer, this));
 		this._hammer.on('tap', L.bind(this._onTap, this));
-		this._hammer.on('swipe', L.bind(this._onSwipe, this));
 		this._map.on('updatepermission', this._onPermission, this);
 	},
 
@@ -29,7 +28,6 @@ L.Map.CalcTap = L.Handler.extend({
 		this._hammer.off('doubletap', L.bind(this._onDoubleTap, this));
 		this._hammer.off('press', L.bind(this._onPress, this));
 		this._hammer.off('tap', L.bind(this._onTap, this));
-		this._hammer.off('swipe', L.bind(this._onSwipe, this));
 		this._hammer.off('panstart', L.bind(this._onPanStart, this));
 		this._hammer.off('pan', L.bind(this._onPan, this));
 		this._hammer.off('panend', L.bind(this._onPanEnd, this));
@@ -73,6 +71,7 @@ L.Map.CalcTap = L.Handler.extend({
 			this._map._docLayer._postMouseEvent('buttonup', mousePos.x, mousePos.y, 1, 4, 0);
 		}
 
+		this._cellSelections = false;
 		e.preventDefault();
 	},
 
@@ -86,6 +85,7 @@ L.Map.CalcTap = L.Handler.extend({
 		this._map._contextMenu._onMouseDown({originalEvent: e.srcEvent});
 		this._map._docLayer._postMouseEvent('buttondown', mousePos.x, mousePos.y, 1, 1, 0);
 		this._map._docLayer._postMouseEvent('buttonup', mousePos.x, mousePos.y, 1, 1, 0);
+		this._cellSelections = false;
 	},
 
 	_onDoubleTap: function (e) {
@@ -110,7 +110,12 @@ L.Map.CalcTap = L.Handler.extend({
 		    latlng = this._map.layerPointToLatLng(layerPoint),
 		    mousePos = this._map._docLayer._latLngToTwips(latlng);
 
-		this._map._docLayer._postMouseEvent('buttondown', mousePos.x, mousePos.y, 1, 1, 0);
+		if (this._map._docLayer._cellCursor.contains(latlng)) {
+			this._cellSelections = true;
+			this._map._docLayer._postMouseEvent('buttondown', mousePos.x, mousePos.y, 1, 1, 0);
+		} else {
+			this._map.dragging._draggable._onDown(this._constructFakeEvent(point, 'mousedown'));
+		}
 	},
 
 	_onPan: function (e) {
@@ -120,7 +125,11 @@ L.Map.CalcTap = L.Handler.extend({
 		    latlng = this._map.layerPointToLatLng(layerPoint),
 		    mousePos = this._map._docLayer._latLngToTwips(latlng);
 
-		this._map._docLayer._postMouseEvent('move', mousePos.x, mousePos.y, 1, 1, 0);
+		if (this._cellSelections) {
+			this._map._docLayer._postMouseEvent('move', mousePos.x, mousePos.y, 1, 1, 0);
+		} else {
+			this._map.dragging._draggable._onMove(this._constructFakeEvent(point, 'mousemove'));
+		}
 	},
 
 	_onPanEnd: function (e) {
@@ -130,14 +139,17 @@ L.Map.CalcTap = L.Handler.extend({
 		    latlng = this._map.layerPointToLatLng(layerPoint),
 		    mousePos = this._map._docLayer._latLngToTwips(latlng);
 
-		this._map._docLayer._postMouseEvent('buttonup', mousePos.x, mousePos.y, 1, 1, 0);
+		if (this._cellSelections) {
+			this._cellSelections = false;
+			this._map._docLayer._postMouseEvent('buttonup', mousePos.x, mousePos.y, 1, 1, 0);
+		} else {
+			this._map.dragging._draggable._onUp(this._constructFakeEvent(point, 'mouseup'));
+		}
 	},
 
-	_onSwipe: function (e) {
-		var evt = e.pointers[0];
-
-		var iniEvent = {
-			type: 'mousedown',
+	_constructFakeEvent: function (evt, type) {
+		var fakeEvt = {
+			type: type,
 			canBubble: false,
 			cancelable: true,
 			screenX: evt.screenX,
@@ -153,26 +165,6 @@ L.Map.CalcTap = L.Handler.extend({
 			preventDefault: function () {}
 		};
 
-		var endEvent = {
-			type: 'mousemove',
-			canBubble: false,
-			cancelable: true,
-			screenX: evt.screenX,
-			screenY: evt.screenY,
-			clientX: evt.clientX + e.deltaX,
-			clientY: evt.clientY + e.deltaY,
-			ctrlKey: false,
-			altKey: false,
-			shiftKey: false,
-			metaKey: false,
-			button: 0,
-			target: evt.target,
-			preventDefault: function () {}
-		};
-
-		this._map.dragging._draggable._onDown(iniEvent);
-		this._map.dragging._draggable._moved = true;
-		this._map.dragging._draggable._onMove(endEvent);
-		setTimeout(L.bind(this._map.dragging._draggable._onUp, this._map.dragging._draggable, endEvent), 0);
+		return fakeEvt;
 	}
 });
commit 0c19139f5d3f0b344dc378b3741a5e29185e87e9
Author:     Henry Castro <hcastro at collabora.com>
AuthorDate: Tue Jun 4 22:24:27 2019 -0400
Commit:     Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
CommitDate: Wed Jul 10 14:18:46 2019 +0900

    loleaflet: mobile: display a context menu if touch press detected
    
    Change-Id: Iae19d2217c8e71de58debf1904bcd8cd83d124b1

diff --git a/loleaflet/src/control/Control.ContextMenu.js b/loleaflet/src/control/Control.ContextMenu.js
index a5cd4929c..7abdcbcfc 100644
--- a/loleaflet/src/control/Control.ContextMenu.js
+++ b/loleaflet/src/control/Control.ContextMenu.js
@@ -50,6 +50,7 @@ L.Control.ContextMenu = L.Control.extend({
 	onAdd: function (map) {
 		this._prevMousePos = null;
 
+		map._contextMenu = this;
 		map.on('locontextmenu', this._onContextMenu, this);
 		map.on('mousedown', this._onMouseDown, this);
 		map.on('keydown', this._onKeyDown, this);
diff --git a/loleaflet/src/map/handler/Map.CalcTap.js b/loleaflet/src/map/handler/Map.CalcTap.js
index f4dd86d2e..f7174ad1b 100644
--- a/loleaflet/src/map/handler/Map.CalcTap.js
+++ b/loleaflet/src/map/handler/Map.CalcTap.js
@@ -60,12 +60,20 @@ L.Map.CalcTap = L.Handler.extend({
 		var point = e.pointers[0],
 		    containerPoint = this._map.mouseEventToContainerPoint(point),
 		    layerPoint = this._map.containerPointToLayerPoint(containerPoint),
-		    latlng = this._map.layerPointToLatLng(layerPoint);
+		    latlng = this._map.layerPointToLatLng(layerPoint),
+		    mousePos = this._map._docLayer._latLngToTwips(latlng);
 
 		if (this._map._docLayer.containsSelection(latlng)) {
 			this._toolbar._pos = containerPoint;
 			this._toolbar.addTo(this._map);
+		} else {
+			this._map._contextMenu._onMouseDown({originalEvent: e.srcEvent});
+			// send right click to trigger context menus
+			this._map._docLayer._postMouseEvent('buttondown', mousePos.x, mousePos.y, 1, 4, 0);
+			this._map._docLayer._postMouseEvent('buttonup', mousePos.x, mousePos.y, 1, 4, 0);
 		}
+
+		e.preventDefault();
 	},
 
 	_onTap: function (e) {
@@ -75,6 +83,7 @@ L.Map.CalcTap = L.Handler.extend({
 		    latlng = this._map.layerPointToLatLng(layerPoint),
 		    mousePos = this._map._docLayer._latLngToTwips(latlng);
 
+		this._map._contextMenu._onMouseDown({originalEvent: e.srcEvent});
 		this._map._docLayer._postMouseEvent('buttondown', mousePos.x, mousePos.y, 1, 1, 0);
 		this._map._docLayer._postMouseEvent('buttonup', mousePos.x, mousePos.y, 1, 1, 0);
 	},
commit 1df1aa8dc661b9918f929f5a9a49dc6a2ce30143
Author:     Henry Castro <hcastro at collabora.com>
AuthorDate: Tue Jun 4 18:06:04 2019 -0400
Commit:     Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
CommitDate: Wed Jul 10 14:18:46 2019 +0900

    loleaflet: mobile: use doubletap event to set focus
    
    Change-Id: I37f59db2ce37ec5117c40be842f2ad06d045a212

diff --git a/loleaflet/src/control/Control.MobileInput.js b/loleaflet/src/control/Control.MobileInput.js
index 392d9b30d..84cd0b36f 100644
--- a/loleaflet/src/control/Control.MobileInput.js
+++ b/loleaflet/src/control/Control.MobileInput.js
@@ -59,7 +59,7 @@ L.Control.MobileInput = L.Control.extend({
 		}
 	},
 
-	focus: function(focus) {
+	focus: function (focus) {
 		if (this._map._permission !== 'edit') {
 			return;
 		}
@@ -70,6 +70,10 @@ L.Control.MobileInput = L.Control.extend({
 		}
 	},
 
+	hasFocus: function () {
+		return this._textArea === document.activeElement;
+	},
+
 	select: function() {
 		this._textArea.select();
 	},
@@ -87,7 +91,7 @@ L.Control.MobileInput = L.Control.extend({
 	},
 
 	showCursor: function () {
-		if (this._textArea === document.activeElement) {
+		if (this.hasFocus()) {
 			this.onGotFocus();
 		}
 	},
diff --git a/loleaflet/src/layer/marker/ClipboardContainer.js b/loleaflet/src/layer/marker/ClipboardContainer.js
index 41aae051d..ac1f01185 100644
--- a/loleaflet/src/layer/marker/ClipboardContainer.js
+++ b/loleaflet/src/layer/marker/ClipboardContainer.js
@@ -32,7 +32,7 @@ L.ClipboardContainer = L.Layer.extend({
 		               this._map._handleDOMEvent, this._map);
 	},
 
-	focus: function(focus) {
+	focus: function (focus) {
 		if (focus === false) {
 			this._textArea.blur();
 		} else {
@@ -40,6 +40,10 @@ L.ClipboardContainer = L.Layer.extend({
 		}
 	},
 
+	hasFocus: function () {
+		return this._textArea === document.activeElement;
+	},
+
 	select: function() {
 		this._textArea.select();
 	},
diff --git a/loleaflet/src/map/Map.js b/loleaflet/src/map/Map.js
index 3326d8042..c88839020 100644
--- a/loleaflet/src/map/Map.js
+++ b/loleaflet/src/map/Map.js
@@ -820,6 +820,10 @@ L.Map = L.Evented.extend({
 		this._clipboardContainer.focus();
 	},
 
+	hasFocus: function () {
+		return this._clipboardContainer.hasFocus();
+	},
+
 	setHelpTarget: function(page) {
 		this._helpTarget = page;
 	},
diff --git a/loleaflet/src/map/handler/Map.CalcTap.js b/loleaflet/src/map/handler/Map.CalcTap.js
index 7b0238034..f4dd86d2e 100644
--- a/loleaflet/src/map/handler/Map.CalcTap.js
+++ b/loleaflet/src/map/handler/Map.CalcTap.js
@@ -88,7 +88,10 @@ L.Map.CalcTap = L.Handler.extend({
 
 		this._map._docLayer._postMouseEvent('buttondown', mousePos.x, mousePos.y, 1, 1, 0);
 		this._map._docLayer._postMouseEvent('buttonup', mousePos.x, mousePos.y, 1, 1, 0);
-		this._map.focus();
+
+		if (!this._map.hasFocus()) {
+			setTimeout(L.bind(this._map.focus, this._map), 0);
+		}
 	},
 
 	_onPanStart: function (e) {
commit 343dca958f4debfdaf1a3c7f390795afbc0b974f
Author:     Henry Castro <hcastro at collabora.com>
AuthorDate: Tue Jun 4 17:50:13 2019 -0400
Commit:     Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
CommitDate: Wed Jul 10 14:18:46 2019 +0900

    loleaflet: mobile: add listener to "double tab" event
    
    The sequence to recognize 'doubletap' event, according to Hammerjs
    defaults:
    tap -> doubletap
    
    Change-Id: Ie2877b8527ae2274e7b2169080c25a278434f1f0

diff --git a/loleaflet/src/map/handler/Map.CalcTap.js b/loleaflet/src/map/handler/Map.CalcTap.js
index 34b1c74b1..7b0238034 100644
--- a/loleaflet/src/map/handler/Map.CalcTap.js
+++ b/loleaflet/src/map/handler/Map.CalcTap.js
@@ -11,36 +11,13 @@ L.Map.CalcTap = L.Handler.extend({
 		}
 
 		if (!this._hammer) {
-			this._hammer = new Hammer(this._map._container);
+			this._hammer = new Hammer(this._map._mapPane);
 			this._hammer.get('swipe').set({
 				direction: Hammer.DIRECTION_ALL
 			});
 			this._hammer.get('pan').set({
 				direction: Hammer.DIRECTION_ALL
 			});
-
-			/*FIXME the sidebar shows after double tap*/
-			/*this._hammer = new Hammer.Manager(this._map._container, {
-				touchAction: 'none'
-			});
-
-			/*this._hammer.add(new Hammer.Tap({
-				event: 'doubletap',
-				taps: 2
-			}));
-			this._hammer.add(new Hammer.Press());
-			this._hammer.add(new Hammer.Tap());
-			this._hammer.add(new Hammer.Pan({
-				direction: Hammer.DIRECTION_ALL,
-				threshold: 10,
-				pointers: 1
-			}));
-			this._hammer.add(new Hammer.Swipe({
-				direction: Hammer.DIRECTION_ALL,
-				threshold: 5,
-				pointers: 1,
-				velocity: 0.3
-			}));*/
 		}
 		this._hammer.on('hammer.input', L.bind(this._onHammer, this));
 		this._hammer.on('tap', L.bind(this._onTap, this));
@@ -49,7 +26,7 @@ L.Map.CalcTap = L.Handler.extend({
 	},
 
 	removeHooks: function () {
-		//this._hammer.off('doubletap', L.bind(this._onDoubleTap, this));
+		this._hammer.off('doubletap', L.bind(this._onDoubleTap, this));
 		this._hammer.off('press', L.bind(this._onPress, this));
 		this._hammer.off('tap', L.bind(this._onTap, this));
 		this._hammer.off('swipe', L.bind(this._onSwipe, this));
@@ -60,13 +37,13 @@ L.Map.CalcTap = L.Handler.extend({
 
 	_onPermission: function (e) {
 		if (e.perm == 'edit') {
-			//this._hammer.on('doubletap', L.bind(this._onDoubleTap, this));
+			this._hammer.on('doubletap', L.bind(this._onDoubleTap, this));
 			this._hammer.on('press', L.bind(this._onPress, this));
 			this._hammer.on('panstart', L.bind(this._onPanStart, this));
 			this._hammer.on('pan', L.bind(this._onPan, this));
 			this._hammer.on('panend', L.bind(this._onPanEnd, this));
 		} else {
-			//this._hammer.off('doubletap', L.bind(this._onDoubleTap, this));
+			this._hammer.off('doubletap', L.bind(this._onDoubleTap, this));
 			this._hammer.off('press', L.bind(this._onPress, this));
 			this._hammer.off('panstart', L.bind(this._onPanStart, this));
 			this._hammer.off('pan', L.bind(this._onPan, this));
@@ -75,7 +52,8 @@ L.Map.CalcTap = L.Handler.extend({
 	},
 
 	_onHammer: function (e) {
-		e.preventDefault();
+		L.DomEvent.preventDefault(e.srcEvent);
+		L.DomEvent.stopPropagation(e.srcEvent);
 	},
 
 	_onPress: function (e) {
@@ -99,7 +77,6 @@ L.Map.CalcTap = L.Handler.extend({
 
 		this._map._docLayer._postMouseEvent('buttondown', mousePos.x, mousePos.y, 1, 1, 0);
 		this._map._docLayer._postMouseEvent('buttonup', mousePos.x, mousePos.y, 1, 1, 0);
-		this._map.focus();
 	},
 
 	_onDoubleTap: function (e) {
@@ -109,8 +86,8 @@ L.Map.CalcTap = L.Handler.extend({
 		    latlng = this._map.layerPointToLatLng(layerPoint),
 		    mousePos = this._map._docLayer._latLngToTwips(latlng);
 
-		this._map._docLayer._postMouseEvent('buttondown', mousePos.x, mousePos.y, 2, 1, 0);
-		this._map._docLayer._postMouseEvent('buttonup', mousePos.x, mousePos.y, 2, 1, 0);
+		this._map._docLayer._postMouseEvent('buttondown', mousePos.x, mousePos.y, 1, 1, 0);
+		this._map._docLayer._postMouseEvent('buttonup', mousePos.x, mousePos.y, 1, 1, 0);
 		this._map.focus();
 	},
 
@@ -142,7 +119,6 @@ L.Map.CalcTap = L.Handler.extend({
 		    mousePos = this._map._docLayer._latLngToTwips(latlng);
 
 		this._map._docLayer._postMouseEvent('buttonup', mousePos.x, mousePos.y, 1, 1, 0);
-		this._map.focus();
 	},
 
 	_onSwipe: function (e) {
commit 40e0a42326eed886875285c08a2c682804e72928
Author:     Henry Castro <hcastro at collabora.com>
AuthorDate: Tue Jun 4 16:21:47 2019 -0400
Commit:     Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
CommitDate: Wed Jul 10 14:18:46 2019 +0900

    loleaflet: mobile: assign CSS properties to the "resize-detector"
    
    element
    
    Setting focus to the textArea element has a side effect, when the first
    touch it shows the floating keyboard
    
    Change-Id: Ib17c56de0caa67eaa28f03997afe9d724e30ce30

diff --git a/loleaflet/src/map/Map.js b/loleaflet/src/map/Map.js
index f84c70df1..3326d8042 100644
--- a/loleaflet/src/map/Map.js
+++ b/loleaflet/src/map/Map.js
@@ -136,8 +136,7 @@ L.Map = L.Evented.extend({
 		// Avoid white bar on the bottom - force resize-detector to get full size
 		if (window.mode.isMobile()) {
 			$('#document-container').css('bottom', '0px');
-			this._clipboardContainer._textArea.blur();
-			this._clipboardContainer._textArea.focus();
+			$(this._resizeDetector).css('bottom', '0px');
 		}
 
 		// When all these conditions are met, fire statusindicator:initializationcomplete
commit 04a8e68a71ceed05008897f90e77a9f8c4edd58b
Author:     Henry Castro <hcastro at collabora.com>
AuthorDate: Mon Jun 3 18:06:07 2019 -0400
Commit:     Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
CommitDate: Wed Jul 10 14:18:46 2019 +0900

    loleaflet: ilisten to the secret event that it is emitted ...
    
     by hammerjs library
    
    Otherwise, it doesn't guarantee that the events are prevented to default
    actions by the browser
    
    Change-Id: Iede8b64e25a27e54f7ad173f4df8daf4aeba3824

diff --git a/loleaflet/src/map/handler/Map.CalcTap.js b/loleaflet/src/map/handler/Map.CalcTap.js
index bb4ea0699..34b1c74b1 100644
--- a/loleaflet/src/map/handler/Map.CalcTap.js
+++ b/loleaflet/src/map/handler/Map.CalcTap.js
@@ -42,7 +42,7 @@ L.Map.CalcTap = L.Handler.extend({
 				velocity: 0.3
 			}));*/
 		}
-
+		this._hammer.on('hammer.input', L.bind(this._onHammer, this));
 		this._hammer.on('tap', L.bind(this._onTap, this));
 		this._hammer.on('swipe', L.bind(this._onSwipe, this));
 		this._map.on('updatepermission', this._onPermission, this);
@@ -74,6 +74,10 @@ L.Map.CalcTap = L.Handler.extend({
 		}
 	},
 
+	_onHammer: function (e) {
+		e.preventDefault();
+	},
+
 	_onPress: function (e) {
 		var point = e.pointers[0],
 		    containerPoint = this._map.mouseEventToContainerPoint(point),
@@ -84,7 +88,6 @@ L.Map.CalcTap = L.Handler.extend({
 			this._toolbar._pos = containerPoint;
 			this._toolbar.addTo(this._map);
 		}
-		e.preventDefault();
 	},
 
 	_onTap: function (e) {
@@ -97,7 +100,6 @@ L.Map.CalcTap = L.Handler.extend({
 		this._map._docLayer._postMouseEvent('buttondown', mousePos.x, mousePos.y, 1, 1, 0);
 		this._map._docLayer._postMouseEvent('buttonup', mousePos.x, mousePos.y, 1, 1, 0);
 		this._map.focus();
-		e.preventDefault();
 	},
 
 	_onDoubleTap: function (e) {
@@ -110,7 +112,6 @@ L.Map.CalcTap = L.Handler.extend({
 		this._map._docLayer._postMouseEvent('buttondown', mousePos.x, mousePos.y, 2, 1, 0);
 		this._map._docLayer._postMouseEvent('buttonup', mousePos.x, mousePos.y, 2, 1, 0);
 		this._map.focus();
-		e.preventDefault();
 	},
 
 	_onPanStart: function (e) {
@@ -121,7 +122,6 @@ L.Map.CalcTap = L.Handler.extend({
 		    mousePos = this._map._docLayer._latLngToTwips(latlng);
 
 		this._map._docLayer._postMouseEvent('buttondown', mousePos.x, mousePos.y, 1, 1, 0);
-		e.preventDefault();
 	},
 
 	_onPan: function (e) {
@@ -132,7 +132,6 @@ L.Map.CalcTap = L.Handler.extend({
 		    mousePos = this._map._docLayer._latLngToTwips(latlng);
 
 		this._map._docLayer._postMouseEvent('move', mousePos.x, mousePos.y, 1, 1, 0);
-		e.preventDefault();
 	},
 
 	_onPanEnd: function (e) {
@@ -144,7 +143,6 @@ L.Map.CalcTap = L.Handler.extend({
 
 		this._map._docLayer._postMouseEvent('buttonup', mousePos.x, mousePos.y, 1, 1, 0);
 		this._map.focus();
-		e.preventDefault();
 	},
 
 	_onSwipe: function (e) {
@@ -188,6 +186,5 @@ L.Map.CalcTap = L.Handler.extend({
 		this._map.dragging._draggable._moved = true;
 		this._map.dragging._draggable._onMove(endEvent);
 		setTimeout(L.bind(this._map.dragging._draggable._onUp, this._map.dragging._draggable, endEvent), 0);
-		e.preventDefault();
 	}
 });


More information about the Libreoffice-commits mailing list