loleaflet/src/core/Socket.js |    2 ++
 loleaflet/src/map/Map.js     |   39 ++++++++++++++++++++++++++++++++++-----
 2 files changed, 36 insertions(+), 5 deletions(-)

New commits:
commit 80429c6c1daeb9672a13d5bd9ecd60aca7207f7d
Author: Ashod Nakashian <ashod.nakash...@collabora.co.uk>
Date:   Sun Apr 24 16:58:37 2016 -0400

    loleaflet: activate upon reconnection, reconnect upon activation
    
    Change-Id: I047b4e25a90dab25f92920f2cba272051e08c90c
    Reviewed-on: https://gerrit.libreoffice.org/24354
    Reviewed-by: Ashod Nakashian <ashnak...@gmail.com>
    Tested-by: Ashod Nakashian <ashnak...@gmail.com>

diff --git a/loleaflet/src/core/Socket.js b/loleaflet/src/core/Socket.js
index 9efb60f..5412d3a 100644
--- a/loleaflet/src/core/Socket.js
+++ b/loleaflet/src/core/Socket.js
@@ -96,6 +96,8 @@ L.Socket = L.Class.extend({
                        this._doSend(this._msgQueue[i].msg, 
this._msgQueue[i].coords);
                }
                this._msgQueue = [];
+
+               this._map._activate();
        },
 
        _onMessage: function (e) {
diff --git a/loleaflet/src/map/Map.js b/loleaflet/src/map/Map.js
index 4abd285..847ba85 100644
--- a/loleaflet/src/map/Map.js
+++ b/loleaflet/src/map/Map.js
@@ -64,6 +64,8 @@ L.Map = L.Evented.extend({
                this._bDisableKeyboard = false;
                this._active = true;
 
+               vex.dialog_id = -1;
+
                this.callInitHooks();
 
                if (this.options.imagePath) {
@@ -690,17 +692,44 @@ L.Map = L.Evented.extend({
 
        _activate: function () {
                clearTimeout(vex.timer);
-               this._socket.sendMessage('useractive');
-               this._docLayer._onMessage('invalidatetiles: part=0 x=0 y=0 
width=2147483647 height=2147483647', null);
 
-               return vex.close(vex.globalID - 1);
+               if (!this._active) {
+                       this._socket.sendMessage('useractive');
+
+                       // Only activate when we are connected.
+                       if (this._socket.connected()) {
+                               this._docLayer._onMessage('invalidatetiles: 
part=0 x=0 y=0 width=2147483647 height=2147483647', null);
+                               this._active = true;
+
+                               if (vex.dialog_id > 0) {
+                                       id = vex.dialog_id;
+                                       vex.dialog_id = -1;
+                                       return vex.close(id);
+                               }
+                       }
+               }
+
+               return false;
        },
 
        _deactivate: function () {
+               clearTimeout(vex.timer);
+
+               if (!this._active || vex.dialog_id > 0) {
+                       // A dialog is already dimming the screen and probably
+                       // shows an error message. Leave it alone.
+                       this._active = false;
+                       this._docLayer._onMessage('textselection:', null);
+                       if (this._socket.connected()) {
+                               this._socket.sendMessage('userinactive');
+                       }
+
+                       return;
+               }
+
                var map = this;
                vex.timer = setTimeout(function() {
-                       L.Log.log("Deactivating");
-                       this._active = false;
+                       map._active = false;
                        clearTimeout(vex.timer);
 
                        options = $.extend({}, vex.defaultOptions, {contentCSS: 
{"background":"rgba(0, 0, 0, 0)"}});
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to