Open panel hotkeys on the focused monitor (#6613)
A bar surface is built per monitor, so panel routing had several live copies of the same widget to choose from and took whichever registered its slot first. Pick the one on the monitor Hyprland has focused instead, preferring an already-open copy so hide and toggle still reach the visible panel. Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
2521b11fdd
commit
667d2d2f31
@@ -1,4 +1,5 @@
|
||||
import Quickshell
|
||||
import Quickshell.Hyprland
|
||||
import Quickshell.Io
|
||||
import Quickshell.Wayland
|
||||
import QtQuick
|
||||
@@ -387,7 +388,10 @@ Item {
|
||||
return Array.isArray(entries) ? entries : []
|
||||
}
|
||||
|
||||
function panelNavigationSlots(region) {
|
||||
// Tab order for the panels in one bar region. Scoped to a single bar surface
|
||||
// so tabbing walks the bar the open panel belongs to instead of hopping the
|
||||
// panel to another monitor's copy of the same widget.
|
||||
function panelNavigationSlots(region, window) {
|
||||
var entries = layoutEntries(region)
|
||||
var slots = []
|
||||
for (var i = 0; i < entries.length; i++) {
|
||||
@@ -395,6 +399,7 @@ Item {
|
||||
for (var j = 0; j < moduleSlots.length; j++) {
|
||||
var slot = moduleSlots[j]
|
||||
if (!slot || slot.region !== region || slot.moduleName !== id) continue
|
||||
if (window && !sameWindow(slotWindow(slot), window)) continue
|
||||
var item = slot.activeItem
|
||||
if (!item || item.visible !== true || slot.visible !== true || slot.width <= 0 || slot.height <= 0) continue
|
||||
if (typeof item.open !== "function" || typeof item.close !== "function" || item.opened === undefined) continue
|
||||
@@ -418,7 +423,7 @@ Item {
|
||||
}
|
||||
if (!currentSlot) return false
|
||||
|
||||
var slots = panelNavigationSlots(currentSlot.region)
|
||||
var slots = panelNavigationSlots(currentSlot.region, slotWindow(currentSlot))
|
||||
if (slots.length < 2) return false
|
||||
|
||||
var currentIndex = -1
|
||||
@@ -452,6 +457,19 @@ Item {
|
||||
return items
|
||||
}
|
||||
|
||||
function slotScreenName(slot) {
|
||||
var window = slotWindow(slot)
|
||||
return window && window.screen ? String(window.screen.name || "") : ""
|
||||
}
|
||||
|
||||
// The output Hyprland has focused, which is where a keyboard-summoned panel
|
||||
// belongs. Empty until Hyprland reports one, which leaves panel routing on
|
||||
// its per-monitor fallback rather than guessing at an output.
|
||||
function focusedScreenName() {
|
||||
var monitor = Hyprland.focusedMonitor
|
||||
return monitor ? String(monitor.name || "") : ""
|
||||
}
|
||||
|
||||
// Resolve the live bar-widget instance for a plugin id (e.g. "omarchy.bluetooth").
|
||||
// Only widgets that expose popup open/close methods count; plain indicators
|
||||
// (clock, workspaces, tray) return null. Used by shell.summon/toggle so
|
||||
@@ -467,11 +485,11 @@ Item {
|
||||
if (slot.moduleName !== id) continue
|
||||
var item = slot.activeItem
|
||||
if (typeof item.open !== "function" || typeof item.close !== "function" || item.opened === undefined) continue
|
||||
candidates.push(slot)
|
||||
candidates.push({ slot: slot, screenName: slotScreenName(slot), opened: item.opened === true })
|
||||
}
|
||||
// Anchored center modules are mounted twice; only the drawn copy can
|
||||
// anchor a popup or carry the open-panel mark. See BarModel.pickDrawnSlot.
|
||||
var chosen = BarModel.pickDrawnSlot(candidates)
|
||||
// One copy per monitor, plus a zero-size placeholder for anchored center
|
||||
// modules. See BarModel.pickPanelSlot for which one a hotkey acts on.
|
||||
var chosen = BarModel.pickPanelSlot(candidates, focusedScreenName())
|
||||
return chosen ? chosen.activeItem : null
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user