|
|
c7fac9 |
From 8b916620e32ee0b42734dd7896fe5058c8591d81 Mon Sep 17 00:00:00 2001
|
|
|
c7fac9 |
From: =?UTF-8?q?Jonas=20=C3=85dahl?= <jadahl@gmail.com>
|
|
|
c7fac9 |
Date: Fri, 20 Jul 2018 16:50:50 +0200
|
|
|
c7fac9 |
Subject: [PATCH 1/2] Add remote access indication and control
|
|
|
c7fac9 |
|
|
|
c7fac9 |
Add an indicator for when there is something access the display server
|
|
|
c7fac9 |
remotely. This could be 1) remote desktop, 2) screen cast or 3) remote
|
|
|
c7fac9 |
control, but all effectively applications using
|
|
|
c7fac9 |
org.freedesktop.portal.ScreenCast or org.gnome.portal.RemoteDesktop as
|
|
|
c7fac9 |
well as gnome-remote-desktop using the corresponding org.gnome.Mutter
|
|
|
c7fac9 |
APIs directly.
|
|
|
c7fac9 |
|
|
|
c7fac9 |
As it is now, it'll simply show a single icon for when anything is
|
|
|
c7fac9 |
having an active session, and a single action "Turn off" that'll close
|
|
|
c7fac9 |
every active session.
|
|
|
c7fac9 |
|
|
|
c7fac9 |
https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/160
|
|
|
c7fac9 |
---
|
|
|
c7fac9 |
js/js-resources.gresource.xml | 1 +
|
|
|
c7fac9 |
js/ui/panel.js | 3 ++
|
|
|
c7fac9 |
js/ui/status/remoteAccess.js | 80 +++++++++++++++++++++++++++++++++++
|
|
|
c7fac9 |
3 files changed, 84 insertions(+)
|
|
|
c7fac9 |
create mode 100644 js/ui/status/remoteAccess.js
|
|
|
c7fac9 |
|
|
|
c7fac9 |
diff --git a/js/js-resources.gresource.xml b/js/js-resources.gresource.xml
|
|
|
c7fac9 |
index 883b62d66..cc1da4461 100644
|
|
|
c7fac9 |
--- a/js/js-resources.gresource.xml
|
|
|
c7fac9 |
+++ b/js/js-resources.gresource.xml
|
|
|
c7fac9 |
@@ -130,6 +130,7 @@
|
|
|
c7fac9 |
<file>ui/status/rfkill.js</file>
|
|
|
c7fac9 |
<file>ui/status/volume.js</file>
|
|
|
c7fac9 |
<file>ui/status/bluetooth.js</file>
|
|
|
c7fac9 |
+ <file>ui/status/remoteAccess.js</file>
|
|
|
c7fac9 |
<file>ui/status/screencast.js</file>
|
|
|
c7fac9 |
<file>ui/status/system.js</file>
|
|
|
c7fac9 |
<file>ui/status/thunderbolt.js</file>
|
|
|
c7fac9 |
diff --git a/js/ui/panel.js b/js/ui/panel.js
|
|
|
c7fac9 |
index d44ed9fec..53cc445f8 100644
|
|
|
c7fac9 |
--- a/js/ui/panel.js
|
|
|
c7fac9 |
+++ b/js/ui/panel.js
|
|
|
c7fac9 |
@@ -709,6 +709,7 @@ var AggregateMenu = new Lang.Class({
|
|
|
c7fac9 |
this._bluetooth = null;
|
|
|
c7fac9 |
}
|
|
|
c7fac9 |
|
|
|
c7fac9 |
+ this._remoteAccess = new imports.ui.status.remoteAccess.RemoteAccessApplet();
|
|
|
c7fac9 |
this._power = new imports.ui.status.power.Indicator();
|
|
|
c7fac9 |
this._rfkill = new imports.ui.status.rfkill.Indicator();
|
|
|
c7fac9 |
this._volume = new imports.ui.status.volume.Indicator();
|
|
|
c7fac9 |
@@ -729,6 +730,7 @@ var AggregateMenu = new Lang.Class({
|
|
|
c7fac9 |
if (this._bluetooth) {
|
|
|
c7fac9 |
this._indicators.add_child(this._bluetooth.indicators);
|
|
|
c7fac9 |
}
|
|
|
c7fac9 |
+ this._indicators.add_child(this._remoteAccess.indicators);
|
|
|
c7fac9 |
this._indicators.add_child(this._rfkill.indicators);
|
|
|
c7fac9 |
this._indicators.add_child(this._volume.indicators);
|
|
|
c7fac9 |
this._indicators.add_child(this._power.indicators);
|
|
|
c7fac9 |
@@ -743,6 +745,7 @@ var AggregateMenu = new Lang.Class({
|
|
|
c7fac9 |
if (this._bluetooth) {
|
|
|
c7fac9 |
this.menu.addMenuItem(this._bluetooth.menu);
|
|
|
c7fac9 |
}
|
|
|
c7fac9 |
+ this.menu.addMenuItem(this._remoteAccess.menu);
|
|
|
c7fac9 |
this.menu.addMenuItem(this._location.menu);
|
|
|
c7fac9 |
this.menu.addMenuItem(this._rfkill.menu);
|
|
|
c7fac9 |
this.menu.addMenuItem(this._power.menu);
|
|
|
c7fac9 |
diff --git a/js/ui/status/remoteAccess.js b/js/ui/status/remoteAccess.js
|
|
|
c7fac9 |
new file mode 100644
|
|
|
c7fac9 |
index 000000000..ffa334001
|
|
|
c7fac9 |
--- /dev/null
|
|
|
c7fac9 |
+++ b/js/ui/status/remoteAccess.js
|
|
|
c7fac9 |
@@ -0,0 +1,80 @@
|
|
|
c7fac9 |
+// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
|
|
|
c7fac9 |
+
|
|
|
c7fac9 |
+const Lang = imports.lang;
|
|
|
c7fac9 |
+const Meta = imports.gi.Meta;
|
|
|
c7fac9 |
+
|
|
|
c7fac9 |
+const PanelMenu = imports.ui.panelMenu;
|
|
|
c7fac9 |
+const PopupMenu = imports.ui.popupMenu;
|
|
|
c7fac9 |
+
|
|
|
c7fac9 |
+var RemoteAccessApplet = new Lang.Class({
|
|
|
c7fac9 |
+ Name: 'RemoteAccessApplet',
|
|
|
c7fac9 |
+ Extends: PanelMenu.SystemIndicator,
|
|
|
c7fac9 |
+
|
|
|
c7fac9 |
+ _init() {
|
|
|
c7fac9 |
+ this.parent();
|
|
|
c7fac9 |
+
|
|
|
c7fac9 |
+ let backend = Meta.get_backend();
|
|
|
c7fac9 |
+ let controller = backend.get_remote_access_controller();
|
|
|
c7fac9 |
+
|
|
|
c7fac9 |
+ if (!controller)
|
|
|
c7fac9 |
+ return;
|
|
|
c7fac9 |
+
|
|
|
c7fac9 |
+ // We can't possibly know about all types of screen sharing on X11, so
|
|
|
c7fac9 |
+ // showing these controls on X11 might give a false sense of security.
|
|
|
c7fac9 |
+ // Thus, only enable these controls when using Wayland, where we are
|
|
|
c7fac9 |
+ // in control of sharing.
|
|
|
c7fac9 |
+ if (!Meta.is_wayland_compositor())
|
|
|
c7fac9 |
+ return;
|
|
|
c7fac9 |
+
|
|
|
c7fac9 |
+ this._handles = new Set();
|
|
|
c7fac9 |
+ this._indicator = null;
|
|
|
c7fac9 |
+ this._menuSection = null;
|
|
|
c7fac9 |
+
|
|
|
c7fac9 |
+ controller.connect('new-handle', (controller, handle) => {
|
|
|
c7fac9 |
+ this._onNewHandle(handle);
|
|
|
c7fac9 |
+ });
|
|
|
c7fac9 |
+ },
|
|
|
c7fac9 |
+
|
|
|
c7fac9 |
+ _ensureControls() {
|
|
|
c7fac9 |
+ if (this._indicator)
|
|
|
c7fac9 |
+ return;
|
|
|
c7fac9 |
+
|
|
|
c7fac9 |
+ this._indicator = this._addIndicator();
|
|
|
c7fac9 |
+ this._indicator.icon_name = 'screen-shared-symbolic';
|
|
|
c7fac9 |
+ this._item =
|
|
|
c7fac9 |
+ new PopupMenu.PopupSubMenuMenuItem(_("Screen is Being Shared"),
|
|
|
c7fac9 |
+ true);
|
|
|
c7fac9 |
+ this._item.menu.addAction(_("Turn off"),
|
|
|
c7fac9 |
+ () => {
|
|
|
c7fac9 |
+ for (let handle of this._handles)
|
|
|
c7fac9 |
+ handle.stop();
|
|
|
c7fac9 |
+ });
|
|
|
c7fac9 |
+ this._item.icon.icon_name = 'screen-shared-symbolic';
|
|
|
c7fac9 |
+ this.menu.addMenuItem(this._item);
|
|
|
c7fac9 |
+ },
|
|
|
c7fac9 |
+
|
|
|
c7fac9 |
+ _sync() {
|
|
|
c7fac9 |
+ if (this._handles.size == 0) {
|
|
|
c7fac9 |
+ this._indicator.visible = false;
|
|
|
c7fac9 |
+ this._item.actor.visible = false;
|
|
|
c7fac9 |
+ } else {
|
|
|
c7fac9 |
+ this._indicator.visible = true;
|
|
|
c7fac9 |
+ this._item.actor.visible = true;
|
|
|
c7fac9 |
+ }
|
|
|
c7fac9 |
+ },
|
|
|
c7fac9 |
+
|
|
|
c7fac9 |
+ _onStopped(handle) {
|
|
|
c7fac9 |
+ this._handles.delete(handle);
|
|
|
c7fac9 |
+ this._sync();
|
|
|
c7fac9 |
+ },
|
|
|
c7fac9 |
+
|
|
|
c7fac9 |
+ _onNewHandle(handle) {
|
|
|
c7fac9 |
+ this._handles.add(handle);
|
|
|
c7fac9 |
+ handle.connect('stopped', this._onStopped.bind(this));
|
|
|
c7fac9 |
+
|
|
|
c7fac9 |
+ if (this._handles.size == 1) {
|
|
|
c7fac9 |
+ this._ensureControls();
|
|
|
c7fac9 |
+ this._sync();
|
|
|
c7fac9 |
+ }
|
|
|
c7fac9 |
+ },
|
|
|
c7fac9 |
+});
|
|
|
c7fac9 |
--
|
|
|
c7fac9 |
2.17.1
|
|
|
c7fac9 |
|