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'