[gnome-shell/wip/hadess/PrefersNonDefaultGPU: 4/6] appDisplay: Use global switcheroo-control D-Bus proxy



commit 9f33eee06aab756efc0d543af59a2d92648f7419
Author: Bastien Nocera <hadess hadess net>
Date:   Tue Apr 28 17:37:29 2020 +0200

    appDisplay: Use global switcheroo-control D-Bus proxy
    
    Rather than creating our own.
    
    https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1226

 js/ui/appDisplay.js | 22 ++++------------------
 1 file changed, 4 insertions(+), 18 deletions(-)
---
diff --git a/js/ui/appDisplay.js b/js/ui/appDisplay.js
index 99a023fa26..6fb983d5be 100644
--- a/js/ui/appDisplay.js
+++ b/js/ui/appDisplay.js
@@ -1162,13 +1162,10 @@ class AppDisplay extends St.BoxLayout {
         this._showView(initialView);
         this._updateFrequentVisibility();
 
-        Gio.DBus.system.watch_name(SWITCHEROO_BUS_NAME,
-                                   Gio.BusNameWatcherFlags.NONE,
-                                   this._switcherooProxyAppeared.bind(this),
-                                   () => {
-                                       this._switcherooProxy = null;
-                                       this._updateDiscreteGpuAvailable();
-                                   });
+        this._switcherooNotifyId = global.connect('notify::switcheroo-control', () => {
+            this._switcherooProxy = global.get_switcheroo_control();
+            this._updateDiscreteGpuAvailable();
+        });
     }
 
     _updateDiscreteGpuAvailable() {
@@ -1178,17 +1175,6 @@ class AppDisplay extends St.BoxLayout {
             discreteGpuAvailable = this._switcherooProxy.HasDualGpu;
     }
 
-    _switcherooProxyAppeared() {
-        this._switcherooProxy = new SwitcherooProxy(Gio.DBus.system, SWITCHEROO_BUS_NAME, 
SWITCHEROO_OBJECT_PATH,
-            (proxy, error) => {
-                if (error) {
-                    log(error.message);
-                    return;
-                }
-                this._updateDiscreteGpuAvailable();
-            });
-    }
-
     animate(animationDirection, onComplete) {
         let currentView = this._views.filter(v => v.control.has_style_pseudo_class('checked')).pop().view;
 


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