lgpasquale/gnome-shell-extension-disable-screenshield

Code is not so robust (fix included for gnome 3.16)

matthijskooijman opened this issue · 2 comments

It seems that whenever gnome-shell is changed, this extension needs changes as well since it's implementation is very much tied together. It seems that this coupling can be slightly reduced by using ScreenShield._liftShield() . The following is working for 3.12, but I suspect it will also work in 3.8 and 3.10:

diff --git a/extension.js b/extension.js
index f95d9fc..3645d17 100644
--- a/extension.js
+++ b/extension.js
@@ -4,20 +4,8 @@ let _onUserBecameActiveOrig;

 function _onUserBecameActiveInjected()
 {
-    this.idleMonitor.remove_watch(this._becameActiveId);
-    this._becameActiveId = 0;
-
-    let lightboxWasShown = this._longLightbox.shown || this._shortLightbox.shown;
-    this._longLightbox.hide();
-    this._shortLightbox.hide();
-
-    // Shortcircuit in case the mouse was moved before the fade completed
-    // or the screen is not locked
-    if (!lightboxWasShown || !this._isLocked)
-    {
-        this.deactivate(false);
-        return;
-    }
+    this._liftShield(true /* onPrimary */, 0 /* velocity */);
+    _onUserBecameActiveOrig.call(this);
 }

 function init()

While looking into this, I also discovered that the working of this extension relies on a non-obvious timing coincidence. When the shield is shown, all extensions are disabled. They are only enabled until after the shield is opened again. This would suggest that this extension could not work. However, I suspect that it works because ScreenShield registers the user active handler before the extension is disabled, so that still uses the function injected by this extension. It now seems to work every time (so it's not a race condition), but a future change in ScreenShield could break this ordering and make things break. Something to keep in mind...

According to https://mail.gnome.org/archives/gnome-shell-list/2015-August/msg00026.html this patch fixes the extension on gnome 3.16

That patch doesn't really work.
It just lifts the shield without resetting some important variables.
Once the shield is activated, for example, even if it gets lifted, the screen keeps turning off with a very short idle delay, the same delay used when the screen is active.
Anyway, I have update the extension to properly work with gnome versions up to 3.18