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
|
||||
}
|
||||
|
||||
|
||||
@@ -154,6 +154,29 @@ function pickDrawnSlot(slots) {
|
||||
return placeholder
|
||||
}
|
||||
|
||||
// A bar surface is built per monitor, so a panel hotkey has several live
|
||||
// copies of the same widget to route to, and the panel opens on whichever
|
||||
// monitor's copy answers. Candidates are `{ slot, screenName, opened }`.
|
||||
//
|
||||
// An open copy wins first: hide and toggle have to reach the panel the user
|
||||
// can actually see, wherever it was opened from. Otherwise the focused
|
||||
// monitor's copy wins, so a summon lands where the user is working instead of
|
||||
// on whichever output registered its slot first. Neither narrowing applies on
|
||||
// a single monitor, or when the focused output has no bar of its own.
|
||||
function pickPanelSlot(candidates, focusedScreen) {
|
||||
var rows = Array.isArray(candidates) ? candidates : []
|
||||
var pool = rows.filter(function(row) { return row && row.opened === true })
|
||||
if (pool.length === 0) pool = rows.filter(function(row) { return !!row })
|
||||
|
||||
var focused = String(focusedScreen || "")
|
||||
if (focused) {
|
||||
var onFocused = pool.filter(function(row) { return row.screenName === focused })
|
||||
if (onFocused.length > 0) pool = onFocused
|
||||
}
|
||||
|
||||
return pickDrawnSlot(pool.map(function(row) { return row.slot }))
|
||||
}
|
||||
|
||||
// Resolve a pointer anywhere along the bar to the closest insertion edge.
|
||||
// Requiring the pointer to sit inside another widget makes the empty space
|
||||
// around a centered group a dead zone, even though it visually reads as the
|
||||
@@ -189,6 +212,7 @@ if (typeof module !== "undefined") {
|
||||
module.exports = {
|
||||
isDrawnSlot: isDrawnSlot,
|
||||
pickDrawnSlot: pickDrawnSlot,
|
||||
pickPanelSlot: pickPanelSlot,
|
||||
nearestDropTarget: nearestDropTarget,
|
||||
normalizePosition: normalizePosition,
|
||||
entrySettings: entrySettings,
|
||||
|
||||
Reference in New Issue
Block a user