#16147

Preserve monitor layout when re-enabling a display

Openzihaomuwants to merge intofrom

Summary

Fixes #15986 by preserving an existing output rule when a display is re-enabled from the Display panel.

Cause and fix

toggleDisplay() disables an output with disabled = true, but its enable command also supplies mode = "preferred", position = "auto", and scale = "auto". hl.monitor() updates the existing rule, so these values overwrite a user's monitor layout. A portrait output configured on the left can return on the right at another scale and mode.

Change the enable command to supply only output and disabled = false. The existing output rule retains its remaining fields. The disable command, output-name escaping, and last-enabled-display guard keep their existing behavior.

This is one command replacement with an explanatory comment, plus focused regression coverage. No config parsing, saved-layout cache, dependency, or migration is introduced.

Validation

Reproduced on Radeon 8060S using an AMD-accelerated, sandboxed nested Hyprland 0.56.2 compositor. The probe executes the actual panel function in a minimal JavaScript host and applies the generated commands to the compositor, using two headless test outputs for stable geometry.

ObservationBefore togglingOriginal panel after togglingPatched panel after toggling
Fractional portrait output position(0, 60)(1920, 0)(0, 60)
Scale1.2521.25
Mode1200×800 @ 60 Hz1920×1080 @ 60 Hz1200×800 @ 60 Hz
Separate custom-mode case1024×768 @ 75 Hz1920×1080 @ 60 Hz1024×768 @ 75 Hz

Three native scenarios each run three toggle cycles. Every fixed cycle preserves the named output's position, mode dimensions, refresh, scale, transform, and enabled state; the anchor output is unchanged. Configuration errors are checked and screenshots are inspected.

The new regression fails against the original panel, then passes with the patch. 60 focused automated checks pass: 12 toggle checks, 21 monitor-model checks, 5 monitor-state checks, 8 output-name checks, and 14 scaling checks. Bash syntax and whitespace checks also pass.

OMARCHY_PATH="$PWD" bash test/shell.d/monitor-toggle-test.sh
OMARCHY_PATH="$PWD" bash test/shell.d/monitor-test.sh
OMARCHY_PATH="$PWD" bash test/shell.d/monitor-state-test.sh
OMARCHY_PATH="$PWD" bash test/shell.d/monitor-output-name-test.sh
OMARCHY_PATH="$PWD" bash test/shell.d/monitor-scaling-test.sh
bash -n test/shell.d/monitor-toggle-test.sh
git diff --check

Validation boundary

The reported configuration names each output explicitly. An additional custom wildcard-rule control loses inherited mode/scale values after toggling on both original and patched sources, because the output-specific disable rule does not retain them. This patch addresses the existing named-rule overwrite in #15986; that inherited-rule behavior remains unresolved.

The native comparison exercises compositor rule updates and rendering. Physical DisplayPort hotplug, suspend, and a complete Quickshell panel-click flow were not tested. Related #7036 changes the same function for internal-panel ownership and should be coordinated if it lands first.

Activity

2
greptile-apps[bot]11h ago

Confidence Score: 5/5

[Medium impact] This focused change appears safe to merge.

Summary

Re-enabling a display now changes only disabled, leaving the existing named rule’s other settings untouched.

  • Re-enabled monitors keep their existing layout.

Review checks were static; no tests or compositor checks were run during this review.

Reviews (1) · Last reviewed commit: "Preserve monitor layout when re-enabling..." · Reviewed by Greptile