From 991d9597e0ba42aa972dd4161fa26025e8a0d17b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCllner?= Date: Thu, 12 Aug 2021 21:25:49 +0200 Subject: [PATCH] appMenu: Allow showing the window section for all windows Since commit fd0da9606fd2, we only show the "Open Windows" section if there are at least two windows. That's another subtle difference with the overview context menus, but while limiting the section to a minimum of two windows makes sense where the menu always represents a running app, it is useful to show the section even for single windows in the dash/app grid. Account for both uses cases by adding a corresponding option to the constructor. Part-of: --- js/ui/appMenu.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/js/ui/appMenu.js b/js/ui/appMenu.js index 3c363bf9c..afd04d4b8 100644 --- a/js/ui/appMenu.js +++ b/js/ui/appMenu.js @@ -9,8 +9,10 @@ var AppMenu = class AppMenu extends PopupMenu.PopupMenu { /** * @param {Clutter.Actor} sourceActor - actor the menu is attached to * @param {St.Side} side - arrow side + * @param {object} params - options + * @param {bool} params.showSingleWindow - show window section for a single window */ - constructor(sourceActor, side = St.Side.TOP) { + constructor(sourceActor, side = St.Side.TOP, params = {}) { if (Clutter.get_default_text_direction() === Clutter.TextDirection.RTL) { if (side === St.Side.LEFT) side = St.Side.RIGHT; @@ -22,8 +24,13 @@ var AppMenu = class AppMenu extends PopupMenu.PopupMenu { this.actor.add_style_class_name('app-menu'); + const { + showSingleWindows = false, + } = params; + this._app = null; this._appSystem = Shell.AppSystem.get_default(); + this._showSingleWindows = showSingleWindows; this._windowsChangedId = 0; this._updateWindowsLaterId = 0; @@ -166,8 +173,9 @@ var AppMenu = class AppMenu extends PopupMenu.PopupMenu { if (!this._app) return; + const minWindows = this._showSingleWindows ? 1 : 2; const windows = this._app.get_windows().filter(w => !w.skip_taskbar); - if (windows.length < 2) + if (windows.length < minWindows) return; this._openWindowsHeader.show();