ScreenShield: implement o.g.ScreenSaver.GetActiveTime
Part of the old gnome-screensaver interface, returns the number of seconds that the screensaver has been active for. https://bugzilla.gnome.org/show_bug.cgi?id=686064
This commit is contained in:
parent
d3ba002313
commit
2a8a8065a8
@ -429,6 +429,7 @@ const ScreenShield = new Lang.Class({
|
|||||||
this._isGreeter = false;
|
this._isGreeter = false;
|
||||||
this._isActive = false;
|
this._isActive = false;
|
||||||
this._inUnlockAnimation = false;
|
this._inUnlockAnimation = false;
|
||||||
|
this._activationTime = 0;
|
||||||
|
|
||||||
this._lightbox = new Lightbox.Lightbox(Main.uiGroup,
|
this._lightbox = new Lightbox.Lightbox(Main.uiGroup,
|
||||||
{ inhibitEvents: true,
|
{ inhibitEvents: true,
|
||||||
@ -556,8 +557,12 @@ const ScreenShield = new Lang.Class({
|
|||||||
this._isModal = true;
|
this._isModal = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this._isActive)
|
if (!this._isActive) {
|
||||||
this._lightbox.show();
|
this._lightbox.show();
|
||||||
|
|
||||||
|
if (this._activationTime == 0)
|
||||||
|
this._activationTime = GLib.get_monotonic_time();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
let lightboxWasShown = this._lightbox.shown;
|
let lightboxWasShown = this._lightbox.shown;
|
||||||
this._lightbox.hide();
|
this._lightbox.hide();
|
||||||
@ -774,6 +779,10 @@ const ScreenShield = new Lang.Class({
|
|||||||
return this._isActive;
|
return this._isActive;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
get activationTime() {
|
||||||
|
return this._activationTime;
|
||||||
|
},
|
||||||
|
|
||||||
_tweenUnlocked: function() {
|
_tweenUnlocked: function() {
|
||||||
this._inUnlockAnimation = true;
|
this._inUnlockAnimation = true;
|
||||||
this.unlock();
|
this.unlock();
|
||||||
@ -818,6 +827,7 @@ const ScreenShield = new Lang.Class({
|
|||||||
if (Main.sessionMode.currentMode == 'unlock-dialog')
|
if (Main.sessionMode.currentMode == 'unlock-dialog')
|
||||||
Main.sessionMode.popMode('unlock-dialog');
|
Main.sessionMode.popMode('unlock-dialog');
|
||||||
|
|
||||||
|
this._activationTime = 0;
|
||||||
this._isActive = false;
|
this._isActive = false;
|
||||||
this.emit('lock-status-changed');
|
this.emit('lock-status-changed');
|
||||||
},
|
},
|
||||||
@ -828,6 +838,9 @@ const ScreenShield = new Lang.Class({
|
|||||||
this._isModal = true;
|
this._isModal = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this._activationTime == 0)
|
||||||
|
this._activationTime = GLib.get_monotonic_time();
|
||||||
|
|
||||||
this.actor.show();
|
this.actor.show();
|
||||||
|
|
||||||
if (Main.sessionMode.currentMode != 'unlock-dialog' &&
|
if (Main.sessionMode.currentMode != 'unlock-dialog' &&
|
||||||
|
@ -59,6 +59,9 @@ const ScreenSaverIface = <interface name="org.gnome.ScreenSaver">
|
|||||||
<method name="SetActive">
|
<method name="SetActive">
|
||||||
<arg name="value" direction="in" type="b" />
|
<arg name="value" direction="in" type="b" />
|
||||||
</method>
|
</method>
|
||||||
|
<method name="GetActiveTime">
|
||||||
|
<arg name="value" direction="out" type="u" />
|
||||||
|
</method>
|
||||||
<signal name="ActiveChanged">
|
<signal name="ActiveChanged">
|
||||||
<arg name="new_value" type="b" />
|
<arg name="new_value" type="b" />
|
||||||
</signal>
|
</signal>
|
||||||
@ -373,5 +376,13 @@ const ScreenSaverDBus = new Lang.Class({
|
|||||||
|
|
||||||
GetActive: function() {
|
GetActive: function() {
|
||||||
return this._screenShield.locked;
|
return this._screenShield.locked;
|
||||||
}
|
},
|
||||||
|
|
||||||
|
GetActiveTime: function() {
|
||||||
|
let started = this._screenShield.activationTime;
|
||||||
|
if (started > 0)
|
||||||
|
return Math.floor((GLib.get_monotonic_time() - started) / 1000000);
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user