From 23141673a2d3449a1f292b519abd9b8571ae7a95 Mon Sep 17 00:00:00 2001 From: Gabriel Brown Date: Thu, 20 Aug 2026 13:41:12 -0400 Subject: [PATCH] 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 --- config/dot/quickshell/config/Theme.qml | 1 - .../modules/quicksettings/QuickSettings.qml | 6 +++++- tests/quickshell/control-center-contract.sh | 19 +++++++++++++------ 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/config/dot/quickshell/config/Theme.qml b/config/dot/quickshell/config/Theme.qml index db3452c..882da56 100644 --- a/config/dot/quickshell/config/Theme.qml +++ b/config/dot/quickshell/config/Theme.qml @@ -135,7 +135,6 @@ Singleton { readonly property int popoverPadding: 14 readonly property int popoverWidth: 380 readonly property int controlCenterWidth: 430 - readonly property int controlCenterTopGap: 2 readonly property int cardRadius: 12 readonly property int pillRadius: 999 diff --git a/config/dot/quickshell/modules/quicksettings/QuickSettings.qml b/config/dot/quickshell/modules/quicksettings/QuickSettings.qml index edfe806..7724b35 100644 --- a/config/dot/quickshell/modules/quicksettings/QuickSettings.qml +++ b/config/dot/quickshell/modules/quicksettings/QuickSettings.qml @@ -30,7 +30,11 @@ PanelWindow { // against the top edge rather than hanging under nothing. anchors.top: 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 exclusiveZone: 0 diff --git a/tests/quickshell/control-center-contract.sh b/tests/quickshell/control-center-contract.sh index 0627b7f..8f6829e 100755 --- a/tests/quickshell/control-center-contract.sh +++ b/tests/quickshell/control-center-contract.sh @@ -66,18 +66,25 @@ start_test_shell() { rg -Fq 'readonly property int controlCenterWidth: 430' \ "$source_config_path/config/Theme.qml" \ || 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, # 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 # 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 # both. layer-margin-contract now holds that rule for every surface. -rg -Fq 'margins.top: Theme.controlCenterTopGap' \ - "$quicksettings_path/QuickSettings.qml" \ - || fail 'Control Center is not tightly attached to the bar' +# Asserted as a RULE rather than a literal, and derived from two files so that +# drift in either direction fails. The Control Center used to carry its own gap +# 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' \ "$quicksettings_path/QuickSettings.qml" \ || fail 'Control Center window does not use its geometry token'