[gnome-shell] remoteAccess: Hide indicator after a timeout
- From: Marge Bot <marge-bot src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] remoteAccess: Hide indicator after a timeout
- Date: Fri, 4 Mar 2022 22:15:35 +0000 (UTC)
commit f979ebcb1a43ca120cb595909f724f813fcdece3
Author: Jonas Ã…dahl <jadahl gmail com>
Date: Thu Jan 27 10:48:59 2022 +0100
remoteAccess: Hide indicator after a timeout
In order to make very short screen capture sessions more visible, let
the indicator remain visible, but a bit greyed out, for some seconds.
This makes it more obvious something was just capturing the screen.
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2132>
js/ui/status/remoteAccess.js | 35 ++++++++++++++++++++++++++++++++++-
1 file changed, 34 insertions(+), 1 deletion(-)
---
diff --git a/js/ui/status/remoteAccess.js b/js/ui/status/remoteAccess.js
index 992215ad3c..a3dfd652c2 100644
--- a/js/ui/status/remoteAccess.js
+++ b/js/ui/status/remoteAccess.js
@@ -7,6 +7,9 @@ const Main = imports.ui.main;
const PanelMenu = imports.ui.panelMenu;
const PopupMenu = imports.ui.popupMenu;
+// Minimum amount of time the shared indicator is visible (in micro seconds)
+const MIN_SHARED_INDICATOR_VISIBLE_TIME_US = 5 * GLib.TIME_SPAN_SECOND;
+
var RemoteAccessApplet = GObject.registerClass(
class RemoteAccessApplet extends PanelMenu.SystemIndicator {
_init() {
@@ -32,6 +35,7 @@ class RemoteAccessApplet extends PanelMenu.SystemIndicator {
return;
this._sharedIndicator = this._addIndicator();
+ this._sharedIndicator.visible = false;
this._sharedIndicator.icon_name = 'screen-shared-symbolic';
this._sharedIndicator.add_style_class_name('remote-access-indicator');
@@ -69,12 +73,41 @@ class RemoteAccessApplet extends PanelMenu.SystemIndicator {
return recordingHandles.length > 0;
}
+ _hideSharedIndicator() {
+ this._sharedIndicator.visible = false;
+ delete this._hideSharedIndicatorId;
+ return GLib.SOURCE_REMOVE;
+ }
+
_sync() {
+ if (this._hideSharedIndicatorId) {
+ GLib.source_remove(this._hideSharedIndicatorId);
+ delete this._hideSharedIndicatorId;
+ }
+
if (this._isScreenShared()) {
+ if (!this._sharedIndicator.visible)
+ this._visibleTimeUs = GLib.get_monotonic_time();
this._sharedIndicator.visible = true;
this._sharedItem.visible = true;
} else {
- this._sharedIndicator.visible = false;
+ if (this._sharedIndicator.visible) {
+ const currentTimeUs = GLib.get_monotonic_time();
+ const timeSinceVisibleUs = currentTimeUs - this._visibleTimeUs;
+
+ if (timeSinceVisibleUs >= MIN_SHARED_INDICATOR_VISIBLE_TIME_US) {
+ this._hideSharedIndicator();
+ } else {
+ const timeUntilHideUs =
+ MIN_SHARED_INDICATOR_VISIBLE_TIME_US - timeSinceVisibleUs;
+ this._hideSharedIndicatorId =
+ GLib.timeout_add(
+ GLib.PRIORITY_DEFAULT,
+ timeUntilHideUs / GLib.TIME_SPAN_MILLISECOND,
+ this._hideSharedIndicator.bind(this));
+ }
+ }
+
this._sharedItem.visible = false;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]