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

Ashod Nakashian (via logerrit) logerrit at kemper.freedesktop.org
Tue Jan 28 10:44:50 UTC 2020


 loleaflet/src/control/Control.LokDialog.js |   30 +++++++-----
 loleaflet/src/layer/marker/TextInput.js    |    2 
 loleaflet/src/layer/tile/TileLayer.js      |   16 ++----
 loleaflet/src/map/Map.js                   |   67 ++++++++++++++++++-----------
 4 files changed, 68 insertions(+), 47 deletions(-)

New commits:
commit 84c0cd277f43552941e8e3b702a85bf6eb9e5bbb
Author:     Ashod Nakashian <ashod.nakashian at collabora.co.uk>
AuthorDate: Mon Jan 13 22:49:48 2020 -0500
Commit:     Jan Holesovsky <kendy at collabora.com>
CommitDate: Tue Jan 28 11:43:53 2020 +0100

    leaflet: new event to notify of focus change
    
    Change-Id: I30a8a1a2d1a8d46708db5748035e14daa76f5e14

diff --git a/loleaflet/src/control/Control.LokDialog.js b/loleaflet/src/control/Control.LokDialog.js
index 6ee870b7d..84513d46f 100644
--- a/loleaflet/src/control/Control.LokDialog.js
+++ b/loleaflet/src/control/Control.LokDialog.js
@@ -121,6 +121,8 @@ L.Control.LokDialog = L.Control.extend({
 		map.on('closepopups', this._onClosePopups, this);
 		map.on('closesidebar', this._closeSidebar, this);
 		map.on('editorgotfocus', this._onEditorGotFocus, this);
+		// Fired to signal that the input focus is being changed.
+		map.on('changefocuswidget', this._changeFocusWidget, this);
 		L.DomEvent.on(document, 'mouseup', this.onCloseCurrentPopUp, this);
 	},
 
@@ -343,13 +345,15 @@ L.Control.LokDialog = L.Control.extend({
 				$('#' + strId).dialog('option', 'title', e.title);
 			}
 		} else if (e.action === 'cursor_visible') {
+			// cursor_visible means focus has changed.
 			this._dialogs[e.id].cursorVisible = e.visible === 'true';
 			if (this._dialogs[e.id].cursorVisible) {
 				$('#' + strId + '-cursor').css({display: 'block'});
-				this._map.onFocusDialog(this, e.id);
+				this._map.fire('changefocuswidget', {winId: e.id, dialog: this}); // Us.
 			}
 			else {
 				$('#' + strId + '-cursor').css({display: 'none'});
+				this._map.fire('changefocuswidget', {winId: 0, dialog: null}); // Editor.
 			}
 		} else if (e.action === 'close') {
 			parent = this._getParentId(e.id);
@@ -955,6 +959,14 @@ L.Control.LokDialog = L.Control.extend({
 		}
 	},
 
+	// Focus is being changed, update states.
+	_changeFocusWidget: function (e) {
+		if (e.winId === 0) {
+			// We lost the focus.
+			this._onEditorGotFocus();
+		}
+	},
+
 	_paintDialog: function(parentId, rectangle, imgData) {
 		var strId = this._toStrId(parentId);
 		var canvas = document.getElementById(strId + '-canvas');
diff --git a/loleaflet/src/map/Map.js b/loleaflet/src/map/Map.js
index 95a30fddf..2b13de11c 100644
--- a/loleaflet/src/map/Map.js
+++ b/loleaflet/src/map/Map.js
@@ -245,6 +245,9 @@ L.Map = L.Evented.extend({
 
 		this.on('editorgotfocus', this._onEditorGotFocus, this);
 
+		// Fired to signal that the input focus is being changed.
+		this.on('changefocuswidget', this._changeFocusWidget, this);
+
 		// View info (user names and view ids)
 		this._viewInfo = {};
 		this._viewInfoByUserName = {};
@@ -1379,6 +1382,15 @@ L.Map = L.Evented.extend({
 		this._activate();
 	},
 
+	// Focus is being changed, update states.
+	_changeFocusWidget: function (e) {
+		if (e.winId === 0) {
+			this._onEditorGotFocus();
+		} else {
+			this.onFocusDialog(e.dialog, e.winId);
+		}
+	},
+
 	_onUpdateProgress: function (e) {
 		if (e.statusType === 'start') {
 			if (this._socket.socket.readyState === 1) {
commit e1b96a6d61f8406d9251daf3b160ec5d719caef0
Author:     Ashod Nakashian <ashod.nakashian at collabora.co.uk>
AuthorDate: Mon Jan 13 15:49:13 2020 -0500
Commit:     Jan Holesovsky <kendy at collabora.com>
CommitDate: Tue Jan 28 11:43:53 2020 +0100

    leaflet: onEditorLostFocus -> onFocusDialog
    
    Change-Id: Ib55da717f4f58159b0b60d31b7fd4de54e2d4f25

diff --git a/loleaflet/src/control/Control.LokDialog.js b/loleaflet/src/control/Control.LokDialog.js
index 2cf473ba3..6ee870b7d 100644
--- a/loleaflet/src/control/Control.LokDialog.js
+++ b/loleaflet/src/control/Control.LokDialog.js
@@ -346,7 +346,7 @@ L.Control.LokDialog = L.Control.extend({
 			this._dialogs[e.id].cursorVisible = e.visible === 'true';
 			if (this._dialogs[e.id].cursorVisible) {
 				$('#' + strId + '-cursor').css({display: 'block'});
-				this._map.onEditorLostFocus(this);
+				this._map.onFocusDialog(this, e.id);
 			}
 			else {
 				$('#' + strId + '-cursor').css({display: 'none'});
diff --git a/loleaflet/src/map/Map.js b/loleaflet/src/map/Map.js
index 9c026277b..95a30fddf 100644
--- a/loleaflet/src/map/Map.js
+++ b/loleaflet/src/map/Map.js
@@ -1331,24 +1331,20 @@ L.Map = L.Evented.extend({
 		}, map.options.outOfFocusTimeoutSecs * 1000);
 	},
 
-	// The editor lost focus (probably a dialog was created).
-	onEditorLostFocus: function onEditorLostFocus(dialog) {
+	// Change the focus to a dialog.
+	onFocusDialog: function onFocusDialog(dialog, winId) {
 		if (!this._loaded) { return; }
 
+		this._winId = winId;
+		this._activeDialog = dialog;
+
 		var doclayer = this._docLayer;
 		if (doclayer)
-		{
 			doclayer._updateCursorAndOverlay();
-		}
-
-		if (dialog) {
-			this._activeDialog = dialog;
-		}
 	},
 
 	// Our browser tab lost focus.
 	_onLostFocus: function () {
-		this.onEditorLostFocus();
 		this._deactivate();
 	},
 
@@ -1374,10 +1370,10 @@ L.Map = L.Evented.extend({
 
 	// Our browser tab got focus.
 	_onGotFocus: function () {
-		if (this._activeDialog === null) {
-			this._onEditorGotFocus();
-		} else {
+		if (this._activeDialog) {
 			this._activeDialog.focus(this._winId);
+		} else {
+			this.fire('editorgotfocus');
 		}
 
 		this._activate();
commit b220ebca67bafa252bb437aa303a10650d07b9be
Author:     Ashod Nakashian <ashod.nakashian at collabora.co.uk>
AuthorDate: Mon Jan 13 15:13:18 2020 -0500
Commit:     Jan Holesovsky <kendy at collabora.com>
CommitDate: Tue Jan 28 11:43:53 2020 +0100

    leaflet: remove _isFocused and add editorHasFocus
    
    Change-Id: I8ec3520e927487cc1b951f6a5d0d12c176ab8fe9

diff --git a/loleaflet/src/control/Control.LokDialog.js b/loleaflet/src/control/Control.LokDialog.js
index 166990aa2..2cf473ba3 100644
--- a/loleaflet/src/control/Control.LokDialog.js
+++ b/loleaflet/src/control/Control.LokDialog.js
@@ -889,7 +889,7 @@ L.Control.LokDialog = L.Control.extend({
 		}
 
 		$('#sidebar-dock-wrapper').css({display: ''});
-		if (this._map.getWinId() === 0) {
+		if (this._map.editorHasFocus()) {
 			this._map.fire('editorgotfocus');
 			this._map.focus();
 		}
@@ -1087,7 +1087,7 @@ L.Control.LokDialog = L.Control.extend({
 		this._adjustCalcInputBar(deckOffset);
 		// If we didn't have the focus, don't steal it form the editor.
 		if ($('#' + this._currentDeck.strId + '-cursor').css('display') === 'none') {
-			if (this._map.getWinId() === 0) {
+			if (this._map.editorHasFocus()) {
 				this._map.fire('editorgotfocus');
 				this._map.focus();
 			}
diff --git a/loleaflet/src/layer/marker/TextInput.js b/loleaflet/src/layer/marker/TextInput.js
index 6a404298e..0e3345200 100644
--- a/loleaflet/src/layer/marker/TextInput.js
+++ b/loleaflet/src/layer/marker/TextInput.js
@@ -691,7 +691,7 @@ L.TextInput = L.Layer.extend({
 		if (!type) {
 			type = 'input';
 		}
-		if (this._map.getWinId() === 0) {
+		if (this._map.editorHasFocus()) {
 			this._map._socket.sendMessage(
 				'key type=' + type + ' char=' + charCode + ' key=' + unoKeyCode + '\n'
 			);
diff --git a/loleaflet/src/layer/tile/TileLayer.js b/loleaflet/src/layer/tile/TileLayer.js
index 71927c471..f5fb704a8 100644
--- a/loleaflet/src/layer/tile/TileLayer.js
+++ b/loleaflet/src/layer/tile/TileLayer.js
@@ -1115,7 +1115,7 @@ L.TileLayer = L.GridLayer.extend({
 				.openOn(this._map);
 		}
 
-		if (!this._map._isFocused && (modifierViewId === this._viewId) && (this._map.getWinId === 0) && (this._map._permission === 'edit')) {
+		if (!this._map.editorHasFocus() && (modifierViewId === this._viewId) && (this._map.getWinId === 0) && (this._map._permission === 'edit')) {
 			// Regain cursor if we had been out of focus and now have input.
 			// (only if it is our own cursor and the input is actually not
 			// going into a dialog)
@@ -2090,7 +2090,7 @@ L.TileLayer = L.GridLayer.extend({
 		}
 
 		this._map._textInput.showCursor();
-		if (this._map._isFocused /* && !L.Browser.mobile */) {
+		if (this._map.editorHasFocus() /* && !L.Browser.mobile */) {
 			// On mobile, this is causing some key input to get lost.
 			this._map.focus();
 		}
@@ -2128,7 +2128,7 @@ L.TileLayer = L.GridLayer.extend({
 	_updateCursorAndOverlay: function (/*update*/) {
 		if (this._map._permission === 'edit'
 		&& this._map._isCursorVisible   // only when LOK has told us it is ok
-		&& this._map._isFocused         // not when document is not focused
+		&& this._map.editorHasFocus()   // not when document is not focused
 		&& !this._isZooming             // not when zooming
 //		&& !this.isGraphicVisible()     // not when sizing / positioning graphics
 		&& !this._isEmptyRectangle(this._visibleCursor)) {
diff --git a/loleaflet/src/map/Map.js b/loleaflet/src/map/Map.js
index c7e4aeca2..9c026277b 100644
--- a/loleaflet/src/map/Map.js
+++ b/loleaflet/src/map/Map.js
@@ -114,8 +114,6 @@ L.Map = L.Evented.extend({
 
 		// Focusing:
 		//
-		// Do we have focus - ie. should we render a cursor
-		this._isFocused = true;
 		// Cursor is visible or hidden (e.g. for graphic selection).
 		this._isCursorVisible = true;
 		// The ID of the window with focus. 0 for the document.
@@ -824,6 +822,11 @@ L.Map = L.Evented.extend({
 		return this._winId;
 	},
 
+	// Returns true iff the document has input focus.
+	editorHasFocus: function () {
+		return this.getWinId() === 0;
+	},
+
 	// TODO replace with universal implementation after refactoring projections
 
 	getZoomScale: function (toZoom, fromZoom) {
@@ -1335,7 +1338,6 @@ L.Map = L.Evented.extend({
 		var doclayer = this._docLayer;
 		if (doclayer)
 		{
-			this._isFocused = false;
 			doclayer._updateCursorAndOverlay();
 		}
 
@@ -1355,7 +1357,6 @@ L.Map = L.Evented.extend({
 		if (!this._loaded) { return; }
 
 		this._winId = 0;
-		this._isFocused = true;
 		this._activeDialog = null;
 
 		var doclayer = this._docLayer;
commit 610bcb0baabe6f6d7c918d1f0154f8bb00effa9d
Author:     Ashod Nakashian <ashod.nakashian at collabora.co.uk>
AuthorDate: Mon Jan 13 14:48:20 2020 -0500
Commit:     Jan Holesovsky <kendy at collabora.com>
CommitDate: Tue Jan 28 11:43:53 2020 +0100

    leaflet: remove unused event
    
    Change-Id: Id655e9d440d9fb46b99c717531275018d92756c2

diff --git a/loleaflet/src/control/Control.LokDialog.js b/loleaflet/src/control/Control.LokDialog.js
index be9485885..166990aa2 100644
--- a/loleaflet/src/control/Control.LokDialog.js
+++ b/loleaflet/src/control/Control.LokDialog.js
@@ -116,7 +116,6 @@ L.Control.LokDialog = L.Control.extend({
 	onAdd: function (map) {
 		map.on('window', this._onDialogMsg, this);
 		map.on('windowpaint', this._onDialogPaint, this);
-		map.on('opendialog', this._openDialog, this);
 		map.on('docloaded', this._docLoaded, this);
 		map.on('closepopup', this.onCloseCurrentPopUp, this);
 		map.on('closepopups', this._onClosePopups, this);
@@ -369,10 +368,6 @@ L.Control.LokDialog = L.Control.extend({
 		}
 	},
 
-	_openDialog: function(e) {
-		this._map.sendUnoCommand(e.uno);
-	},
-
 	_updateDialogCursor: function(dlgId, x, y, height) {
 		var strId = this._toStrId(dlgId);
 		var dialogCursor = L.DomUtil.get(strId + '-cursor');
commit 7ca2c880355b7db9ec0af2bd8b3306086caa7ef9
Author:     Ashod Nakashian <ashod.nakashian at collabora.co.uk>
AuthorDate: Mon Jan 13 14:38:51 2020 -0500
Commit:     Jan Holesovsky <kendy at collabora.com>
CommitDate: Tue Jan 28 11:43:53 2020 +0100

    leaflet: don't expose the textInput object via getter
    
    Contain the textInput instance in map and use
    the available focus() and blur() functions instead.
    Ideally these functions would be renamed to something
    more accurate, but that's a big and risky change.
    
    Note that there are many cases where the textInput is
    still accessed directly. These are harder to encapsulate
    just yet, but we should move in that direction.
    
    Change-Id: Ibc14fcbde14b54a9633cf534e11072f6fd383403

diff --git a/loleaflet/src/control/Control.LokDialog.js b/loleaflet/src/control/Control.LokDialog.js
index fecc36240..be9485885 100644
--- a/loleaflet/src/control/Control.LokDialog.js
+++ b/loleaflet/src/control/Control.LokDialog.js
@@ -381,7 +381,7 @@ L.Control.LokDialog = L.Control.extend({
 		// set the position of the cursor container element
 		L.DomUtil.setStyle(this._dialogs[dlgId].cursor, 'left', x + 'px');
 		L.DomUtil.setStyle(this._dialogs[dlgId].cursor, 'top', y + 'px');
-		this._map.getTextInput().focus();
+		this._map.focus();
 	},
 
 	_createDialogCursor: function(dialogId) {
@@ -410,11 +410,10 @@ L.Control.LokDialog = L.Control.extend({
 		}
 
 		this._map.setWinId(dlgId);
-		var inputContainer = this._map.getTextInput();
 		if (dlgId in this._dialogs && this._dialogs[dlgId].cursorVisible) {
-			inputContainer.focus();
+			this._map.focus();
 		} else {
-			inputContainer.blur();
+			this._map.blur();
 		}
 	},
 
diff --git a/loleaflet/src/map/Map.js b/loleaflet/src/map/Map.js
index 86c7211e4..c7e4aeca2 100644
--- a/loleaflet/src/map/Map.js
+++ b/loleaflet/src/map/Map.js
@@ -810,11 +810,6 @@ L.Map = L.Evented.extend({
 		return this._container;
 	},
 
-	// Returns the instance of layer/marker/TextInput in this map.
-	getTextInput: function getTextInput() {
-		return this._textInput;
-	},
-
 	// We have one global winId that controls what window (dialog, sidebar, or
 	// the main document) has the actual focus.  0 means the document.
 	setWinId: function (id) {
@@ -903,10 +898,16 @@ L.Map = L.Evented.extend({
 		return this.layerPointToLatLng(this.mouseEventToLayerPoint(e));
 	},
 
+	// Give the focus to the text input to accept keyboard input.
+	// On mobile, it will show the virtual keyboard.
 	focus: function () {
+		//TODO: we should check if focus is going to edit the doc in
+		//TODO: read-only mode and prevent it (but allow for searching).
 		this._textInput.focus();
 	},
 
+	// Lose focus to stop accepting keyboard input.
+	// On mobile, it will hide the virtual keyboard.
 	blur: function () {
 		this._textInput.blur();
 	},
commit 2684a6effeda36c9767ca005ed34289e4e8a4c7a
Author:     Ashod Nakashian <ashod.nakashian at collabora.co.uk>
AuthorDate: Mon Jan 13 14:21:11 2020 -0500
Commit:     Jan Holesovsky <kendy at collabora.com>
CommitDate: Tue Jan 28 11:43:53 2020 +0100

    leaflet: the activeDialog expects the window ID
    
    Change-Id: I4379930fe1df2b67d0b71af0b8264eeb74b098cf

diff --git a/loleaflet/src/map/Map.js b/loleaflet/src/map/Map.js
index 6803d8adf..86c7211e4 100644
--- a/loleaflet/src/map/Map.js
+++ b/loleaflet/src/map/Map.js
@@ -1375,7 +1375,7 @@ L.Map = L.Evented.extend({
 		if (this._activeDialog === null) {
 			this._onEditorGotFocus();
 		} else {
-			this._activeDialog.focus();
+			this._activeDialog.focus(this._winId);
 		}
 
 		this._activate();
commit 2d78fcb20c62a5086730a2c0ff2058248d6b463c
Author:     Ashod Nakashian <ashod.nakashian at collabora.co.uk>
AuthorDate: Mon Jan 13 14:19:37 2020 -0500
Commit:     Jan Holesovsky <kendy at collabora.com>
CommitDate: Tue Jan 28 11:43:53 2020 +0100

    leaflet: cleanup map._onEditorGotFocus
    
    Change-Id: I16ff60f006d83212010d19dfe595c416b351cadb

diff --git a/loleaflet/src/map/Map.js b/loleaflet/src/map/Map.js
index 119fb590d..6803d8adf 100644
--- a/loleaflet/src/map/Map.js
+++ b/loleaflet/src/map/Map.js
@@ -110,8 +110,6 @@ L.Map = L.Evented.extend({
 		this._documentIdle = false;
 		this._helpTarget = null; // help page that fits best the current context
 		this._disableDefaultAction = {}; // The events for which the default handler is disabled and only issues postMessage.
-		this._winId = 0;
-		this._activeDialog = null;
 		this.showSidebar = false;
 
 		// Focusing:
@@ -120,6 +118,10 @@ L.Map = L.Evented.extend({
 		this._isFocused = true;
 		// Cursor is visible or hidden (e.g. for graphic selection).
 		this._isCursorVisible = true;
+		// The ID of the window with focus. 0 for the document.
+		this._winId = 0;
+		// The object of the dialog, if any (must have .focus callable).
+		this._activeDialog = null;
 
 
 		vex.dialogID = -1;
@@ -1351,22 +1353,21 @@ L.Map = L.Evented.extend({
 	_onEditorGotFocus: function() {
 		if (!this._loaded) { return; }
 
+		this._winId = 0;
+		this._isFocused = true;
+		this._activeDialog = null;
+
 		var doclayer = this._docLayer;
 		if (doclayer)
 		{
-			this._isFocused = true;
 			// 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
-			var map = this;
 			setTimeout(function () {
 				console.debug('apply focus change in timeout');
-				map.setWinId(0);
 				doclayer._updateCursorAndOverlay();
 			}, 300);
 		}
-
-		this._activeDialog = null;
 	},
 
 	// Our browser tab got focus.
commit 18b3bfeabcde69e3e1736b6c6dc7c8b4fed27dec
Author:     Ashod Nakashian <ashod.nakashian at collabora.co.uk>
AuthorDate: Mon Jan 13 10:42:20 2020 -0500
Commit:     Jan Holesovsky <kendy at collabora.com>
CommitDate: Tue Jan 28 11:43:53 2020 +0100

    leaflet: move isCursorVisible to map
    
    Change-Id: Ie6f276f643eae38cb88fee4b2c77f992818f9ee7

diff --git a/loleaflet/src/layer/tile/TileLayer.js b/loleaflet/src/layer/tile/TileLayer.js
index cad28c9b3..71927c471 100644
--- a/loleaflet/src/layer/tile/TileLayer.js
+++ b/loleaflet/src/layer/tile/TileLayer.js
@@ -105,8 +105,6 @@ L.TileLayer = L.GridLayer.extend({
 		this.lastCursorPos = this._visibleCursor.getNorthWest();
 		// Are we zooming currently ? - if so, no cursor.
 		this._isZooming = false;
-		// Cursor is visible or hidden (e.g. for graphic selection).
-		this._isCursorVisible = true;
 		// Original rectangle graphic selection in twips
 		this._graphicSelectionTwips = new L.Bounds(new L.Point(0, 0), new L.Point(0, 0));
 		// Rectangle graphic selection
@@ -787,7 +785,7 @@ L.TileLayer = L.GridLayer.extend({
 
 	_onCursorVisibleMsg: function(textMsg) {
 		var command = textMsg.match('cursorvisible: true');
-		this._isCursorVisible = command ? true : false;
+		this._map._isCursorVisible = command ? true : false;
 		this._onUpdateCursor();
 	},
 
@@ -2103,7 +2101,7 @@ L.TileLayer = L.GridLayer.extend({
 		var cursorPos = this._visibleCursor.getNorthWest();
 		var docLayer = this._map._docLayer;
 
-		if (!zoom && scroll !== false && !this._map.getBounds().contains(this._visibleCursor) && this._isCursorVisible) {
+		if (!zoom && scroll !== false && !this._map.getBounds().contains(this._visibleCursor) && this._map._isCursorVisible) {
 			var center = this._map.project(cursorPos);
 			center = center.subtract(this._map.getSize().divideBy(2));
 			center.x = Math.round(center.x < 0 ? 0 : center.x);
@@ -2129,7 +2127,7 @@ L.TileLayer = L.GridLayer.extend({
 	// the state of the document (if the falgs are set)
 	_updateCursorAndOverlay: function (/*update*/) {
 		if (this._map._permission === 'edit'
-		&& this._isCursorVisible        // only when LOK has told us it is ok
+		&& this._map._isCursorVisible   // only when LOK has told us it is ok
 		&& this._map._isFocused         // not when document is not focused
 		&& !this._isZooming             // not when zooming
 //		&& !this.isGraphicVisible()     // not when sizing / positioning graphics
diff --git a/loleaflet/src/map/Map.js b/loleaflet/src/map/Map.js
index 1380aade3..119fb590d 100644
--- a/loleaflet/src/map/Map.js
+++ b/loleaflet/src/map/Map.js
@@ -118,6 +118,8 @@ L.Map = L.Evented.extend({
 		//
 		// Do we have focus - ie. should we render a cursor
 		this._isFocused = true;
+		// Cursor is visible or hidden (e.g. for graphic selection).
+		this._isCursorVisible = true;
 
 
 		vex.dialogID = -1;
commit b7e05a11896db7c08972ff84e247df7b8875c314
Author:     Ashod Nakashian <ashod.nakashian at collabora.co.uk>
AuthorDate: Mon Jan 13 10:34:48 2020 -0500
Commit:     Jan Holesovsky <kendy at collabora.com>
CommitDate: Tue Jan 28 11:43:53 2020 +0100

    leaflet: move isFocused to map
    
    Change-Id: Ie0776b5bca8728f69eccd3b6d83b9bbe8358ab0f

diff --git a/loleaflet/src/layer/tile/TileLayer.js b/loleaflet/src/layer/tile/TileLayer.js
index 731f10a49..cad28c9b3 100644
--- a/loleaflet/src/layer/tile/TileLayer.js
+++ b/loleaflet/src/layer/tile/TileLayer.js
@@ -101,8 +101,6 @@ L.TileLayer = L.GridLayer.extend({
 		this._documentInfo = '';
 		// Position and size of the visible cursor.
 		this._visibleCursor = new L.LatLngBounds(new L.LatLng(0, 0), new L.LatLng(0, 0));
-		// Do we have focus - ie. should we render a cursor
-		this._isFocused = true;
 		// Last cursor position for invalidation
 		this.lastCursorPos = this._visibleCursor.getNorthWest();
 		// Are we zooming currently ? - if so, no cursor.
@@ -1119,7 +1117,7 @@ L.TileLayer = L.GridLayer.extend({
 				.openOn(this._map);
 		}
 
-		if (!this._isFocused && (modifierViewId === this._viewId) && (this._map.getWinId === 0) && (this._map._permission === 'edit')) {
+		if (!this._map._isFocused && (modifierViewId === this._viewId) && (this._map.getWinId === 0) && (this._map._permission === 'edit')) {
 			// Regain cursor if we had been out of focus and now have input.
 			// (only if it is our own cursor and the input is actually not
 			// going into a dialog)
@@ -2094,7 +2092,7 @@ L.TileLayer = L.GridLayer.extend({
 		}
 
 		this._map._textInput.showCursor();
-		if (this._isFocused /* && !L.Browser.mobile */) {
+		if (this._map._isFocused /* && !L.Browser.mobile */) {
 			// On mobile, this is causing some key input to get lost.
 			this._map.focus();
 		}
@@ -2132,7 +2130,7 @@ L.TileLayer = L.GridLayer.extend({
 	_updateCursorAndOverlay: function (/*update*/) {
 		if (this._map._permission === 'edit'
 		&& this._isCursorVisible        // only when LOK has told us it is ok
-		&& this._isFocused              // not when document is not focused
+		&& this._map._isFocused         // not when document is not focused
 		&& !this._isZooming             // not when zooming
 //		&& !this.isGraphicVisible()     // not when sizing / positioning graphics
 		&& !this._isEmptyRectangle(this._visibleCursor)) {
diff --git a/loleaflet/src/map/Map.js b/loleaflet/src/map/Map.js
index 3cd72c31c..1380aade3 100644
--- a/loleaflet/src/map/Map.js
+++ b/loleaflet/src/map/Map.js
@@ -114,6 +114,12 @@ L.Map = L.Evented.extend({
 		this._activeDialog = null;
 		this.showSidebar = false;
 
+		// Focusing:
+		//
+		// Do we have focus - ie. should we render a cursor
+		this._isFocused = true;
+
+
 		vex.dialogID = -1;
 
 		this.callInitHooks();
@@ -1324,7 +1330,7 @@ L.Map = L.Evented.extend({
 		var doclayer = this._docLayer;
 		if (doclayer)
 		{
-			doclayer._isFocused = false;
+			this._isFocused = false;
 			doclayer._updateCursorAndOverlay();
 		}
 
@@ -1343,14 +1349,14 @@ L.Map = L.Evented.extend({
 	_onEditorGotFocus: function() {
 		if (!this._loaded) { return; }
 
-		var map = this;
 		var doclayer = this._docLayer;
 		if (doclayer)
 		{
-			doclayer._isFocused = true;
+			this._isFocused = true;
 			// 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
+			var map = this;
 			setTimeout(function () {
 				console.debug('apply focus change in timeout');
 				map.setWinId(0);


More information about the Libreoffice-commits mailing list