summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAshod Nakashian <ashod.nakashian@collabora.co.uk>2020-03-09 07:50:57 -0400
committerAshod Nakashian <ashnakash@gmail.com>2020-03-18 07:29:49 +0100
commitb0f8897b470d64053ccf3fd2bf43f614cdd511a4 (patch)
treef40a0c7516180c6ed7289752ded2e2a0aade884d
parentbc5bf2eb2ad355f342f158bcefcb968bb7e78318 (diff)
leaflet: show/hide the keyboard with the cursor
We should only show the cursor without the keyboard when the focus is not in the document, and even that is highly suspecious. Change-Id: Ibbddf24464b0b41bb0206a8d28f31aa26779fbb8 Reviewed-on: https://gerrit.libreoffice.org/c/online/+/90525 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
-rw-r--r--loleaflet/src/layer/tile/TileLayer.js34
1 files changed, 17 insertions, 17 deletions
diff --git a/loleaflet/src/layer/tile/TileLayer.js b/loleaflet/src/layer/tile/TileLayer.js
index 4937e7c31..7cdea620d 100644
--- a/loleaflet/src/layer/tile/TileLayer.js
+++ b/loleaflet/src/layer/tile/TileLayer.js
@@ -2139,26 +2139,13 @@ L.TileLayer = L.GridLayer.extend({
_updateCursorPos: function () {
var pixBounds = L.bounds(this._map.latLngToLayerPoint(this._visibleCursor.getSouthWest()),
this._map.latLngToLayerPoint(this._visibleCursor.getNorthEast()));
+ var cursorSize = pixBounds.getSize().multiplyBy(this._map.getZoomScale(this._map.getZoom()));
var cursorPos = this._visibleCursor.getNorthWest();
- var updated = true;
if (!this._cursorMarker) {
- this._cursorMarker = L.cursor(cursorPos, pixBounds.getSize().multiplyBy(this._map.getZoomScale(this._map.getZoom())), {blink: true});
+ this._cursorMarker = L.cursor(cursorPos, cursorSize, {blink: true});
} else {
- var oldLatLng = this._cursorMarker.getLatLng();
- this._cursorMarker.setLatLng(cursorPos, pixBounds.getSize().multiplyBy(this._map.getZoomScale(this._map.getZoom())));
- var newLatLng = this._cursorMarker.getLatLng();
- // Assume the user didn't update the cursor if there is a selection.
- // The update can happen when the font has changed, for example.
- updated = !newLatLng.equals(oldLatLng) && !this.hasTextSelection();
- }
-
- this._map._textInput.showCursor();
-
- if (!window.mobileWizard && updated && this._map.editorHasFocus()) {
- // If the user is editing, show the keyboard, but don't change
- // anything if nothing is changed, or the wizard is visible.
- this._map.focus(true);
+ this._cursorMarker.setLatLng(cursorPos, cursorSize);
}
},
@@ -2197,11 +2184,24 @@ L.TileLayer = L.GridLayer.extend({
&& this._map.editorHasFocus() // not when document is not focused
&& !this._map.isSearching() // not when searching within the doc
&& !this._isZooming // not when zooming
-// && !this.isGraphicVisible() // not when sizing / positioning graphics
&& !this._isEmptyRectangle(this._visibleCursor)) {
+
this._updateCursorPos();
+
+ // Update the cursor/keyboard only when the document has focus.
+ if (this._map.editorHasFocus()) {
+ this._map._textInput.showCursor();
+
+ // Don't show the keyboard when the Wizard is visible.
+ if (!window.mobileWizard) {
+ // If the user is editing, show the keyboard, but don't change
+ // anything if nothing is changed.
+ this._map.focus(true);
+ }
+ }
} else {
this._map._textInput.hideCursor();
+ this._map.focus(false);
}
},