Repository navigation
Add a floating bar option (bar.floating) - #13569
AbaddonTataken wants to merge 2 commits into
Conversation
`bar.floating` (and `omarchy bar floating <true|false|toggle>`) insets the bar from its screen edge by one Hyprland gaps_out, with the window corner radius, so it lines up with windows. The layer window keeps a fixed size and only the card inside it moves, so toggling window gaps animates the bar with the windows instead of resizing the surface (which can show a stretched frame). The bar watches the window-gaps flag itself rather than waiting for Style to re-poll Hyprland. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Automated AI review
Outcome: Toasts overlap a floating top/right bar; the first gaps toggle mishandles the inset. Toasts overlap the floating bar
Suggested change: Clear Reproducer (fails at 9d878b0)Reproducer: notification toasts overlap a floating top or right bar (reproduced as geometry)Reviewed head: 9d878b0. Toasts are placed from This is a geometric check with the repository's own Run from an Omarchy checkout at the PR head (needs node): bash toast-overlap-repro.sh "$PWD"
#!/bin/bash
# Reproducer: with bar.floating, notification toasts start inside a floating
# top or right bar. Uses the repository's own placement helper and the
# clearance formula in notifications/Service.qml.
# Usage: bash toast-overlap-repro.sh <omarchy-checkout>
set -euo pipefail
source "$1/test/shell.d/base-test.sh"
run_node_test <<'JS'
const fs = require('fs')
const notifications = requireFromRoot('shell/plugins/notifications/NotificationLogic.js')
const service = fs.readFileSync(root + '/shell/plugins/notifications/Service.qml', 'utf8')
const bar = fs.readFileSync(root + '/shell/plugins/bar/Bar.qml', 'utf8')
// Stock sizes: Style.bar.sizeHorizontal 26, sizeVertical 28, and
// Style.gapsOut 5 (half of Hyprland's default gaps_out 10).
const gapsOut = 5
assert(/floatGap: floating && !windowGapsOff \? \(Style\.gapsOut > 0 \? Style\.gapsOut \* 2 : lastGap\) : 0/.test(bar),
'a floating bar card sits Style.gapsOut * 2 from its edge')
assert(/liveBarSize: [^\n]*shell\.bar\.barSize\)/.test(service) && /barClearance: liveBarSize \+ Style\.gapsOut/.test(service),
'toasts clear shell.bar.barSize + Style.gapsOut')
const rows = [['top', 26, 'top'], ['right', 28, 'right']].map(([position, barSize, margin]) => {
const cardInnerEdge = gapsOut * 2 + barSize
const toastEdge = notifications.popupPlacement(position, barSize + gapsOut, gapsOut).margins[margin]
console.log(`# ${position} bar: toast starts ${toastEdge}px from the edge; the floating bar reaches ${cardInnerEdge}px`)
return { position, cardInnerEdge, toastEdge }
})
for (const row of rows) {
assert(row.toastEdge >= row.cardInnerEdge, `a toast clears a floating ${row.position} bar`,
`overlap: ${row.cardInnerEdge - row.toastEdge}px`)
}
JSActual output at 9d878b0 (exit 1): The script stops at the first failed assertion; both rows are printed before it: the top case overlaps by 5 px (31 against 36) and the right case by 5 px (33 against 38). First gaps toggle resizes the barStock Suggested change: Assign Reproducer (fails at 9d878b0)Reproducer: the floating bar's window-gaps bookkeeping on stock Omarchy (reproduced)Reviewed head: 9d878b0. Stock Omarchy ships The script copies the PR's floating block out of Run from an Omarchy checkout at the PR head: bash floating-gaps-repro.sh "$PWD" "$(mktemp -d)"
#!/bin/bash
# Reproducer: the floating bar's lastGap follows Style.gapsOut to 0 on the first
# window-gaps toggle. Copies the PR's floating property block out of Bar.qml
# verbatim into a qmltestrunner harness with a stub Style singleton.
# Usage: bash floating-gaps-repro.sh <omarchy-checkout> <empty-scratch-dir>
set -euo pipefail
src="$1"; work="$2/lastgap"
rm -rf "$work"; mkdir -p "$work/qs/Commons" "$work/tests"
style="$src/shell/Commons/Style.qml"
bar="$src/shell/plugins/bar/Bar.qml"
start_gaps=$(sed -n 's/^ property int gapsOut: \([0-9][0-9]*\)$/\1/p' "$style")
start_radius=$(sed -n 's/^ property int cornerRadius: \([0-9][0-9]*\)$/\1/p' "$style")
[[ -n $start_gaps && -n $start_radius ]] || { echo "could not read Style.qml starting values" >&2; exit 2; }
printf 'module qs.Commons\nsingleton Style 1.0 Style.qml\n' >"$work/qs/Commons/qmldir"
cat >"$work/qs/Commons/Style.qml" <<QML
pragma Singleton
import QtQuick
// Stub with the starting values of shell/Commons/Style.qml.
QtObject {
property int cornerRadius: $start_radius
property int gapsOut: $start_gaps
}
QML
# Everything from 'property bool floating: false' through the end of the
# 'Connections { target: Style ... }' block, byte for byte.
awk '/^ property bool floating: false$/ { on = 1 }
on { print }
on && /^ Connections \{$/ { conn = 1 }
conn && /^ \}$/ { exit }' "$bar" >"$work/block.txt"
grep -q 'function onGapsOutChanged' "$work/block.txt" || { echo "floating block not found in Bar.qml" >&2; exit 2; }
{
cat <<'QML'
import QtQuick
import QtTest
import qs.Commons
Item {
id: harness
width: 100
height: 100
Component {
id: barComponent
Item {
id: root
// Bar.qml: vertical ? Style.bar.sizeVertical : Style.bar.sizeHorizontal (26 for a top bar)
property int barSize: 26
QML
cat "$work/block.txt"
cat <<QML
}
}
TestCase {
name: "FloatingBarWindowGaps"
// Creates the bar the way the shell does: Style still holds its starting
// values, then its startup hyprctl poll lands.
function makeBar(polledGapsOut, polledRadius) {
Style.gapsOut = $start_gaps
Style.cornerRadius = $start_radius
var bar = createTemporaryObject(barComponent, harness)
Style.gapsOut = polledGapsOut
Style.cornerRadius = polledRadius
bar.floating = true
return bar
}
// omarchy toggle window-gaps: the bar's own probe sees the flag first,
// then Style re-polls Hyprland (200 ms later) and reads 0.
function gapsOff(bar) {
bar.windowGapsOff = true
Style.gapsOut = 0
Style.cornerRadius = 0
}
// Stock Omarchy: gaps_out = 10, so Style.gapsOut polls as 5, its starting value.
function test_stock_windowKeepsFloatingSizeWithGapsOff() {
var bar = makeBar(5, 0)
compare(bar.floatGap, 10, "floating gap before the toggle")
compare(bar.windowExtent, 36, "window extent before the toggle")
gapsOff(bar)
compare(bar.floatGap, 0, "gaps off tucks the card")
compare(bar.windowExtent, 36, "the window keeps its floating size while gaps are off")
}
function test_stock_floatsAgainBeforeStyleRepolls() {
var bar = makeBar(5, 0)
gapsOff(bar)
// Toggle back: the probe sees the flag go before Style re-polls.
bar.windowGapsOff = false
compare(bar.floatGap, 10, "the card floats again before Style re-polls")
}
// After one full off/on cycle the handler has assigned lastGap, so the
// binding is gone and later cycles behave as designed.
function test_stock_secondCycle() {
var bar = makeBar(5, 0)
gapsOff(bar)
bar.windowGapsOff = false
Style.gapsOut = 5
gapsOff(bar)
compare(bar.windowExtent, 36, "second cycle: the window keeps its floating size")
bar.windowGapsOff = false
compare(bar.floatGap, 10, "second cycle: the card floats again before Style re-polls")
}
// A gaps_out that really is 0 (no toggle flag) must not float the card.
function test_realZeroGapsAtStartup() {
var bar = makeBar(0, 0)
compare(bar.floatGap, 0, "gaps_out 0 at startup: no inset")
}
function test_realZeroGapsWhileRunning() {
var bar = makeBar(10, 0)
Style.gapsOut = 0
compare(bar.floatGap, 0, "gaps_out set to 0 while running, flag absent: no inset")
}
// Control: gaps_out = 20, so Style.gapsOut changes from 5 to 10 at startup.
function test_gapsOut20() {
var bar = makeBar(10, 0)
gapsOff(bar)
compare(bar.windowExtent, 46, "the window keeps its floating size while gaps are off")
bar.windowGapsOff = false
compare(bar.floatGap, 20, "the card floats again before Style re-polls")
}
}
}
QML
} >"$work/tests/tst_floating_gaps.qml"
runner=/usr/lib/qt6/bin/qmltestrunner
QT_QPA_PLATFORM=offscreen QT_QUICK_BACKEND=software "$runner" -import "$work" -input "$work/tests" -o -,txtActual output at 9d878b0 (qmltestrunner exits 3, one per failed case): One run-environment setup line and its one-line output are omitted, and the scratch directory in The two Diagnostic check (disposable copy of the extracted block, not a PR change): with DetailsRelated open PRs
Optional notes
Verified
Review informationTest scope: Source and sandbox tests only, at AI process: Opus 5.5 Medium coordination and synthesis, Opus 5.5 Xhigh technical review and final fact check, GPT 6 Sol Xhigh search for related issues, Opus 5.5 Medium editorial check. Opt out: To stop receiving these reviews, reply to this comment saying so. |
|
Hi @AbaddonTataken, #13138 adds the same |
Toasts cleared barSize + gapsOut while a floating card reaches barSize + 2 * gapsOut, so they covered its inner 5 px. They now clear the bar's barExtent when it is larger. lastGap and lastRadius were bound at creation, before Style had polled Hyprland, so the first window-gaps toggle could start from a wrong inset and resize the bar. They are now captured in Component.onCompleted, and a gaps_out of 0 is remembered only when the toggle flag is off. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
|
Thanks @cristian-fleischer, and thanks @llstrk for the review. Both review findings are fixed in fcd6580: toasts now clear the bar's full On #13138: it uses the same |
|
| FileView { | ||
| path: root.home + "/.local/state/omarchy/toggles/hypr" | ||
| watchChanges: true | ||
| printErrors: false | ||
| onFileChanged: windowGapsProbe.running = true |
There was a problem hiding this comment.
The new directory watch has no recovery path if it misses a gap toggle. The existing bar-off watch documents this failure and uses syncHidden() to recover, but windowGapsProbe only runs at startup and on directory events. After quick toggles, windowGapsOff can stay stale even after Style refreshes, leaving the floating bar docked or inset incorrectly until the shell restarts. Add a refresh call from the toggle command or another way to re-read the flag.
| readonly property int floatGap: floating && !windowGapsOff ? (Style.gapsOut > 0 ? Style.gapsOut * 2 : lastGap) : 0 | ||
| readonly property int floatRadius: floating && !windowGapsOff ? (Style.cornerRadius > 0 ? Style.cornerRadius : lastRadius) : 0 |
There was a problem hiding this comment.
Cached gaps and rounding never expire when the restored value stays zero. For example, start with rounding 12, turn gaps off, change the configured rounding to 0, then turn gaps back on. Style.cornerRadius stays 0, so onCornerRadiusChanged() never runs again and floatRadius keeps using 12. The same problem affects a gap changed to zero while gaps are off. Refresh the cached values after the restore poll completes, even when the values did not change.
| // stretched frame), so a floating bar's window always spans the floating | ||
| // footprint and only its reserved space and card inset change. | ||
| readonly property int barExtent: barSize + floatGap | ||
| readonly property int windowExtent: barSize + (floating ? Math.max(lastGap, floatGap) : 0) |
There was a problem hiding this comment.
Keeping the layer window larger than the docked card breaks the spacing used by KeyboardPanel. It places panels using anchorWindow.height or anchorWindow.width, not the visible card edge. With a floating top bar and a remembered gap of 10, turning gaps off leaves the clock and weather panels 10 pixels below the flush bar even though gap is now zero. Update panel placement to use the visible bar edge rather than the fixed window size.
Knowledge Base Used: Shell UI and desktop interactions
|
Thanks @AbaddonTataken, sounds good. Upstream reworked the bar since (#15517, #14991), so I'm porting #13138 onto it now. Once that's up, your animated inset and the click-through mask would fit nicely on top. |
What
omarchy bar floating true(or"floating": trueunderbarin~/.config/omarchy/shell.json) lifts the bar off its screen edge:gaps_outfrom the edge and both sides, so it lines up with window edges.decoration:rounding, the same radius windows get. With Omarchy's default rounding of 0 the card is square; themes or users that round windows get a matching rounded bar.Super + Shift + Backspace) tucks it back flush against the edge together with the windows, and floats it again when gaps come back. The inset and radius animate on the default Hyprlandwindowscurve (easeOutQuint, 379 ms).Super + Shift + Space).floatingdefaults tofalse; the docked bar is unchanged.How
windowExtent), and abarSurfacerectangle inside it carries the background, inset and radius. Only the card moves when the gap changes; the layer surface is never resized. Resizing a layer surface to animate can show one stale, stretched frame, which is what a naive implementation (animating the window height) looked like during the gaps toggle.ExclusionMode.Normal+exclusiveZone: barExtent), so windows reflow to the new gap immediately with their own animation while the card follows.mask: Region { item: barSurface }keeps the floating gap click-through.Styleonly re-pollsgeneral:gaps_out/decoration:rounding200 ms after Hyprland reloads, which made the bar snap after the windows had already moved. The bar watches thewindow-no-gapstoggle flag itself (the same directory-watch + probe pattern asbar-off) and holds the last real gap and radius untilStylecatches up.barExtent) so a floating transparent bar samples what is actually behind it.Also
omarchy bar floating <true|false|toggle>inbin/omarchy-bar, mirroringtransparent.manual/05-the-top-bar.md(new "Floating the bar" section, command and config example),docs/omarchy-shell.md,shell/plugins/bar/README.md.Tests
test/shell.d/bar-test.sh: the existing hidden-bar assertions now match the explicit exclusion zone andwindowExtent; new assertions cover the gap derivation, reserved space, fixed window size across a gap change, the click-through mask, the gaps-toggle watch and readingbar.floating.test/shell.d/config-test.sh:omarchy bar floating true,toggle, and rejection of invalid values../test/all: 4086 passing (11 new), no new failures. The 8 failures on my machine fail identically on unmodifiedquattro(environment:omasnapnot installed, noomarchy-isocheckout, kernel headers, browser launcher, VS Code theme, cache cleanup, network portal fixture, apre_removehook).Visual verification
Verified on a running session (Hyprland
gaps_out = 10,rounding = 12): floating, gaps toggled off, gaps back on, and the layer surface stayed 1920×47 throughout while the reserved zone switched 47 → 37 → 47.Screenshots (floating, and with window gaps toggled off) are attached below.
Possible follow-ups
🤖 Generated with Claude Code