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



commit 7db0051a6a388dc204d337884dda71babe0422a8
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

 data/gnome-shell-dbus-interfaces.gresource.xml |  1 -
 js/ui/appDisplay.js                            | 29 ++++----------------------
 2 files changed, 4 insertions(+), 26 deletions(-)
---
diff --git a/data/gnome-shell-dbus-interfaces.gresource.xml b/data/gnome-shell-dbus-interfaces.gresource.xml
index db3ef4ac22..8d335124af 100644
--- a/data/gnome-shell-dbus-interfaces.gresource.xml
+++ b/data/gnome-shell-dbus-interfaces.gresource.xml
@@ -2,7 +2,6 @@
 <gresources>
   <gresource prefix="/org/gnome/shell/dbus-interfaces">
     <file preprocess="xml-stripblanks">net.hadess.SensorProxy.xml</file>
-    <file preprocess="xml-stripblanks">net.hadess.SwitcherooControl.xml</file>
     <file preprocess="xml-stripblanks">org.freedesktop.Application.xml</file>
     <file preprocess="xml-stripblanks">org.freedesktop.bolt1.Device.xml</file>
     <file preprocess="xml-stripblanks">org.freedesktop.bolt1.Manager.xml</file>
diff --git a/js/ui/appDisplay.js b/js/ui/appDisplay.js
index 99a023fa26..59eaa6e7b5 100644
--- a/js/ui/appDisplay.js
+++ b/js/ui/appDisplay.js
@@ -18,8 +18,6 @@ const Params = imports.misc.params;
 const Util = imports.misc.util;
 const SystemActions = imports.misc.systemActions;
 
-const { loadInterfaceXML } = imports.misc.fileUtils;
-
 var MENU_POPUP_TIMEOUT = 600;
 var MAX_COLUMNS = 6;
 var MIN_COLUMNS = 4;
@@ -46,11 +44,6 @@ const FOLDER_DIALOG_ANIMATION_TIME = 200;
 const OVERSHOOT_THRESHOLD = 20;
 const OVERSHOOT_TIMEOUT = 1000;
 
-const SWITCHEROO_BUS_NAME = 'net.hadess.SwitcherooControl';
-const SWITCHEROO_OBJECT_PATH = '/net/hadess/SwitcherooControl';
-
-const SwitcherooProxyInterface = loadInterfaceXML('net.hadess.SwitcherooControl');
-const SwitcherooProxy = Gio.DBusProxy.makeProxyWrapper(SwitcherooProxyInterface);
 let discreteGpuAvailable = false;
 
 function _getCategories(info) {
@@ -1162,13 +1155,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 +1168,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]