[Libreoffice-commits] online.git: Branch 'distro/collabora/collabora-online-3' - 2 commits - loleaflet/src
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Tue Nov 13 16:06:35 UTC 2018
loleaflet/src/control/Control.Scroll.js | 2 -
loleaflet/src/control/Parts.js | 2 -
loleaflet/src/layer/tile/TileLayer.js | 55 ++++++++++++++++++++------------
loleaflet/src/map/Map.js | 22 ++++--------
loleaflet/src/map/handler/Map.Scroll.js | 2 -
5 files changed, 45 insertions(+), 38 deletions(-)
New commits:
commit 98fe14c28e94ef499f27d1b1b585a199961fcf7f
Author: Michael Meeks <michael.meeks at collabora.com>
AuthorDate: Sat Oct 6 22:37:50 2018 +0100
Commit: Michael Meeks <michael.meeks at collabora.com>
CommitDate: Tue Nov 13 16:04:28 2018 +0000
Simplify cursor visibility.
Removes race conditions between kit messages and browser.
Avoid storing old state wherever possible.
Change-Id: I56aa57df22a4190881c8d197df8445ca542d4fc1
cursor simplify.
Don't show cursor when graphics are selected either.
Change-Id: I0a604d73bd1818317a2b04d8bdd392d1d6472627
Hide other view cursors on zoom.
Change-Id: I9e953f841b5c526b499f9170aef9b2682011947e
diff --git a/loleaflet/src/control/Parts.js b/loleaflet/src/control/Parts.js
index 21c8525fd..c37636bc6 100644
--- a/loleaflet/src/control/Parts.js
+++ b/loleaflet/src/control/Parts.js
@@ -21,7 +21,7 @@ L.Map.include({
else {
return;
}
- if (docLayer._isCursorOverlayVisible) {
+ if (docLayer.isCursorVisible()) {
// a click outside the slide to clear any selection
this._socket.sendMessage('resetselection');
}
diff --git a/loleaflet/src/layer/tile/TileLayer.js b/loleaflet/src/layer/tile/TileLayer.js
index b3f45581d..ebae1bbd7 100644
--- a/loleaflet/src/layer/tile/TileLayer.js
+++ b/loleaflet/src/layer/tile/TileLayer.js
@@ -75,10 +75,10 @@ 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));
- // Cursor overlay is visible or hidden (for blinking).
- this._isCursorOverlayVisible = false;
- // Cursor overlay visibility flag to store last state during zooming
- this._oldCursorOverlayVisibility = false;
+ // Do we have focus - ie. should we render a cursor
+ this._isFocused = true;
+ // 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
@@ -531,7 +531,6 @@ L.TileLayer = L.GridLayer.extend({
_onCursorVisibleMsg: function(textMsg) {
var command = textMsg.match('cursorvisible: true');
this._isCursorVisible = command ? true : false;
- this._isCursorOverlayVisible = true;
this._onUpdateCursor();
},
@@ -745,8 +744,6 @@ L.TileLayer = L.GridLayer.extend({
this._visibleCursor = new L.LatLngBounds(
this._twipsToLatLng(topLeftTwips, this._map.getZoom()),
this._twipsToLatLng(bottomRightTwips, this._map.getZoom()));
- this._visibleCursorOnLostFocus = this._visibleCursor;
- this._isCursorOverlayVisible = true;
if ((docLayer._followEditor || docLayer._followUser) && this._map.lastActionByUser) {
this._map.fire('setFollowOff');
}
@@ -1354,8 +1351,7 @@ L.TileLayer = L.GridLayer.extend({
},
_clearSelections: function () {
- // hide the cursor
- this._isCursorOverlayVisible = false;
+ // hide the cursor if not editable
this._onUpdateCursor();
// hide the text selection
this._selections.clearLayers();
@@ -1432,15 +1428,16 @@ L.TileLayer = L.GridLayer.extend({
},
_onZoomStart: function () {
- this._oldCursorOverlayVisibility = this._isCursorOverlayVisible;
- this._isCursorOverlayVisible = false;
+ this._isZooming = true;
this._onUpdateCursor();
+ this.updateAllViewCursors();
},
_onZoomEnd: function () {
- this._isCursorOverlayVisible = this._oldCursorOverlayVisibility;
+ this._isZooming = false;
this._onUpdateCursor();
+ this.updateAllViewCursors();
},
_updateCursorPos: function () {
@@ -1481,7 +1478,7 @@ L.TileLayer = L.GridLayer.extend({
this.eachView(this._viewCursors, function (item) {
var viewCursorMarker = item.marker;
if (viewCursorMarker) {
- viewCursorMarker.setOpacity(this._map.hasLayer(this._cursorMarker) && this._cursorMarker.getLatLng().equals(viewCursorMarker.getLatLng()) ? 0 : 1);
+ viewCursorMarker.setOpacity(this.isCursorVisible() && this._cursorMarker.getLatLng().equals(viewCursorMarker.getLatLng()) ? 0 : 1);
}
}, this, true);
},
@@ -1490,14 +1487,15 @@ 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
- && this._isCursorOverlayVisible
+ && this._isCursorVisible // only when LOK has told us it is ok
+ && this._isFocused // not when document is not focused
+ && !this._isZooming // not when zooming
+ && !this.isGraphicVisible() // not when sizing / positioning graphics
&& !this._isEmptyRectangle(this._visibleCursor)) {
this._updateCursorPos();
}
else if (this._cursorMarker) {
this._map.removeLayer(this._cursorMarker);
- this._isCursorOverlayVisible = false;
}
},
@@ -1515,8 +1513,11 @@ L.TileLayer = L.GridLayer.extend({
var viewCursorVisible = this._viewCursors[viewId].visible;
var viewPart = this._viewCursors[viewId].part;
- if (!this._map.isViewReadOnly(viewId) && viewCursorVisible && !this._isEmptyRectangle(this._viewCursors[viewId].bounds) &&
- (this._docType === 'text' || this._selectedPart === viewPart)) {
+ if (!this._map.isViewReadOnly(viewId) &&
+ viewCursorVisible &&
+ !this._isZooming &&
+ !this._isEmptyRectangle(this._viewCursors[viewId].bounds) &&
+ (this._docType === 'text' || this._selectedPart === viewPart)) {
if (!viewCursorMarker) {
var viewCursorOptions = {
color: L.LOUtil.rgbToHex(this._map.getViewColor(viewId)),
@@ -1532,7 +1533,7 @@ L.TileLayer = L.GridLayer.extend({
else {
viewCursorMarker.setLatLng(viewCursorPos, pixBounds.getSize().multiplyBy(this._map.getZoomScale(this._map.getZoom())));
}
- viewCursorMarker.setOpacity(this._map.hasLayer(this._cursorMarker) && this._cursorMarker.getLatLng().equals(viewCursorMarker.getLatLng()) ? 0 : 1);
+ viewCursorMarker.setOpacity(this.isCursorVisible() && this._cursorMarker.getLatLng().equals(viewCursorMarker.getLatLng()) ? 0 : 1);
this._viewLayerGroup.addLayer(viewCursorMarker);
}
else if (viewCursorMarker) {
@@ -1540,6 +1541,20 @@ L.TileLayer = L.GridLayer.extend({
}
},
+ updateAllViewCursors : function() {
+ for (var key in this._viewCursors) {
+ this._onUpdateViewCursor(key);
+ }
+ },
+
+ isCursorVisible: function() {
+ return this._map.hasLayer(this._cursorMarker);
+ },
+
+ isGraphicVisible: function() {
+ return this._graphicMarker && this._map.hasLayer(this._graphicMarker);
+ },
+
goToViewCursor: function(viewId) {
if (viewId === this._viewId) {
this._onUpdateCursor();
@@ -1706,7 +1721,6 @@ L.TileLayer = L.GridLayer.extend({
this._graphicMarker = L.rectangle(this._graphicSelection, {
pointerEvents: 'none',
fill: false});
- this._visibleCursor = this._visibleCursorOnLostFocus = this._graphicMarker._bounds;
if (!this._graphicMarker) {
this._map.fire('error', {msg: 'Graphic marker initialization', cmd: 'marker', kind: 'failed', id: 1});
return;
@@ -1721,6 +1735,7 @@ L.TileLayer = L.GridLayer.extend({
this._map.removeLayer(this._graphicMarker);
this._graphicMarker.isDragged = false;
}
+ this._updateCursorAndOverlay();
},
_onUpdateCellCursor: function (horizontalDirection, verticalDirection, onPgUpDn) {
diff --git a/loleaflet/src/map/Map.js b/loleaflet/src/map/Map.js
index 7a078ebd2..1dffaa458 100644
--- a/loleaflet/src/map/Map.js
+++ b/loleaflet/src/map/Map.js
@@ -988,15 +988,9 @@ L.Map = L.Evented.extend({
console.debug('_onLostFocus: ');
var doclayer = this._docLayer;
- if (!doclayer) { return; }
-
- // save state of cursor (blinking marker) and the cursor overlay
- doclayer._isCursorVisibleOnLostFocus = doclayer._isCursorVisible;
- doclayer._isCursorOverlayVisibleOnLostFocus = doclayer._isCursorOverlayVisible;
-
- // if the blinking cursor is visible, disable the overlay when we go out of focus
- if (doclayer._isCursorVisible && doclayer._isCursorOverlayVisible) {
- doclayer._isCursorOverlayVisible = false;
+ if (doclayer)
+ {
+ doclayer._isFocused = false;
doclayer._updateCursorAndOverlay();
}
@@ -1008,16 +1002,14 @@ L.Map = L.Evented.extend({
if (!this._loaded) { return; }
var doclayer = this._docLayer;
- if (doclayer &&
- typeof doclayer._isCursorOverlayVisibleOnLostFocus !== 'undefined' &&
- typeof doclayer._isCursorVisibleOnLostFocus !== 'undefined') {
+ if (doclayer)
+ {
+ doclayer._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
setTimeout(function () {
- // restore the state that was before focus was lost
- doclayer._isCursorOverlayVisible = doclayer._isCursorOverlayVisibleOnLostFocus;
- doclayer._isCursorVisible = doclayer._isCursorVisibleOnLostFocus;
+ console.debug('apply focus change in timeout');
doclayer._updateCursorAndOverlay();
}, 300);
}
commit c81dca923e5a8bef50b9509a1f5d4994a1ac8acd
Author: Michael Meeks <michael.meeks at collabora.com>
AuthorDate: Mon Nov 12 22:09:07 2018 +0000
Commit: Michael Meeks <michael.meeks at collabora.com>
CommitDate: Tue Nov 13 16:00:45 2018 +0000
Avoid scroll-wheel jittering, and shrink the scroll increment.
Hypothetically the underlying cause is that malihu's
scrollTo:function(val,options){ calculates data based on current state,
dispatches asynchronous changes to that state, and can thus while
that change is in-flight can mis-calculate subsequent changes - causing
significant jitter.
Change-Id: I3c8becead04582b05e30d7dfab233e898509cd75
diff --git a/loleaflet/src/control/Control.Scroll.js b/loleaflet/src/control/Control.Scroll.js
index 4973e109d..a3fe3725c 100644
--- a/loleaflet/src/control/Control.Scroll.js
+++ b/loleaflet/src/control/Control.Scroll.js
@@ -168,7 +168,7 @@ L.Control.Scroll = L.Control.extend({
if (e.x < 0) {
x = '-=' + Math.abs(e.x);
}
- $('.scroll-container').mCustomScrollbar('scrollTo', [y, x]);
+ $('.scroll-container').mCustomScrollbar('scrollTo', [y, x], { timeout: 1 });
},
_onScrollVelocity: function (e) {
diff --git a/loleaflet/src/map/handler/Map.Scroll.js b/loleaflet/src/map/handler/Map.Scroll.js
index 9c584ecc1..2203b6596 100644
--- a/loleaflet/src/map/handler/Map.Scroll.js
+++ b/loleaflet/src/map/handler/Map.Scroll.js
@@ -53,7 +53,7 @@ L.Map.Scroll = L.Handler.extend({
_performScroll: function () {
var map = this._map,
delta = -this._delta,
- scrollAmount = Math.round(map.getSize().y / 4);
+ scrollAmount = Math.round(map.getSize().y / 20);
this._delta = 0;
this._startTime = null;
More information about the Libreoffice-commits
mailing list