class PanelMenu
Swift
final class PanelMenu
The global menu, from a panel's side: the focused window's menu, imported
over DBusMenu and turned into the same MenuModel an app's own menubar is.
MenuHost is the mirror of this — what an application does to publish a
menu — and the two never meet in one process except by coincidence. What
they share is the model: once imported, another application's menu is an
ordinary MenuModel, which is what lets a panel draw it with MenuBarStrip
rather than growing a second menu renderer that would drift from the first.
Activation goes back the way it came. A MenuID here is a DBusMenu item id
in a string, so activating one is a lookup and a clicked event to the
application that owns the menu — nothing runs in the panel, which owns none
of these actions and could not run them if it wanted to.
Sources/LavaUI/PanelMenu.swift:17
Constructors
init(editor: Editor)
Not documented.
Sources/LavaUI/PanelMenu.swift:39
Properties
var busName: String { get }
Which registrar name is owned. com.canonical.AppMenu.Registrar also
picks up Qt and GTK applications; the lava-specific fallback picks up
only LavaUI ones.
Sources/LavaUI/PanelMenu.swift:37
var isServing: Bool { get }
Whether this panel is serving a registrar at all. False means no bus,
or every registrar name already taken — see Editor.menuImportStart.
Sources/LavaUI/PanelMenu.swift:32
var model: MenuModel { get }
The imported menu. Empty when nothing is focused, when the focused window exported no menu, or before the layout has arrived.
Sources/LavaUI/PanelMenu.swift:28
Methods
func aboutToShow(_ id: MenuID)
"This submenu is about to open." Applications are allowed to fill a submenu only when asked, so a menu opened without this can be legitimately empty — and stay that way until the user gives up.
Sources/LavaUI/PanelMenu.swift:116
func activate(_ id: MenuID)
Runs an item in the application that owns it.
The MenuID is a DBusMenu id in a string — see menuID(for:). An id
from a menu that has since been replaced simply resolves to nothing,
which is the right answer: the item the user clicked is gone.
Sources/LavaUI/PanelMenu.swift:108
func closed()
"The dropdown closed."
Worth saying, because the importer keeps the open one fresh by itself:
a layout update rebuilds the bar from GetLayout(0), which for a
Chromium menu hands back the empty stub it always does, so the subtree
the user is looking at is re-fetched on the spot. Left believing a menu
is open, it does that for the rest of the session — and asking VS Code
is what makes VS Code publish another layout.
Sources/LavaUI/PanelMenu.swift:143
@discardableResult func poll() -> Bool
Pumps DBus and rebuilds the model when the far side changed it.
Returns true when model is different from the last time it did, which
is the panel's signal to rebuild its view — and, more to the point, its
signal not to, on the overwhelming majority of frames where a menu
sits still.
Sources/LavaUI/PanelMenu.swift:93
func setActiveWindow(_ registrarId: UInt32, menuService: String = "", menuObjectPath: String = "", pid: UInt32 = 0)
Show this window's menu. Cheap to call with an unchanged address.
registrarId is what the window passed to RegisterWindow — the
compositor surface id for Wayland clients, an XID for X11 ones, and
ActiveWindow.registrarId either way. Not the surface id, which for
an Xwayland window is a number its toolkit has never seen.
menuService / menuObjectPath are the KDE AppMenu DBus coordinates
for foreign Wayland clients; empty uses the registrar + registrarId,
then a registrar entry matching pid.
Sources/LavaUI/PanelMenu.swift:63