Skip to content

Commit 7633d8d

Browse files
vivek7405dhh
andauthored
Keep the bar mapped while hidden so revealing it is instant (omacom#6677)
* Keep the bar mapped while hidden so revealing it is instant Hiding the bar set the panel invisible, which unmaps the layer surface and releases the scene graph with it. Every reveal then had to rebuild all of it: a new layer surface, a configure roundtrip, re-shaped glyphs and re-uploaded textures, and a first frame before anything appeared. Measured on a 2560x1440 screen, showing took 155-175ms against 20ms to hide, and 400-595ms on the first reveal after a cold start. Splitting the cost showed the exclusive-zone reflow was not to blame: show latency was the same on an empty workspace as on a tiled one, and windows finished moving ~15ms after the bar was already on screen. Park the bar one bar-width past its anchored edge instead, and drop its exclusion zone while hidden. The surface stays alive, so showing is only a margin change: 10-14ms in both directions, at every bar position. Since a hidden bar is now mapped, layer_present no longer proves the bar is visible; the session acceptance test asserts on-screen geometry. * Fix layer visibility checks on offset monitors * Handle rotated outputs in layer visibility checks * Cover hidden bar behavior in acceptance tests --------- Co-authored-by: David Heinemeier Hansson <david@hey.com>
1 parent 354c2f0 commit 7633d8d

5 files changed

Lines changed: 134 additions & 5 deletions

File tree

‎shell/plugins/bar/Bar.qml‎

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ Item {
2727
// diagnostics; the built-in bar does not otherwise need it.
2828
property var manifest: null
2929
// Mirrors the on-disk `bar-off` flag so the user can hide the bar without
30-
// killing the entire shell. Wired to BarPanel.visible below; updated by the
31-
// FileView watcher further down.
30+
// killing the entire shell. Hidden panels stay mapped but park off-screen
31+
// without an exclusion zone; updated by the FileView watcher further down.
3232
property bool barHidden: false
3333
property string home: Quickshell.env("HOME")
3434
property string stateHome: home + "/.local/state"
@@ -956,13 +956,26 @@ Item {
956956
component BarPanel: PanelWindow {
957957
id: barWindow
958958

959-
visible: !root.barHidden && !remapGuard.remapping
959+
// Hiding parks the bar just past its screen edge instead of unmapping it.
960+
// Unmapping frees the layer surface and the whole scene graph, so every
961+
// reveal has to rebuild them — new surface, re-shaped glyphs, re-uploaded
962+
// textures — which measures ~150ms against ~20ms to tear down. Parking
963+
// keeps the surface alive, so showing is only a margin change.
964+
visible: !remapGuard.remapping
965+
exclusionMode: root.barHidden ? ExclusionMode.Ignore : ExclusionMode.Auto
960966

961967
ScreenMoveRemap {
962968
id: remapGuard
963969
window: barWindow
964970
}
965971

972+
margins {
973+
top: root.barHidden && root.position === "top" ? -root.barSize : 0
974+
bottom: root.barHidden && root.position === "bottom" ? -root.barSize : 0
975+
left: root.barHidden && root.position === "left" ? -root.barSize : 0
976+
right: root.barHidden && root.position === "right" ? -root.barSize : 0
977+
}
978+
966979
anchors {
967980
top: root.position === "top" || root.vertical
968981
bottom: root.position === "bottom" || root.vertical

‎test/acceptance.d/base-test.sh‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,34 @@ layer_absent() {
7979
! layer_present "$1"
8080
}
8181

82+
# A layer can be mapped but parked off the monitor: the bar hides that way so
83+
# revealing it does not have to rebuild the surface. Assert on geometry when
84+
# what matters is that the user can actually see it. Layer boxes are local to
85+
# their monitor and in logical coordinates, so compare them with local bounds
86+
# derived from the monitor's scaled pixel size.
87+
layer_on_screen() {
88+
local monitors
89+
monitors=$(hyprctl -j monitors) || return 1
90+
91+
hyprctl -j layers | jq -e --arg ns "$1" --argjson monitors "$monitors" '
92+
to_entries[]
93+
| .key as $name
94+
| .value as $levels
95+
| ($monitors[] | select(.name == $name)) as $m
96+
| (if ($m.transform // 0) % 2 == 1 then $m.height else $m.width end) / $m.scale | round as $width
97+
| (if ($m.transform // 0) % 2 == 1 then $m.width else $m.height end) / $m.scale | round as $height
98+
| [$levels | .. | objects | select(.namespace? == $ns)][]
99+
| select(
100+
.x + .w > 0 and .x < $width and
101+
.y + .h > 0 and .y < $height
102+
)
103+
' >/dev/null
104+
}
105+
106+
layer_off_screen() {
107+
! layer_on_screen "$1"
108+
}
109+
82110
# Close every window matching a class regex, by address so multi-window apps
83111
# are fully closed. Tries the quattro Lua dispatcher first, then classic.
84112
close_windows() {

‎test/acceptance.d/session-test.sh‎

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,25 @@ for plugin in \
2424
done
2525

2626
# The bar and background are actually on screen
27-
wait_until "bar layer is on screen" 30 layer_present "omarchy-bar"
28-
wait_until "background layer is on screen" 30 layer_present "omarchy-background"
27+
wait_until "bar layer is on screen" 30 layer_on_screen "omarchy-bar"
28+
wait_until "background layer is on screen" 30 layer_on_screen "omarchy-background"
29+
30+
# Hiding parks the bar off-screen without unmapping its layer surface, and
31+
# revealing brings that same surface back on-screen.
32+
restore_bar_visibility() {
33+
omarchy-toggle-bar off >/dev/null 2>&1 || true
34+
}
35+
trap restore_bar_visibility EXIT
36+
37+
omarchy-toggle-bar on
38+
wait_until "hidden bar layer stays mapped" 15 layer_present "omarchy-bar"
39+
wait_until "hidden bar layer parks off screen" 15 layer_off_screen "omarchy-bar"
40+
screenshot "success-bar-hidden"
41+
42+
omarchy-toggle-bar off
43+
wait_until "revealed bar layer returns on screen" 15 layer_on_screen "omarchy-bar"
44+
screenshot "success-bar-revealed"
45+
trap - EXIT
2946

3047
# Audio stack is up
3148
wait_until "pipewire is running" 30 wpctl status
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#!/bin/bash
2+
3+
source "$(dirname "$0")/base-test.sh"
4+
source "$ROOT/test/acceptance.d/base-test.sh"
5+
6+
monitor_json='[
7+
{"name":"DP-1","x":1920,"y":0,"width":3840,"height":2160,"scale":2},
8+
{"name":"DP-2","x":-2560,"y":-1440,"width":2560,"height":1440,"scale":1},
9+
{"name":"DP-3","x":0,"y":1080,"width":1920,"height":1080,"scale":1,"transform":1}
10+
]'
11+
layer_json='{
12+
"DP-1":{"levels":{"2":[
13+
{"x":0,"y":0,"w":1920,"h":26,"namespace":"visible-positive-offset"},
14+
{"x":1920,"y":0,"w":26,"h":1080,"namespace":"parked-positive-offset"}
15+
]}},
16+
"DP-2":{"levels":{"2":[
17+
{"x":0,"y":0,"w":2560,"h":26,"namespace":"visible-negative-offset"},
18+
{"x":-26,"y":0,"w":26,"h":1440,"namespace":"parked-negative-offset"}
19+
]}},
20+
"DP-3":{"levels":{"2":[
21+
{"x":0,"y":1500,"w":26,"h":26,"namespace":"visible-rotated"},
22+
{"x":1080,"y":0,"w":26,"h":1920,"namespace":"parked-rotated"}
23+
]}}
24+
}'
25+
26+
hyprctl() {
27+
if [[ $2 == "monitors" ]]; then
28+
printf '%s\n' "$monitor_json"
29+
elif [[ $2 == "layers" ]]; then
30+
printf '%s\n' "$layer_json"
31+
else
32+
return 1
33+
fi
34+
}
35+
36+
assert_layer_on_screen() {
37+
local namespace="$1" description="$2"
38+
39+
layer_on_screen "$namespace" && pass "$description" || fail "$description"
40+
}
41+
42+
assert_layer_off_screen() {
43+
local namespace="$1" description="$2"
44+
45+
layer_off_screen "$namespace" && pass "$description" || fail "$description"
46+
}
47+
48+
assert_layer_on_screen "visible-positive-offset" "visible layer is found on a positively offset monitor"
49+
assert_layer_off_screen "parked-positive-offset" "right-parked layer stays off a positively offset monitor"
50+
assert_layer_on_screen "visible-negative-offset" "visible layer is found on a negatively offset monitor"
51+
assert_layer_off_screen "parked-negative-offset" "left-parked layer stays off a negatively offset monitor"
52+
assert_layer_on_screen "visible-rotated" "visible layer uses the transformed monitor height"
53+
assert_layer_off_screen "parked-rotated" "parked layer uses the transformed monitor width"

‎test/shell.d/bar-test.sh‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,24 @@ const shellSource = fs.readFileSync(root + '/shell/shell.qml', 'utf8')
2222
2323
assert(/function toggleBarTransparency\(\): string \{[\s\S]*?shell\.bar\.toggleTransparency\(\)/.test(shellSource), 'shell exposes the bar transparency toggle over IPC')
2424
25+
// Hiding must not unmap the bar. An unmapped layer surface has to be rebuilt on
26+
// every reveal, which measured ~150ms against ~20ms to tear it down; parking it
27+
// past the screen edge keeps show and hide symmetric at ~12ms.
28+
assert(
29+
/visible: !remapGuard\.remapping/.test(barSource),
30+
'bar stays mapped while hidden so revealing it does not rebuild the surface'
31+
)
32+
assert(
33+
/exclusionMode: root\.barHidden \? ExclusionMode\.Ignore : ExclusionMode\.Auto/.test(barSource),
34+
'a hidden bar reserves no space for itself'
35+
)
36+
for (const edge of ['top', 'bottom', 'left', 'right']) {
37+
assert(
38+
new RegExp(`${edge}: root\\.barHidden && root\\.position === "${edge}" \\? -root\\.barSize : 0`).test(barSource),
39+
`a hidden bar parks past the ${edge} edge`
40+
)
41+
}
42+
2543
// The center section declares two arrangements and shows one; the hidden one
2644
// must not build its modules or every center widget exists twice.
2745
const moduleList = barSource.slice(barSource.indexOf('component ModuleList'), barSource.indexOf('component ModuleSlot'))

0 commit comments

Comments
 (0)