appMenu: Support launching on the non-default GPU
Changing the GPU to launch an app on is the last feature from the app context menu that is still missing. Add support for it now, and we are ready for some unifying cleanup! Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1948>
This commit is contained in:
parent
bba799a70c
commit
414ed9128f
@ -60,6 +60,12 @@ var AppMenu = class AppMenu extends PopupMenu.PopupMenu {
|
|||||||
this._actionSection = new PopupMenu.PopupMenuSection();
|
this._actionSection = new PopupMenu.PopupMenuSection();
|
||||||
this.addMenuItem(this._actionSection);
|
this.addMenuItem(this._actionSection);
|
||||||
|
|
||||||
|
this._onGpuMenuItem = this.addAction('', () => {
|
||||||
|
this._animateLaunch();
|
||||||
|
this._app.launch(0, -1, this._getNonDefaultLaunchGpu());
|
||||||
|
Main.overview.hide();
|
||||||
|
});
|
||||||
|
|
||||||
this.addMenuItem(new PopupMenu.PopupSeparatorMenuItem());
|
this.addMenuItem(new PopupMenu.PopupSeparatorMenuItem());
|
||||||
|
|
||||||
this._toggleFavoriteItem = this.addAction('', () => {
|
this._toggleFavoriteItem = this.addAction('', () => {
|
||||||
@ -110,9 +116,14 @@ var AppMenu = class AppMenu extends PopupMenu.PopupMenu {
|
|||||||
global.settings,
|
global.settings,
|
||||||
global.settings.connect('writable-changed::favorite-apps',
|
global.settings.connect('writable-changed::favorite-apps',
|
||||||
() => this._updateFavoriteItem()),
|
() => this._updateFavoriteItem()),
|
||||||
|
], [
|
||||||
|
global,
|
||||||
|
global.connect('notify::switcheroo-control',
|
||||||
|
() => this._updateGpuItem()),
|
||||||
]);
|
]);
|
||||||
this._updateQuitItem();
|
this._updateQuitItem();
|
||||||
this._updateFavoriteItem();
|
this._updateFavoriteItem();
|
||||||
|
this._updateGpuItem();
|
||||||
this._updateDetailsVisibility();
|
this._updateDetailsVisibility();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -122,6 +133,7 @@ var AppMenu = class AppMenu extends PopupMenu.PopupMenu {
|
|||||||
|
|
||||||
this._updateQuitItem();
|
this._updateQuitItem();
|
||||||
this._updateNewWindowItem();
|
this._updateNewWindowItem();
|
||||||
|
this._updateGpuItem();
|
||||||
}
|
}
|
||||||
|
|
||||||
_updateQuitItem() {
|
_updateQuitItem() {
|
||||||
@ -152,6 +164,24 @@ var AppMenu = class AppMenu extends PopupMenu.PopupMenu {
|
|||||||
: _('Add to Favorites');
|
: _('Add to Favorites');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_updateGpuItem() {
|
||||||
|
const proxy = global.get_switcheroo_control();
|
||||||
|
const hasDualGpu = proxy?.get_cached_property('HasDualGpu')?.unpack();
|
||||||
|
|
||||||
|
const showItem =
|
||||||
|
this._app?.state === Shell.AppState.STOPPED && hasDualGpu;
|
||||||
|
|
||||||
|
this._onGpuMenuItem.visible = showItem;
|
||||||
|
|
||||||
|
if (!showItem)
|
||||||
|
return;
|
||||||
|
|
||||||
|
const launchGpu = this._getNonDefaultLaunchGpu();
|
||||||
|
this._onGpuMenuItem.label.text = launchGpu === Shell.AppLaunchGpu.DEFAULT
|
||||||
|
? _('Launch using Integrated Graphics Card')
|
||||||
|
: _('Launch using Discrete Graphics Card');
|
||||||
|
}
|
||||||
|
|
||||||
_updateDetailsVisibility() {
|
_updateDetailsVisibility() {
|
||||||
const sw = this._appSystem.lookup_app('org.gnome.Software.desktop');
|
const sw = this._appSystem.lookup_app('org.gnome.Software.desktop');
|
||||||
this._detailsItem.visible = sw !== null;
|
this._detailsItem.visible = sw !== null;
|
||||||
@ -162,6 +192,12 @@ var AppMenu = class AppMenu extends PopupMenu.PopupMenu {
|
|||||||
this.sourceActor.animateLaunch();
|
this.sourceActor.animateLaunch();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_getNonDefaultLaunchGpu() {
|
||||||
|
return this._app.appInfo.get_boolean('PrefersNonDefaultGPU')
|
||||||
|
? Shell.AppLaunchGpu.DEFAULT
|
||||||
|
: Shell.AppLaunchGpu.DISCRETE;
|
||||||
|
}
|
||||||
|
|
||||||
/** */
|
/** */
|
||||||
destroy() {
|
destroy() {
|
||||||
super.destroy();
|
super.destroy();
|
||||||
@ -220,6 +256,7 @@ var AppMenu = class AppMenu extends PopupMenu.PopupMenu {
|
|||||||
this._updateQuitItem();
|
this._updateQuitItem();
|
||||||
this._updateNewWindowItem();
|
this._updateNewWindowItem();
|
||||||
this._updateFavoriteItem();
|
this._updateFavoriteItem();
|
||||||
|
this._updateGpuItem();
|
||||||
}
|
}
|
||||||
|
|
||||||
_queueUpdateWindowsSection() {
|
_queueUpdateWindowsSection() {
|
||||||
|
Loading…
Reference in New Issue
Block a user