LavaUI docs GitHub

class MenuHost

Swift

Constructors

init(editor: Editor)

Creates the menu host for editor's window and picks a backend: the global menu when a registrar is on the session bus (or LAVA_MENU=dbus), the in-window strip otherwise.

Sources/LavaUI/MenuHost.swift:42

Properties

var backend: MenuBackendKind { get }

Which backend shows the menu, chosen once at init.

Sources/LavaUI/MenuHost.swift:35

static let barHeight: Float

Default strip height in layout pixels (Vulkan backend only).

Sources/LavaUI/MenuHost.swift:148

let controller: MenuController

Holds the menu model and runs item actions.

Sources/LavaUI/MenuHost.swift:33

nonisolated(unsafe) static var exportWindowId: UInt32

The id to register this app's menu under, when the window is not an X11 one and has no id of its own to offer.

Set by LavaClient to the compositor's surface id, before the first MenuHost exists. That number is what the compositor reports as focused, so it is the one a panel can match a menu to — and without it a client's menu could be exported but never found, which is why a client used to fall back to drawing its own strip.

Sources/LavaUI/MenuHost.swift:30

var isEmpty: Bool { get }

Whether the menu has no top-level menus.

Sources/LavaUI/MenuHost.swift:145

var model: MenuModel { get }

The current menu model.

Sources/LavaUI/MenuHost.swift:142

var needsDBusPump: Bool { get }

DBusMenu replies (GetLayout / AboutToShow / Event) only run when the GLib main context is iterated. The panel blocks on those calls — an app that sat in glfwWaitEvents without anything to wake it for them froze XFCE. GLibPump is what wakes it now.

Sources/LavaUI/MenuHost.swift:72

var showsInWindowChrome: Bool { get }

Whether the in-window MenuChromeRoot strip should be composed.

Sources/LavaUI/MenuHost.swift:64

Methods

@discardableResult func activate(_ id: MenuID) -> Bool

Runs the action of item id and asks for a redraw. Returns false if the item is disabled or has no action.

Sources/LavaUI/MenuHost.swift:101

@discardableResult func activate(matchingKey key: Int32, mods: Int32) -> Bool

Runs the item whose shortcut matches this key and modifiers, if any, and asks for a redraw. Returns whether one ran.

Sources/LavaUI/MenuHost.swift:112

func poll()

Pump GLib/DBus and run any panel activations. Call once per frame.

Sources/LavaUI/MenuHost.swift:131

@discardableResult func update(_ bar: MenuBar) -> Bool

Rebuild IR from a menubar description. Pushes to DBus when that backend is active. Returns whether the platform-facing model changed.

Sources/LavaUI/MenuHost.swift:77

@discardableResult func update(@MenuBarBuilder _ content: () -> [Menu]) -> Bool

Rebuilds the menu from a @MenuBarBuilder block. Returns whether the model changed.

Sources/LavaUI/MenuHost.swift:94