loleaflet/src/core/Socket.js | 7 ++++--- loleaflet/src/map/Map.js | 36 ++++++++++++++++++++++++++++++++++-- 2 files changed, 38 insertions(+), 5 deletions(-)
New commits: commit e2eddca5d9af337d87e28c4f9d184961effb5b8f Author: Michael Meeks <[email protected]> AuthorDate: Wed Jun 26 21:55:23 2019 +0100 Commit: Aron Budea <[email protected]> CommitDate: Wed Oct 9 11:14:49 2019 +0200 dimming: wait 4x as long before dimming a visible window. Use several variants to try to detect visible browser windows. Also check we havn't had an active event before dimming. Change-Id: I10a0a19b606d93f8c6ab76cc74e561e2820ceec9 Reviewed-on: https://gerrit.libreoffice.org/80491 Reviewed-by: Aron Budea <[email protected]> Tested-by: Aron Budea <[email protected]> diff --git a/loleaflet/src/core/Socket.js b/loleaflet/src/core/Socket.js index 96bcca375..350f19f2b 100644 --- a/loleaflet/src/core/Socket.js +++ b/loleaflet/src/core/Socket.js @@ -361,6 +361,7 @@ L.Socket = L.Class.extend({ var socket = this; map = this._map; + clearTimeout(vex.timer); vex.timer = setInterval(function() { if (socket.connected()) { // We're connected: cancel timer and dialog. @@ -404,6 +405,7 @@ L.Socket = L.Class.extend({ // Reload the document this._map._active = false; map = this._map; + clearTimeout(vex.timer); vex.timer = setInterval(function() { try { // Activate and cancel timer and dialogs. @@ -611,10 +613,9 @@ L.Socket = L.Class.extend({ // The document is unloading. Have to wait a bit. this._map._active = false; - if (this.ReconnectCount++ >= 10) { - clearTimeout(vex.timer); + clearTimeout(vex.timer); + if (this.ReconnectCount++ >= 10) return; // Give up. - } map = this._map; vex.timer = setInterval(function() { diff --git a/loleaflet/src/map/Map.js b/loleaflet/src/map/Map.js index a02528ca0..10525ae73 100644 --- a/loleaflet/src/map/Map.js +++ b/loleaflet/src/map/Map.js @@ -1008,6 +1008,20 @@ L.Map = L.Evented.extend({ return false; }, + documentHidden: function(unknownValue) { + var hidden = unknownValue; + if (typeof document.hidden !== 'undefined') { + hidden = document.hidden; + } else if (typeof document.msHidden !== 'undefined') { + hidden = document.msHidden; + } else if (typeof document.webkitHidden !== 'undefined') { + hidden = document.webkitHidden; + } else { + console.debug('Unusual browser, cant determine if hidden'); + } + return hidden; + }, + _dim: function() { if (this.options.alwaysActive || this._debugAlwaysActive === true) { return; @@ -1018,11 +1032,29 @@ L.Map = L.Evented.extend({ return; } - this._active = false; clearTimeout(vex.timer); - var message = ''; var map = this; + var inactiveMs = Date.now() - this.lastActiveTime; + var multiplier = 1; + if (!this.documentHidden(true)) + { + console.debug('document visible'); + multiplier = 4; // quadruple the grace period + } + if (inactiveMs <= this.options.outOfFocusTimeoutSecs * 1000 * multiplier) { + console.debug('had activity ' + inactiveMs + 'ms ago vs. threshold ' + + (this.options.outOfFocusTimeoutSecs * 1000 * multiplier) + + ' - so fending off the dim'); + vex.timer = setTimeout(function() { + map._dim(); + }, map.options.outOfFocusTimeoutSecs * 1000); + return; + } + + this._active = false; + + var message = ''; if (!map['wopi'].DisableInactiveMessages) { message = _('Inactive document - please click to resume editing'); } _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
