Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions shell/plugins/bar/Bar.qml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ Item {
property int revision: 0
function metadataFor(id) { return null }
}
// Qt names a screen before adding it, so only its geometry can arrive late;
// those reads are tracked and a screen whose size lands afterwards still gets
// its bar. BarModel.isRealScreen says which screens are skipped and why.
readonly property var realScreens: BarModel.realScreens(Quickshell.screens)
// Mirrors the on-disk `bar-off` flag so the user can hide the bar without
// killing the entire shell. Hidden panels stay mapped but park off-screen
// without an exclusion zone; updated by the FileView watcher further down.
Expand Down Expand Up @@ -1194,7 +1198,7 @@ Item {
}

Variants {
model: Quickshell.screens
model: root.realScreens

delegate: Component {
BarPanel {
Expand All @@ -1206,7 +1210,7 @@ Item {
}

Variants {
model: Quickshell.screens
model: root.realScreens

delegate: Component {
DragGhostPanel {
Expand All @@ -1219,7 +1223,7 @@ Item {
}

Variants {
model: Quickshell.screens
model: root.realScreens

delegate: Component {
BarMoveGhostPanel {
Expand Down
22 changes: 22 additions & 0 deletions shell/plugins/bar/BarModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,30 @@ function nearestDropTarget(candidates, point, vertical) {
return best
}


// With every monitor unplugged, Qt substitutes a nameless placeholder screen
// and Hyprland its headless FALLBACK output. A bar built for either outlives
// the monitors' return: the compositor drops it onto whichever monitor comes
// back first, where it stacks over that monitor's own bar — and every bar
// widget's ShellIpc re-registers — until torn down (#13072 / #13163).
function isRealScreen(screen) {
if (!screen || !screen.name || screen.name === "FALLBACK") return false
return screen.width > 0 && screen.height > 0
}

function realScreens(screens) {
var real = []
var list = screens || []
for (var i = 0; i < list.length; i++) {
if (isRealScreen(list[i])) real.push(list[i])
}
return real
}

if (typeof module !== "undefined") {
module.exports = {
isRealScreen: isRealScreen,
realScreens: realScreens,
isDrawnSlot: isDrawnSlot,
pickDrawnSlot: pickDrawnSlot,
pickPanelSlot: pickPanelSlot,
Expand Down
35 changes: 35 additions & 0 deletions test/shell.d/bar-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,22 @@ if rg -q 'barMoveSettling|barMoveSettleTimer' "$ROOT/shell/plugins/bar/Bar.qml";
fi
pass "bar move outline has no post-release settling state"

# Every per-screen bar surface has to go through the real-screen filter, or the
# placeholder and FALLBACK screens get a bar again; BarModel's tests below cover
# which screens the filter keeps.
if rg -q 'model:\s*Quickshell\.screens' "$ROOT/shell/plugins/bar/Bar.qml"; then
fail "bar surfaces must not be built for Qt's placeholder screen"
fi
if (( $(rg -c 'model:\s*root\.realScreens' "$ROOT/shell/plugins/bar/Bar.qml") != 3 )); then
fail "bar, drag ghost and move ghost surfaces must all use the real-screen filter"
fi
if ! rg -q 'readonly property var realScreens: BarModel\.realScreens\(Quickshell\.screens\)' "$ROOT/shell/plugins/bar/Bar.qml"; then
fail "bar real-screen list must come from BarModel.realScreens"
fi
pass "bar surfaces are built only for real screens"



# A widget above the gesture area propagates its composed press-and-hold down
# without handing over the grab, so the resulting move gets neither a release
# nor a cancel and the ghost stays up for the session. Only the grabbing area
Expand Down Expand Up @@ -84,6 +100,25 @@ assertEqual(bar.pickDrawnSlot([placeholder]), placeholder, 'bar falls back to th
assertEqual(bar.pickDrawnSlot([]), null, 'bar reports no slot when there are none')
assertEqual(bar.pickDrawnSlot(null), null, 'bar tolerates a missing slot list')

// With every monitor unplugged, Qt substitutes a nameless 0x0 placeholder and
// Hyprland a FALLBACK output with a real mode; neither may get a bar. A
// user-created headless output is a real screen and keeps its bar.
const qtPlaceholder = { name: '', width: 0, height: 0 }
const hyprFallback = { name: 'FALLBACK', width: 1920, height: 1080 }
const monitor = { name: 'HDMI-A-1', width: 3840, height: 2160 }
const headless = { name: 'HEADLESS-2', width: 1920, height: 1080 }
const unsized = { name: 'DP-1', width: 0, height: 0 }
assertEqual(bar.isRealScreen(qtPlaceholder), false, 'bar skips Qt\'s placeholder screen')
assertEqual(bar.isRealScreen(hyprFallback), false, 'bar skips Hyprland\'s FALLBACK output despite its real mode')
assertEqual(bar.isRealScreen(monitor), true, 'bar keeps a real monitor')
assertEqual(bar.isRealScreen(headless), true, 'bar keeps a user-created headless output')
assertEqual(bar.isRealScreen(unsized), false, 'bar waits for a screen\'s geometry')
assertEqual(bar.isRealScreen(null), false, 'bar tolerates a missing screen')
assertEqual(JSON.stringify(bar.realScreens([qtPlaceholder, monitor, hyprFallback, headless])), JSON.stringify([monitor, headless]), 'bar keeps only real screens, in order')
assertEqual(JSON.stringify(bar.realScreens(null)), '[]', 'bar tolerates a missing screen list')



// Revealing the indicators can slide a neighbouring widget under a stationary
// pointer; collapsing the peek on that un-hover re-opens it and stutters the
// bar, so the peek stays held while the pointer is anywhere on the bar.
Expand Down