Restore menu toggle behavior on keybinds and bar clicks
The old bash bin short-circuited with close_visible_quickshell_menu at the top of open_quickshell_menu, so pressing any menu keybind while the menu was open just closed it. The IPC path I introduced summoned every time, so keyboard shortcuts couldn't dismiss \u2014 only outside clicks did (which is why the bar icon appeared to toggle: clicking it while the menu was open hit the menu's outer-click MouseArea, not the icon). Add a menu.toggle IPC method: - if root.opened: cancel() and return "closed" - otherwise: behaves exactly like summon Switch every Hyprland binding and the two bar-icon click handlers (omarchy logo, battery right-click \u2192 power menu) to toggle. summon stays as the always-open primitive for callers that want explicit summon semantics (rare \u2014 right now nothing internal uses it).
This commit is contained in:
@@ -1388,7 +1388,7 @@ Item {
|
||||
tooltipText: "Omarchy Menu\n\nSuper + Alt + Space"
|
||||
onPressed: function(button) {
|
||||
if (button === Qt.RightButton) root.run("xdg-terminal-exec")
|
||||
else root.run("omarchy-shell-ipc menu summon root")
|
||||
else root.run("omarchy-shell-ipc menu toggle root")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1944,7 +1944,7 @@ Item {
|
||||
tooltipText: root.batteryTooltip()
|
||||
onPressed: function(button) {
|
||||
if (button === Qt.RightButton) root.run("omarchy-notification-send \"$(omarchy-battery-status)\"")
|
||||
else root.run("omarchy-shell-ipc menu summon power")
|
||||
else root.run("omarchy-shell-ipc menu toggle power")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -690,6 +690,17 @@ Item {
|
||||
return "ok"
|
||||
}
|
||||
|
||||
// Hitting the same menu keybind while the menu is already visible should
|
||||
// close it — even if the requested target differs from the active one.
|
||||
// Matches the old bash bin's `close_visible_quickshell_menu` short-circuit.
|
||||
function toggle(initialMenu: string): string {
|
||||
if (root.opened) {
|
||||
root.cancel()
|
||||
return "closed"
|
||||
}
|
||||
return summon(initialMenu)
|
||||
}
|
||||
|
||||
function refresh(): string {
|
||||
defaultMenuFile.reload()
|
||||
userMenuFile.reload()
|
||||
@@ -697,7 +708,7 @@ Item {
|
||||
}
|
||||
|
||||
function close(): string {
|
||||
root.close()
|
||||
root.cancel()
|
||||
return "ok"
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user