[gnome-shell] Don't track the status of the screensaver on DBus



commit 34cb92ff4cb2fb95849900d463294bbf23e69551
Author: Giovanni Campagna <gcampagna src gnome org>
Date:   Tue May 22 23:24:32 2012 +0200

    Don't track the status of the screensaver on DBus
    
    We are the screensaver now, and internal objects can track the
    locking status better themselves. And to do so, add two signals
    to ScreenShield.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=619955

 js/Makefile.am            |    1 -
 js/misc/screenSaver.js    |   48 ---------------------------------------------
 js/ui/automountManager.js |   15 +++++--------
 js/ui/layout.js           |   33 ++++++++++--------------------
 js/ui/userMenu.js         |   17 ++++-----------
 5 files changed, 22 insertions(+), 92 deletions(-)
---
diff --git a/js/Makefile.am b/js/Makefile.am
index cf2353c..97d95a9 100644
--- a/js/Makefile.am
+++ b/js/Makefile.am
@@ -32,7 +32,6 @@ nobase_dist_js_DATA = 	\
 	misc/jsParse.js		\
 	misc/modemManager.js	\
 	misc/params.js		\
-	misc/screenSaver.js     \
 	misc/util.js		\
 	perf/core.js		\
 	ui/altTab.js		\
diff --git a/js/ui/automountManager.js b/js/ui/automountManager.js
index 9a6f7f6..69a94cb 100644
--- a/js/ui/automountManager.js
+++ b/js/ui/automountManager.js
@@ -9,7 +9,6 @@ const Params = imports.misc.params;
 const Shell = imports.gi.Shell;
 const Main = imports.ui.main;
 const ShellMountOperation = imports.ui.shellMountOperation;
-const ScreenSaver = imports.misc.screenSaver;
 const GnomeSession = imports.misc.gnomeSession;
 
 const GNOME_SESSION_AUTOMOUNT_INHIBIT = 16;
@@ -92,9 +91,7 @@ const AutomountManager = new Lang.Class({
         if (!haveSystemd())
             this.ckListener = new ConsoleKitManager();
 
-        this._ssProxy = new ScreenSaver.ScreenSaverProxy();
-        this._ssProxy.connectSignal('ActiveChanged',
-                                    Lang.bind(this, this._screenSaverActiveChanged));
+        Main.screenShield.connect('lock-status-changed', Lang.bind(this, this._lockStatusChanged));
 
         this._volumeMonitor = Gio.VolumeMonitor.get();
 
@@ -127,8 +124,8 @@ const AutomountManager = new Lang.Class({
                 }));
     },
 
-    _screenSaverActiveChanged: function(object, senderName, [isActive]) {
-        if (!isActive) {
+    _lockStatusChanged: function(shield, locked) {
+        if (!locked) {
             this._volumeQueue.forEach(Lang.bind(this, function(volume) {
                 this._checkAndMountVolume(volume);
             }));
@@ -166,7 +163,7 @@ const AutomountManager = new Lang.Class({
         if (!this.isSessionActive())
             return;
 
-        if (this._ssProxy.screenSaverActive)
+        if (Main.screenShield.locked)
             return;
 
         global.play_theme_sound(0, 'device-added-media');
@@ -178,7 +175,7 @@ const AutomountManager = new Lang.Class({
         if (!this.isSessionActive())
             return;
 
-        if (this._ssProxy.screenSaverActive)
+        if (Main.screenShield.locked)
             return;
 
         global.play_theme_sound(0, 'device-removed-media');        
@@ -230,7 +227,7 @@ const AutomountManager = new Lang.Class({
             if (!this.isSessionActive())
                 return;
 
-            if (this._ssProxy.screenSaverActive) {
+            if (Main.screenShield.locked) {
                 if (this._volumeQueue.indexOf(volume) == -1)
                     this._volumeQueue.push(volume);
 
diff --git a/js/ui/layout.js b/js/ui/layout.js
index acf6e1f..a4da201 100644
--- a/js/ui/layout.js
+++ b/js/ui/layout.js
@@ -11,7 +11,6 @@ const St = imports.gi.St;
 const DND = imports.ui.dnd;
 const Main = imports.ui.main;
 const Params = imports.misc.params;
-const ScreenSaver = imports.misc.screenSaver;
 const Tweener = imports.ui.tweener;
 
 const HOT_CORNER_ACTIVATION_TIMEOUT = 0.5;
@@ -565,6 +564,7 @@ const Chrome = new Lang.Class({
 
         this._monitors = [];
         this._inOverview = false;
+        this._isLocked = false;
         this._updateRegionIdle = 0;
         this._freezeUpdateCount = 0;
 
@@ -579,16 +579,6 @@ const Chrome = new Lang.Class({
         global.screen.connect('notify::n-workspaces',
                               Lang.bind(this, this._queueUpdateRegions));
 
-        this._screenSaverActive = false;
-        this._screenSaverProxy = new ScreenSaver.ScreenSaverProxy();
-        this._screenSaverProxy.connectSignal('ActiveChanged', Lang.bind(this, function(proxy, senderName, [isActive]) {
-            this._onScreenSaverActiveChanged(isActive);
-        }));
-        this._screenSaverProxy.GetActiveRemote(Lang.bind(this, function(result, err) {
-            if (!err)
-                this._onScreenSaverActiveChanged(result[0]);
-        }));
-
         this._relayout();
     },
 
@@ -597,6 +587,8 @@ const Chrome = new Lang.Class({
                              Lang.bind(this, this._overviewShowing));
         Main.overview.connect('hidden',
                              Lang.bind(this, this._overviewHidden));
+        Main.screenShield.connect('lock-status-changed',
+                                  Lang.bind(this, this._lockStatusChanged));
     },
 
     addActor: function(actor, params) {
@@ -690,16 +682,13 @@ const Chrome = new Lang.Class({
 
     _updateVisibility: function() {
         for (let i = 0; i < this._trackedActors.length; i++) {
+            let actorData = this._trackedActors[i], visible;
             if (!actorData.trackFullscreen)
                 continue;
-
-            let actorData = this._trackedActors[i], visible;
             if (!actorData.isToplevel)
                 continue;
 
-            if (this._screenSaverActive)
-                visible = false;
-            else if (this._inOverview)
+            if (this._inOverview || this._isLocked)
                 visible = true;
             else if (this.findMonitorForActor(actorData.actor).inFullscreen)
                 visible = false;
@@ -721,6 +710,12 @@ const Chrome = new Lang.Class({
         this._queueUpdateRegions();
     },
 
+    _lockStatusChanged: function(shield, locked) {
+        this._isLocked = locked;
+        this._updateVisibility();
+        this._queueUpdateRegions();
+    },
+
     _relayout: function() {
         this._monitors = this._layoutManager.monitors;
         this._primaryMonitor = this._layoutManager.primaryMonitor;
@@ -730,12 +725,6 @@ const Chrome = new Lang.Class({
         this._queueUpdateRegions();
     },
 
-    _onScreenSaverActiveChanged: function(screenSaverActive) {
-        this._screenSaverActive = screenSaverActive;
-        this._updateVisibility();
-        this._queueUpdateRegions();
-    },
-
     _findMonitorForRect: function(x, y, w, h) {
         // First look at what monitor the center of the rectangle is at
         let cx = x + w/2;
diff --git a/js/ui/userMenu.js b/js/ui/userMenu.js
index eea4146..ed6f9f7 100644
--- a/js/ui/userMenu.js
+++ b/js/ui/userMenu.js
@@ -16,7 +16,6 @@ const GnomeSession = imports.misc.gnomeSession;
 const Main = imports.ui.main;
 const PanelMenu = imports.ui.panelMenu;
 const PopupMenu = imports.ui.popupMenu;
-const ScreenSaver = imports.misc.screenSaver;
 const Util = imports.misc.util;
 
 const LOCKDOWN_SCHEMA = 'org.gnome.desktop.lockdown';
@@ -451,7 +450,6 @@ const UserMenuButton = new Lang.Class({
         this._accountMgr = Tp.AccountManager.dup();
 
         this._upClient = new UPowerGlib.Client();
-        this._screenSaverProxy = new ScreenSaver.ScreenSaverProxy();
         this.actor.connect('destroy', Lang.bind(this, this._onDestroy));
 
         this._iconBox = new St.Bin();
@@ -769,16 +767,13 @@ const UserMenuButton = new Lang.Class({
 
     _onLockScreenActivate: function() {
         Main.overview.hide();
-        this._screenSaverProxy.LockRemote();
+        Main.screenShield.lock();
     },
 
     _onLoginScreenActivate: function() {
         Main.overview.hide();
-        // Ensure we only move to GDM after the screensaver has activated; in some
-        // OS configurations, the X server may block event processing on VT switch
-        this._screenSaverProxy.SetActiveRemote(true, Lang.bind(this, function() {
-            this._userManager.goto_login_session();
-        }));
+        Main.screenShield.lock();
+        this._userManager.goto_login_session();
     },
 
     _onQuitSessionActivate: function() {
@@ -800,10 +795,8 @@ const UserMenuButton = new Lang.Class({
             this._suspendOrPowerOffItem.state == PopupMenu.PopupAlternatingMenuItemState.DEFAULT) {
             this._session.ShutdownRemote();
         } else {
-            // Ensure we only suspend after locking the screen
-            this._screenSaverProxy.LockRemote(Lang.bind(this, function() {
-                this._upClient.suspend_sync(null);
-            }));
+            Main.screenShield.lock();
+            this._upClient.suspend_sync(null);
         }
     }
 });



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]