[gnome-shell/wip/hadess/always-launch-discrete-gpu: 3/3] appDisplay: Respect X-KDE-RunOnDiscreteGpu appInfo property



commit ade0056d1fb1c30dc524d677f4fa9a456a7d457d
Author: Bastien Nocera <hadess hadess net>
Date:   Mon Oct 21 12:55:38 2019 +0200

    appDisplay: Respect X-KDE-RunOnDiscreteGpu appInfo property
    
    When X-KDE-RunOnDiscreteGpu is set in the application's .desktop file,
    launch the application on the discrete GPU if available, and offer to
    launch on the integrated GPU otherwise.
    
    Closes: #1804

 js/ui/appDisplay.js | 31 ++++++++++++++++++++++++-------
 1 file changed, 24 insertions(+), 7 deletions(-)
---
diff --git a/js/ui/appDisplay.js b/js/ui/appDisplay.js
index d79c9b54b6..b6b6ecdecf 100644
--- a/js/ui/appDisplay.js
+++ b/js/ui/appDisplay.js
@@ -2513,14 +2513,24 @@ var AppIconMenu = class AppIconMenu extends PopupMenu.PopupMenu {
                 this._appendSeparator();
             }
 
+            let wantsDiscreteGpu = appInfo.get_boolean("X-KDE-RunOnDiscreteGpu");
             if (discreteGpuAvailable &&
                 this._source.app.state == Shell.AppState.STOPPED) {
-                this._onDiscreteGpuMenuItem = this._appendMenuItem(_("Launch using Dedicated Graphics 
Card"));
-                this._onDiscreteGpuMenuItem.connect('activate', () => {
-                    this._source.animateLaunch();
-                    this._source.app.launch(0, -1, true);
-                    this.emit('activate-window', null);
-                });
+                if (!wantsDiscreteGpu) {
+                    this._onDiscreteGpuMenuItem = this._appendMenuItem(_("Launch using Dedicated Graphics 
Card"));
+                    this._onDiscreteGpuMenuItem.connect('activate', () => {
+                        this._source.animateLaunch();
+                        this._source.app.launch(0, -1, true);
+                        this.emit('activate-window', null);
+                    });
+                } else {
+                    this._onDiscreteGpuMenuItem = this._appendMenuItem(_("Launch using Integrated Graphics 
Card"));
+                    this._onDiscreteGpuMenuItem.connect('activate', () => {
+                        this._source.animateLaunch();
+                        this._source.app.launch(0, -1, false);
+                        this.emit('activate-window', null);
+                    });
+                }
             }
 
             for (let i = 0; i < actions.length; i++) {
@@ -2530,7 +2540,14 @@ var AppIconMenu = class AppIconMenu extends PopupMenu.PopupMenu {
                     if (action == 'new-window')
                         this._source.animateLaunch();
 
-                    this._source.app.launch_action(action, event.get_time(), -1);
+                    if (discreteGpuAvailable &&
+                        action == 'new-window' &&
+                        this._source.app.state == Shell.AppState.STOPPED) {
+                        let wantsDiscreteGpu = appInfo.get_boolean("X-KDE-RunOnDiscreteGpu");
+                        this._source.app.launch(0, -1, !wantsDiscreteGpu);
+                    } else {
+                        this._source.app.launch_action(action, event.get_time(), -1);
+                    }
                     this.emit('activate-window', null);
                 });
             }


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