[Libreoffice-commits] online.git: Branch 'distro/collabora/milestone-7' - loleaflet/src

Marco Cecchetti marco.cecchetti at collabora.com
Mon Jan 25 09:53:41 PST 2016


 loleaflet/src/map/Map.js |   28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

New commits:
commit b47013c0e9e80906732d6f50724cfffd77ee5b9e
Author: Marco Cecchetti <marco.cecchetti at collabora.com>
Date:   Mon Jan 25 15:46:11 2016 +0100

    loleaflet - active cursor in multiple documents - fixed
    
    Added handlers for focus and blur events.
    
    Change-Id: Ie85ae264696e5221168f7ac280ba91732e9f5df3

diff --git a/loleaflet/src/map/Map.js b/loleaflet/src/map/Map.js
index 87dd60f..eb430a9 100644
--- a/loleaflet/src/map/Map.js
+++ b/loleaflet/src/map/Map.js
@@ -607,6 +607,9 @@ L.Map = L.Evented.extend({
 		if (this.options.trackResize && this._resizeDetector.contentWindow) {
 			L.DomEvent[onOff](this._resizeDetector.contentWindow, 'resize', this._onResize, this);
 		}
+
+		L.DomEvent[onOff](window, 'blur', this._onLostFocus, this);
+		L.DomEvent[onOff](window, 'focus', this._onGotFocus, this);
 	},
 
 	_onResize: function () {
@@ -615,6 +618,31 @@ L.Map = L.Evented.extend({
 		        function () { this.invalidateSize({debounceMoveend: true}); }, this, false, this._container);
 	},
 
+	_onLostFocus: function () {
+		var doclayer = this._docLayer;
+		if (doclayer._isCursorVisible && doclayer._isCursorOverlayVisible) {
+			doclayer._visibleCursorOnLostFocus = doclayer._visibleCursor;
+			doclayer._isCursorOverlayVisibleOnLostFocus = doclayer._isCursorVisibleOnLostFocus = true;
+			doclayer._isCursorOverlayVisible = false;
+			doclayer._onUpdateCursor();
+		}
+	},
+
+	_onGotFocus: function () {
+		var doclayer = this._docLayer;
+		if (doclayer._isCursorVisibleOnLostFocus && doclayer._isCursorOverlayVisibleOnLostFocus) {
+			// we restore the old cursor position by a small delay, so that if the user clicks
+			// inside the document we skip to restore it, so that the user does not see the cursor
+			// jumping from the old position to the new one
+			setTimeout(function () {
+				if (doclayer._isCursorOverlayVisible) { return; } // user has clicked inside the document
+				doclayer._isCursorOverlayVisible = doclayer._isCursorVisible = true;
+				doclayer._visibleCursor = doclayer._visibleCursorOnLostFocus;
+				doclayer._onUpdateCursor();
+			}, 300);
+		}
+	},
+
 	_isMouseEnteringLeaving: function (e) {
 		var target = e.target || e.srcElement,
 			related = e.relatedTarget;


More information about the Libreoffice-commits mailing list