Hang the Control Center where every other popover hangs

Five surfaces sat 12 pixels under the bar -- the date menu, the activity panel,
notification toasts, signal glass and the clipboard, all using barGap * 2. The
Control Center sat at 2, through a constant of its own, which left the widest
surface in the shell hanging ten pixels higher than the date menu beside it.

That constant arrived with the original Control Center and carried no reason,
while barGap directly above it explains itself. The clipboard even cites
QuickSettings in a comment for how it derived its own margin, and still landed
on 12. It reads as an early value nothing else converged on rather than a
decision, which is why it is going rather than being documented and kept.

The contract that guarded it pinned the literal, and that same file already
records where pinning a literal led: it once asserted the buggy margin
expression, so the code and the test agreed and a 38-pixel gap was invisible to
both. Replacing one number with another would have repeated it. It now reads the
top margin out of the Control Center and out of the date menu and requires them
to match, so drift in either direction fails -- verified by moving each one in
turn and watching it break.

Claude-Session: https://claude.ai/code/session_01BRvzt4H8XXLPVH5MyYdk9L
This commit is contained in:
Gabriel Brown
2026-08-20 13:41:12 -04:00
parent 495fb9b41b
commit 23141673a2
3 changed files with 18 additions and 8 deletions
-1
View File
@@ -135,7 +135,6 @@ Singleton {
readonly property int popoverPadding: 14 readonly property int popoverPadding: 14
readonly property int popoverWidth: 380 readonly property int popoverWidth: 380
readonly property int controlCenterWidth: 430 readonly property int controlCenterWidth: 430
readonly property int controlCenterTopGap: 2
readonly property int cardRadius: 12 readonly property int cardRadius: 12
readonly property int pillRadius: 999 readonly property int pillRadius: 999
@@ -30,7 +30,11 @@ PanelWindow {
// against the top edge rather than hanging under nothing. // against the top edge rather than hanging under nothing.
anchors.top: true anchors.top: true
anchors.right: true anchors.right: true
margins.top: Theme.controlCenterTopGap // The same gap every other popover uses. This had its own constant set to
// 2, which left the widest surface in the shell hanging ten pixels higher
// than the date menu beside it -- an early value nothing else converged on
// rather than a decision; it carried no reason, while barGap does.
margins.top: Theme.barGap * 2
margins.right: Theme.barSideMargin margins.right: Theme.barSideMargin
exclusiveZone: 0 exclusiveZone: 0
+13 -6
View File
@@ -66,18 +66,25 @@ start_test_shell() {
rg -Fq 'readonly property int controlCenterWidth: 430' \ rg -Fq 'readonly property int controlCenterWidth: 430' \
"$source_config_path/config/Theme.qml" \ "$source_config_path/config/Theme.qml" \
|| fail 'approved Control Center width is missing' || fail 'approved Control Center width is missing'
rg -Fq 'readonly property int controlCenterTopGap: 2' \
"$source_config_path/config/Theme.qml" \
|| fail 'approved top attachment is missing'
# The margin is the GAP alone. This used to assert the bar height plus the gap, # The margin is the GAP alone. This used to assert the bar height plus the gap,
# which is what the code said and what made the panel open 38 pixels below a bar # which is what the code said and what made the panel open 38 pixels below a bar
# it was written to sit 2 pixels under: an exclusiveZone of 0 already places the # it was written to sit 2 pixels under: an exclusiveZone of 0 already places the
# surface below the bar's reserved space, so naming the bar height again counted # surface below the bar's reserved space, so naming the bar height again counted
# it twice. The contract agreed with the code and so the bug was invisible to # it twice. The contract agreed with the code and so the bug was invisible to
# both. layer-margin-contract now holds that rule for every surface. # both. layer-margin-contract now holds that rule for every surface.
rg -Fq 'margins.top: Theme.controlCenterTopGap' \ # Asserted as a RULE rather than a literal, and derived from two files so that
"$quicksettings_path/QuickSettings.qml" \ # drift in either direction fails. The Control Center used to carry its own gap
|| fail 'Control Center is not tightly attached to the bar' # constant set to 2 while every other popover used barGap * 2, leaving the widest
# surface in the shell hanging ten pixels higher than the date menu beside it.
# Pinning the new number here would repeat the mistake this file already records
# below: a contract that agrees with the code cannot see the code being wrong.
control_center_gap="$(rg -o 'margins\.top: (.+)$' -r '$1' "$quicksettings_path/QuickSettings.qml" | head -1)"
date_menu_gap="$(rg -o 'margins\.top: (.+)$' -r '$1' "$source_config_path/modules/datemenu/DateMenu.qml" | head -1)"
[[ -n "$control_center_gap" ]] || fail 'Control Center sets no top margin at all'
[[ "$control_center_gap" == "$date_menu_gap" ]] \
|| fail "Control Center hangs at '$control_center_gap' while the date menu uses '$date_menu_gap'"
rg -Fq 'implicitWidth: Theme.controlCenterWidth' \ rg -Fq 'implicitWidth: Theme.controlCenterWidth' \
"$quicksettings_path/QuickSettings.qml" \ "$quicksettings_path/QuickSettings.qml" \
|| fail 'Control Center window does not use its geometry token' || fail 'Control Center window does not use its geometry token'