Blame SOURCES/introspect-backports.patch

1be690
From 781dfcf6ce7168c6b116d58df5f1c67291a7b513 Mon Sep 17 00:00:00 2001
1be690
From: =?UTF-8?q?Florian=20M=C3=BCllner?= <fmuellner@gnome.org>
1be690
Date: Thu, 16 May 2019 00:57:27 +0200
1be690
Subject: [PATCH 01/11] introspect: Include `sandboxed-app-id` as well
1be690
1be690
App IDs in gnome-shell don't match AppStream, Flatpak or Snap IDs. For the
1be690
desktop portal, the latter two are more relevant, so include it in the
1be690
returned information.
1be690
1be690
https://gitlab.gnome.org/GNOME/gnome-shell/issues/1289
1be690
---
1be690
 js/misc/introspect.js | 14 ++++++++++++++
1be690
 1 file changed, 14 insertions(+)
1be690
1be690
diff --git a/js/misc/introspect.js b/js/misc/introspect.js
1be690
index f7a7f2fe6..1e8300d0a 100644
1be690
--- a/js/misc/introspect.js
1be690
+++ b/js/misc/introspect.js
1be690
@@ -55,6 +55,11 @@ var IntrospectService = class {
1be690
        return APP_WHITELIST.includes(sender);
1be690
     }
1be690
 
1be690
+    _getSandboxedAppId(app) {
1be690
+        let ids = app.get_windows().map(w => w.get_sandboxed_app_id());
1be690
+        return ids.find(id => id != null);
1be690
+    }
1be690
+
1be690
     _syncRunningApplications() {
1be690
         let tracker = Shell.WindowTracker.get_default();
1be690
         let apps = this._appSystem.get_running();
1be690
@@ -76,6 +81,10 @@ var IntrospectService = class {
1be690
                 newActiveApplication = app.get_id();
1be690
             }
1be690
 
1be690
+            let sandboxedAppId = this._getSandboxedAppId(app);
1be690
+            if (sandboxedAppId)
1be690
+                appInfo['sandboxed-app-id'] = new GLib.Variant('s', sandboxedAppId);
1be690
+
1be690
             newRunningApplications[app.get_id()] = appInfo;
1be690
         }
1be690
 
1be690
@@ -137,6 +146,7 @@ var IntrospectService = class {
1be690
                 let frameRect = window.get_frame_rect();
1be690
                 let title = window.get_title();
1be690
                 let wmClass = window.get_wm_class();
1be690
+                let sandboxedAppId = window.get_sandboxed_app_id();
1be690
 
1be690
                 windowsList[windowId] = {
1be690
                     'app-id': GLib.Variant.new('s', app.get_id()),
1be690
@@ -153,6 +163,10 @@ var IntrospectService = class {
1be690
 
1be690
                 if (wmClass != null)
1be690
                     windowsList[windowId]['wm-class'] = GLib.Variant.new('s', wmClass);
1be690
+
1be690
+                if (sandboxedAppId != null)
1be690
+                    windowsList[windowId]['sandboxed-app-id'] =
1be690
+                        GLib.Variant.new('s', sandboxedAppId);
1be690
             }
1be690
         }
1be690
         invocation.return_value(new GLib.Variant('(a{ta{sv}})', [windowsList]));
1be690
-- 
1be690
2.26.2
1be690
1be690
1be690
From b0b4fb82c058722e2171d24902ba3855ffe243f3 Mon Sep 17 00:00:00 2001
1be690
From: =?UTF-8?q?Jonas=20=C3=85dahl?= <jadahl@gmail.com>
1be690
Date: Wed, 18 Sep 2019 14:57:48 +0200
1be690
Subject: [PATCH 02/11] introspect: Check whitelist also for
1be690
 GetRunningWindows()
1be690
1be690
Otherwise the xdg-desktop-portal-gtk screen cast widget won't work.
1be690
1be690
https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/732
1be690
---
1be690
 js/misc/introspect.js | 3 ++-
1be690
 1 file changed, 2 insertions(+), 1 deletion(-)
1be690
1be690
diff --git a/js/misc/introspect.js b/js/misc/introspect.js
1be690
index 1e8300d0a..cee6409a8 100644
1be690
--- a/js/misc/introspect.js
1be690
+++ b/js/misc/introspect.js
1be690
@@ -128,7 +128,8 @@ var IntrospectService = class {
1be690
         let apps = this._appSystem.get_running();
1be690
         let windowsList = {};
1be690
 
1be690
-        if (!this._isIntrospectEnabled()) {
1be690
+        if (!this._isIntrospectEnabled() &&
1be690
+            !this._isSenderWhitelisted(invocation.get_sender())) {
1be690
             invocation.return_error_literal(Gio.DBusError,
1be690
                                             Gio.DBusError.ACCESS_DENIED,
1be690
                                             'App introspection not allowed');
1be690
-- 
1be690
2.26.2
1be690
1be690
1be690
From 23556e03db3743ddf478a3c1bbb64946c687afdf Mon Sep 17 00:00:00 2001
1be690
From: =?UTF-8?q?Florian=20M=C3=BCllner?= <fmuellner@gnome.org>
1be690
Date: Mon, 25 Nov 2019 19:44:10 +0100
1be690
Subject: [PATCH 03/11] introspect: Fix whitelist check
1be690
1be690
The whitelist is a list of well-known D-Bus names, which we then search
1be690
for the unique name we get from the method invocation - unsuccesfully.
1be690
1be690
Fix this by watching the bus for any name in the whitelist in order
1be690
to maintain a map from wel-known to unique name that we can use for
1be690
matching.
1be690
1be690
https://gitlab.gnome.org/GNOME/gnome-shell/issues/1916
1be690
---
1be690
 js/misc/introspect.js | 11 ++++++++++-
1be690
 1 file changed, 10 insertions(+), 1 deletion(-)
1be690
1be690
diff --git a/js/misc/introspect.js b/js/misc/introspect.js
1be690
index cee6409a8..f14eabfad 100644
1be690
--- a/js/misc/introspect.js
1be690
+++ b/js/misc/introspect.js
1be690
@@ -39,6 +39,15 @@ var IntrospectService = class {
1be690
                         });
1be690
 
1be690
         this._syncRunningApplications();
1be690
+
1be690
+        this._whitelistMap = new Map();
1be690
+        APP_WHITELIST.forEach(appName => {
1be690
+            Gio.DBus.watch_name(Gio.BusType.SESSION,
1be690
+                appName,
1be690
+                Gio.BusNameWatcherFlags.NONE,
1be690
+                (conn, name, owner) => this._whitelistMap.set(name, owner),
1be690
+                (conn, name) => this._whitelistMap.delete(name));
1be690
+        });
1be690
     }
1be690
 
1be690
     _isStandaloneApp(app) {
1be690
@@ -52,7 +61,7 @@ var IntrospectService = class {
1be690
     }
1be690
 
1be690
     _isSenderWhitelisted(sender) {
1be690
-       return APP_WHITELIST.includes(sender);
1be690
+        return [...this._whitelistMap.values()].includes(sender);
1be690
     }
1be690
 
1be690
     _getSandboxedAppId(app) {
1be690
-- 
1be690
2.26.2
1be690
1be690
1be690
From 1a6275add6d214df958ed8a06c097445bef021bc Mon Sep 17 00:00:00 2001
1be690
From: =?UTF-8?q?Jonas=20=C3=85dahl?= <jadahl@gmail.com>
1be690
Date: Wed, 25 Sep 2019 20:36:28 +0200
1be690
Subject: [PATCH 04/11] introspect: Add helper to check method call permission
1be690
1be690
https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/757
1be690
---
1be690
 js/misc/introspect.js | 16 ++++++++++++----
1be690
 1 file changed, 12 insertions(+), 4 deletions(-)
1be690
1be690
diff --git a/js/misc/introspect.js b/js/misc/introspect.js
1be690
index f14eabfad..6186754cd 100644
1be690
--- a/js/misc/introspect.js
1be690
+++ b/js/misc/introspect.js
1be690
@@ -120,9 +120,18 @@ var IntrospectService = class {
1be690
                 type == Meta.WindowType.UTILITY);
1be690
     }
1be690
 
1be690
+    _isInvocationAllowed(invocation) {
1be690
+        if (this._isIntrospectEnabled())
1be690
+            return true;
1be690
+
1be690
+        if (this._isSenderWhitelisted(invocation.get_sender()))
1be690
+            return true;
1be690
+
1be690
+        return false;
1be690
+    }
1be690
+
1be690
     GetRunningApplicationsAsync(params, invocation) {
1be690
-        if (!this._isIntrospectEnabled() &&
1be690
-            !this._isSenderWhitelisted(invocation.get_sender())) {
1be690
+        if (!this._isInvocationAllowed(invocation)) {
1be690
             invocation.return_error_literal(Gio.DBusError,
1be690
                                             Gio.DBusError.ACCESS_DENIED,
1be690
                                             'App introspection not allowed');
1be690
@@ -137,8 +146,7 @@ var IntrospectService = class {
1be690
         let apps = this._appSystem.get_running();
1be690
         let windowsList = {};
1be690
 
1be690
-        if (!this._isIntrospectEnabled() &&
1be690
-            !this._isSenderWhitelisted(invocation.get_sender())) {
1be690
+        if (!this._isInvocationAllowed(invocation)) {
1be690
             invocation.return_error_literal(Gio.DBusError,
1be690
                                             Gio.DBusError.ACCESS_DENIED,
1be690
                                             'App introspection not allowed');
1be690
-- 
1be690
2.26.2
1be690
1be690
1be690
From f578dc01cf774faa4504a4d258cc0e82060d988b Mon Sep 17 00:00:00 2001
1be690
From: =?UTF-8?q?Jonas=20=C3=85dahl?= <jadahl@gmail.com>
1be690
Date: Tue, 1 Oct 2019 11:55:33 +0200
1be690
Subject: [PATCH 05/11] shell-util: Add API to check for X11 extensions
1be690
1be690
Will be used to disable animations when running inside Xvnc. This was
1be690
done in gsd-xsettings before.
1be690
1be690
https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/757
1be690
---
1be690
 src/shell-util.c | 26 ++++++++++++++++++++++++++
1be690
 src/shell-util.h |  3 +++
1be690
 2 files changed, 29 insertions(+)
1be690
1be690
diff --git a/src/shell-util.c b/src/shell-util.c
1be690
index 31bb18e70..fa3fc08c8 100644
1be690
--- a/src/shell-util.c
1be690
+++ b/src/shell-util.c
1be690
@@ -21,6 +21,8 @@
1be690
 #include <gtk/gtk.h>
1be690
 #include <gdk-pixbuf/gdk-pixbuf.h>
1be690
 #include <meta/meta-shaped-texture.h>
1be690
+#include <meta/display.h>
1be690
+#include <meta/meta-x11-display.h>
1be690
 
1be690
 #include <locale.h>
1be690
 #ifdef HAVE__NL_TIME_FIRST_WEEKDAY
1be690
@@ -613,3 +615,27 @@ shell_util_check_cloexec_fds (void)
1be690
   fdwalk (check_cloexec, NULL);
1be690
   g_info ("Open fd CLOEXEC check complete");
1be690
 }
1be690
+
1be690
+/**
1be690
+ * shell_util_has_x11_display_extension:
1be690
+ * @display: A #MetaDisplay
1be690
+ * @extension: An X11 extension
1be690
+ *
1be690
+ * If the corresponding X11 display provides the passed extension, return %TRUE,
1be690
+ * otherwise %FALSE. If there is no X11 display, %FALSE is passed.
1be690
+ */
1be690
+gboolean
1be690
+shell_util_has_x11_display_extension (MetaDisplay *display,
1be690
+                                      const char  *extension)
1be690
+{
1be690
+  MetaX11Display *x11_display;
1be690
+  Display *xdisplay;
1be690
+  int op, event, error;
1be690
+
1be690
+  x11_display = meta_display_get_x11_display (display);
1be690
+  if (!x11_display)
1be690
+    return FALSE;
1be690
+
1be690
+  xdisplay = meta_x11_display_get_xdisplay (x11_display);
1be690
+  return XQueryExtension (xdisplay, extension, &op, &event, &error);
1be690
+}
1be690
diff --git a/src/shell-util.h b/src/shell-util.h
1be690
index 6904f43bc..02b8404e9 100644
1be690
--- a/src/shell-util.h
1be690
+++ b/src/shell-util.h
1be690
@@ -59,6 +59,9 @@ cairo_surface_t * shell_util_composite_capture_images (ClutterCapture  *captures
1be690
 
1be690
 void shell_util_check_cloexec_fds (void);
1be690
 
1be690
+gboolean shell_util_has_x11_display_extension (MetaDisplay *display,
1be690
+                                               const char  *extension);
1be690
+
1be690
 G_END_DECLS
1be690
 
1be690
 #endif /* __SHELL_UTIL_H__ */
1be690
-- 
1be690
2.26.2
1be690
1be690
1be690
From 48ee79bb7b48c7e93e77e35629f21bbdbabc253f Mon Sep 17 00:00:00 2001
1be690
From: =?UTF-8?q?Jonas=20=C3=85dahl?= <jadahl@gmail.com>
1be690
Date: Tue, 1 Oct 2019 11:56:34 +0200
1be690
Subject: [PATCH 06/11] st/settings: Add API to inhibit animations
1be690
1be690
There may be situations where we shouldn't enable animations. Make it
1be690
possible for the Shell to decide when there are such situations and in
1be690
when needed inhibit animations.
1be690
1be690
https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/757
1be690
---
1be690
 src/st/st-settings.c | 38 +++++++++++++++++++++++++++++++++++++-
1be690
 src/st/st-settings.h |  4 ++++
1be690
 2 files changed, 41 insertions(+), 1 deletion(-)
1be690
1be690
diff --git a/src/st/st-settings.c b/src/st/st-settings.c
1be690
index 17f2c466e..ebfd28480 100644
1be690
--- a/src/st/st-settings.c
1be690
+++ b/src/st/st-settings.c
1be690
@@ -54,6 +54,7 @@ struct _StSettings
1be690
 
1be690
   gchar *gtk_theme;
1be690
   gchar *gtk_icon_theme;
1be690
+  int inhibit_animations_count;
1be690
   gboolean enable_animations;
1be690
   gboolean primary_paste;
1be690
   gboolean magnifier_active;
1be690
@@ -62,6 +63,41 @@ struct _StSettings
1be690
 
1be690
 G_DEFINE_TYPE (StSettings, st_settings, G_TYPE_OBJECT)
1be690
 
1be690
+static gboolean
1be690
+get_enable_animations (StSettings *settings)
1be690
+{
1be690
+  if (settings->inhibit_animations_count > 0)
1be690
+    return FALSE;
1be690
+  else
1be690
+    return settings->enable_animations;
1be690
+}
1be690
+
1be690
+void
1be690
+st_settings_inhibit_animations (StSettings *settings)
1be690
+{
1be690
+  gboolean enable_animations;
1be690
+
1be690
+  enable_animations = get_enable_animations (settings);
1be690
+  settings->inhibit_animations_count++;
1be690
+
1be690
+  if (enable_animations != get_enable_animations (settings))
1be690
+    g_object_notify_by_pspec (G_OBJECT (settings),
1be690
+                              props[PROP_ENABLE_ANIMATIONS]);
1be690
+}
1be690
+
1be690
+void
1be690
+st_settings_uninhibit_animations (StSettings *settings)
1be690
+{
1be690
+  gboolean enable_animations;
1be690
+
1be690
+  enable_animations = get_enable_animations (settings);
1be690
+  settings->inhibit_animations_count--;
1be690
+
1be690
+  if (enable_animations != get_enable_animations (settings))
1be690
+    g_object_notify_by_pspec (G_OBJECT (settings),
1be690
+                              props[PROP_ENABLE_ANIMATIONS]);
1be690
+}
1be690
+
1be690
 static void
1be690
 st_settings_finalize (GObject *object)
1be690
 {
1be690
@@ -95,7 +131,7 @@ st_settings_get_property (GObject    *object,
1be690
   switch (prop_id)
1be690
     {
1be690
     case PROP_ENABLE_ANIMATIONS:
1be690
-      g_value_set_boolean (value, settings->enable_animations);
1be690
+      g_value_set_boolean (value, get_enable_animations (settings));
1be690
       break;
1be690
     case PROP_PRIMARY_PASTE:
1be690
       g_value_set_boolean (value, settings->primary_paste);
1be690
diff --git a/src/st/st-settings.h b/src/st/st-settings.h
1be690
index c2c4fa23e..8b2549469 100644
1be690
--- a/src/st/st-settings.h
1be690
+++ b/src/st/st-settings.h
1be690
@@ -33,6 +33,10 @@ G_DECLARE_FINAL_TYPE (StSettings, st_settings, ST, SETTINGS, GObject)
1be690
 
1be690
 StSettings * st_settings_get (void);
1be690
 
1be690
+void st_settings_inhibit_animations (StSettings *settings);
1be690
+
1be690
+void st_settings_uninhibit_animations (StSettings *settings);
1be690
+
1be690
 G_END_DECLS
1be690
 
1be690
 #endif /* __ST_SETTINGS_H__ */
1be690
-- 
1be690
2.26.2
1be690
1be690
1be690
From 80025388c44296b629c8f24ea673d77ffc4efc67 Mon Sep 17 00:00:00 2001
1be690
From: =?UTF-8?q?Jonas=20=C3=85dahl?= <jadahl@gmail.com>
1be690
Date: Tue, 1 Oct 2019 12:02:31 +0200
1be690
Subject: [PATCH 07/11] main: Inhibit animations when software rendered
1be690
1be690
This was previously decided by gsd-xsettings.
1be690
1be690
https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/757
1be690
---
1be690
 js/ui/main.js | 12 ++++++++++++
1be690
 1 file changed, 12 insertions(+)
1be690
1be690
diff --git a/js/ui/main.js b/js/ui/main.js
1be690
index 978f83c3f..c3230ff03 100644
1be690
--- a/js/ui/main.js
1be690
+++ b/js/ui/main.js
1be690
@@ -147,6 +147,8 @@ function _initializeUI() {
1be690
     _loadOskLayouts();
1be690
     _loadDefaultStylesheet();
1be690
 
1be690
+    new AnimationsSettings();
1be690
+
1be690
     // Setup the stage hierarchy early
1be690
     layoutManager = new Layout.LayoutManager();
1be690
 
1be690
@@ -723,3 +725,13 @@ function showRestartMessage(message) {
1be690
     let restartMessage = new RestartMessage(message);
1be690
     restartMessage.open();
1be690
 }
1be690
+
1be690
+var AnimationsSettings = class {
1be690
+    constructor() {
1be690
+        let backend = Meta.get_backend();
1be690
+        if (!backend.is_rendering_hardware_accelerated()) {
1be690
+            St.Settings.get().inhibit_animations();
1be690
+            return;
1be690
+        }
1be690
+    }
1be690
+};
1be690
-- 
1be690
2.26.2
1be690
1be690
1be690
From 788ecb60e35d8a369f0747813f37e8b1ca27cb87 Mon Sep 17 00:00:00 2001
1be690
From: =?UTF-8?q?Jonas=20=C3=85dahl?= <jadahl@gmail.com>
1be690
Date: Tue, 1 Oct 2019 12:03:52 +0200
1be690
Subject: [PATCH 08/11] main: Inhibit animations if X server advertises
1be690
 VNC-EXTENSION
1be690
1be690
This was previously done by gsd-xsettings to disable animations when
1be690
running in Xvnc.
1be690
1be690
https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/757
1be690
---
1be690
 js/ui/main.js | 7 +++++++
1be690
 1 file changed, 7 insertions(+)
1be690
1be690
diff --git a/js/ui/main.js b/js/ui/main.js
1be690
index c3230ff03..ae7c3ffd0 100644
1be690
--- a/js/ui/main.js
1be690
+++ b/js/ui/main.js
1be690
@@ -733,5 +733,12 @@ var AnimationsSettings = class {
1be690
             St.Settings.get().inhibit_animations();
1be690
             return;
1be690
         }
1be690
+
1be690
+        let isXvnc = Shell.util_has_x11_display_extension(
1be690
+            global.display, 'VNC-EXTENSION');
1be690
+        if (isXvnc) {
1be690
+            St.Settings.get().inhibit_animations();
1be690
+            return;
1be690
+        }
1be690
     }
1be690
 };
1be690
-- 
1be690
2.26.2
1be690
1be690
1be690
From 1da5a7ce4cf0b95b96dd50b62ac6c1380fd88cb1 Mon Sep 17 00:00:00 2001
1be690
From: =?UTF-8?q?Jonas=20=C3=85dahl?= <jadahl@gmail.com>
1be690
Date: Tue, 1 Oct 2019 12:04:52 +0200
1be690
Subject: [PATCH 09/11] main: Inhibit animations when there is a remote desktop
1be690
 session
1be690
1be690
If a remote desktop session asks for animations to be disabled, inhibit
1be690
animations while the session is active.
1be690
1be690
https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/757
1be690
---
1be690
 js/ui/main.js | 26 ++++++++++++++++++++++++++
1be690
 1 file changed, 26 insertions(+)
1be690
1be690
diff --git a/js/ui/main.js b/js/ui/main.js
1be690
index ae7c3ffd0..1203b3c39 100644
1be690
--- a/js/ui/main.js
1be690
+++ b/js/ui/main.js
1be690
@@ -740,5 +740,31 @@ var AnimationsSettings = class {
1be690
             St.Settings.get().inhibit_animations();
1be690
             return;
1be690
         }
1be690
+
1be690
+        let remoteAccessController = backend.get_remote_access_controller();
1be690
+        if (!remoteAccessController)
1be690
+            return;
1be690
+
1be690
+        this._handles = new Set();
1be690
+        remoteAccessController.connect('new-handle',
1be690
+            (_, handle) => this._onNewRemoteAccessHandle(handle));
1be690
+    }
1be690
+
1be690
+    _onRemoteAccessHandleStopped(handle) {
1be690
+        let settings = St.Settings.get();
1be690
+
1be690
+        settings.uninhibit_animations();
1be690
+        this._handles.delete(handle);
1be690
+    }
1be690
+
1be690
+    _onNewRemoteAccessHandle(handle) {
1be690
+        if (!handle.get_disable_animations())
1be690
+            return;
1be690
+
1be690
+        let settings = St.Settings.get();
1be690
+
1be690
+        settings.inhibit_animations();
1be690
+        this._handles.add(handle);
1be690
+        handle.connect('stopped', this._onRemoteAccessHandleStopped.bind(this));
1be690
     }
1be690
 };
1be690
-- 
1be690
2.26.2
1be690
1be690
1be690
From ebfd46341a2d7a6338386e4be4a2807a6bc6e63c Mon Sep 17 00:00:00 2001
1be690
From: =?UTF-8?q?Jonas=20=C3=85dahl?= <jadahl@gmail.com>
1be690
Date: Tue, 1 Oct 2019 12:06:13 +0200
1be690
Subject: [PATCH 10/11] introspect: Rename variable
1be690
1be690
It was too generic, and would conflict with a StSettings variable.
1be690
1be690
https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/757
1be690
---
1be690
 js/misc/introspect.js | 6 ++++--
1be690
 1 file changed, 4 insertions(+), 2 deletions(-)
1be690
1be690
diff --git a/js/misc/introspect.js b/js/misc/introspect.js
1be690
index 6186754cd..8e68a7e4f 100644
1be690
--- a/js/misc/introspect.js
1be690
+++ b/js/misc/introspect.js
1be690
@@ -29,7 +29,9 @@ var IntrospectService = class {
1be690
                                     this._syncRunningApplications();
1be690
                                 });
1be690
 
1be690
-        this._settings = new Gio.Settings({ schema_id: INTROSPECT_SCHEMA });
1be690
+        this._introspectSettings = new Gio.Settings({
1be690
+            schema_id: INTROSPECT_SCHEMA,
1be690
+        });
1be690
 
1be690
         let tracker = Shell.WindowTracker.get_default();
1be690
         tracker.connect('notify::focus-app',
1be690
@@ -57,7 +59,7 @@ var IntrospectService = class {
1be690
     }
1be690
 
1be690
     _isIntrospectEnabled() {
1be690
-       return this._settings.get_boolean(INTROSPECT_KEY);
1be690
+        return this._introspectSettings.get_boolean(INTROSPECT_KEY);
1be690
     }
1be690
 
1be690
     _isSenderWhitelisted(sender) {
1be690
-- 
1be690
2.26.2
1be690
1be690
1be690
From 343e7792fc84c296b331c3fcb142ed79d2ce9bd5 Mon Sep 17 00:00:00 2001
1be690
From: =?UTF-8?q?Jonas=20=C3=85dahl?= <jadahl@gmail.com>
1be690
Date: Tue, 1 Oct 2019 12:07:03 +0200
1be690
Subject: [PATCH 11/11] introspect: Add AnimationsEnabled property
1be690
1be690
While the gsetting is available for all who needs it, the Shell might
1be690
override it given various hueristics. Expose the decision made by the
1be690
Shell via a new property.
1be690
1be690
Intended to be used by gsd-xsettings as well as xdg-desktop-portal-gtk.
1be690
1be690
This also add a version property to the API, so that semi external
1be690
services (xdg-desktop-portal-gtk) can detect what API is expected to be
1be690
present.
1be690
1be690
https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/757
1be690
---
1be690
 .../org.gnome.Shell.Introspect.xml            | 14 ++++++++++
1be690
 js/misc/introspect.js                         | 27 ++++++++++++++++++-
1be690
 2 files changed, 40 insertions(+), 1 deletion(-)
1be690
1be690
diff --git a/data/dbus-interfaces/org.gnome.Shell.Introspect.xml b/data/dbus-interfaces/org.gnome.Shell.Introspect.xml
1be690
index 9508681af..d71f2414b 100644
1be690
--- a/data/dbus-interfaces/org.gnome.Shell.Introspect.xml
1be690
+++ b/data/dbus-interfaces/org.gnome.Shell.Introspect.xml
1be690
@@ -57,5 +57,19 @@
1be690
     <method name="GetWindows">
1be690
       <arg name="windows" direction="out" type="a{ta{sv}}" />
1be690
     </method>
1be690
+
1be690
+    
1be690
+       AnimationsEnabled:
1be690
+       @short_description: Whether the shell animations are enabled
1be690
+
1be690
+       By default determined by the org.gnome.desktop.interface enable-animations
1be690
+       gsetting, but may be overridden, e.g. if there is an active screen cast or
1be690
+       remote desktop session that asked for animations to be disabled.
1be690
+
1be690
+       Since: 2
1be690
+    -->
1be690
+    <property name="AnimationsEnabled" type="b" access="read"/>
1be690
+
1be690
+    <property name="version" type="u" access="read"/>
1be690
   </interface>
1be690
 </node>
1be690
diff --git a/js/misc/introspect.js b/js/misc/introspect.js
1be690
index 8e68a7e4f..7c62113e5 100644
1be690
--- a/js/misc/introspect.js
1be690
+++ b/js/misc/introspect.js
1be690
@@ -1,9 +1,11 @@
1be690
-const { Gio, GLib, Meta, Shell } = imports.gi;
1be690
+const { Gio, GLib, Meta, Shell, St } = imports.gi;
1be690
 
1be690
 const INTROSPECT_SCHEMA = 'org.gnome.shell';
1be690
 const INTROSPECT_KEY = 'introspect';
1be690
 const APP_WHITELIST = ['org.freedesktop.impl.portal.desktop.gtk'];
1be690
 
1be690
+const INTROSPECT_DBUS_API_VERSION = 2;
1be690
+
1be690
 const { loadInterfaceXML } = imports.misc.fileUtils;
1be690
 
1be690
 const IntrospectDBusIface = loadInterfaceXML('org.gnome.Shell.Introspect');
1be690
@@ -21,6 +23,7 @@ var IntrospectService = class {
1be690
         this._runningApplicationsDirty = true;
1be690
         this._activeApplication = null;
1be690
         this._activeApplicationDirty = true;
1be690
+        this._animationsEnabled = true;
1be690
 
1be690
         this._appSystem = Shell.AppSystem.get_default();
1be690
         this._appSystem.connect('app-state-changed',
1be690
@@ -50,6 +53,11 @@ var IntrospectService = class {
1be690
                 (conn, name, owner) => this._whitelistMap.set(name, owner),
1be690
                 (conn, name) => this._whitelistMap.delete(name));
1be690
         });
1be690
+
1be690
+        this._settings = St.Settings.get();
1be690
+        this._settings.connect('notify::enable-animations',
1be690
+            this._syncAnimationsEnabled.bind(this));
1be690
+        this._syncAnimationsEnabled();
1be690
     }
1be690
 
1be690
     _isStandaloneApp(app) {
1be690
@@ -191,4 +199,21 @@ var IntrospectService = class {
1be690
         }
1be690
         invocation.return_value(new GLib.Variant('(a{ta{sv}})', [windowsList]));
1be690
     }
1be690
+
1be690
+    _syncAnimationsEnabled() {
1be690
+        let wasAnimationsEnabled = this._animationsEnabled;
1be690
+        this._animationsEnabled = this._settings.enable_animations;
1be690
+        if (wasAnimationsEnabled !== this._animationsEnabled) {
1be690
+            let variant = new GLib.Variant('b', this._animationsEnabled);
1be690
+            this._dbusImpl.emit_property_changed('AnimationsEnabled', variant);
1be690
+        }
1be690
+    }
1be690
+
1be690
+    get AnimationsEnabled() {
1be690
+        return this._animationsEnabled;
1be690
+    }
1be690
+
1be690
+    get version() {
1be690
+        return INTROSPECT_DBUS_API_VERSION;
1be690
+    }
1be690
 };
1be690
-- 
1be690
2.26.2
1be690