[Libreoffice-commits] online.git: Branch 'distro/collabora/collabora-online-4-0' - loleaflet/src
Michael Meeks (via logerrit)
logerrit at kemper.freedesktop.org
Wed Oct 9 09:15:06 UTC 2019
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 <michael.meeks at collabora.com>
AuthorDate: Wed Jun 26 21:55:23 2019 +0100
Commit: Aron Budea <aron.budea at collabora.com>
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 <aron.budea at collabora.com>
Tested-by: Aron Budea <aron.budea at collabora.com>
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');
}
More information about the Libreoffice-commits
mailing list