Skip to content

Preserve monitor layout when re-enabling a display - #16147

Merged
dhh merged 1 commit into
omacom:quattrofrom
zihaomu:fix/15986-monitor-layout
Oct 21, 2026
Merged

dhh merged 1 commit into
omacom:quattrofrom
zihaomu:fix/15986-monitor-layout

Conversation

@zihaomu

@zihaomu zihaomu commented Oct 21, 2026

Copy link
Copy Markdown
Contributor

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.

Observation Before toggling Original panel after toggling Patched panel after toggling
Fractional portrait output position (0, 60) (1920, 0) (0, 60)
Scale 1.25 2 1.25
Mode 1200×800 @ 60 Hz 1920×1080 @ 60 Hz 1200×800 @ 60 Hz
Separate custom-mode case 1024×768 @ 75 Hz 1920×1080 @ 60 Hz 1024×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.

Only update the disabled field when enabling an output from the Display panel. Let the existing named monitor rule retain its mode, position, and scale, and cover command generation, output escaping, action launch, and the last-display guard.
@greptile-apps

greptile-apps Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence 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

@omarchybot

Copy link
Copy Markdown
Collaborator

Reviewed at 5f2b560. Nothing found to change, and nothing was pushed.

Reproduction, on a disposable Omarchy worker running Hyprland 0.56.2. Using a headless output with a named rule (mode = "1200x800@60", position = "-1200x0", scale = 1.25), the enable expression on quattro brought it back at 1920x1080, auto-placed to the right, at scale 2 — the bug in #15986. The expression this PR sends restored 1200x800 at -1200x0 and scale 1.25 across two toggle cycles, and a second rule with transform = 3 kept its rotation too. I also checked the two populations that could have relied on the dropped preferred/auto/auto fields: an output covered only by the default wildcard rule in config/hypr/monitors.lua, and an output that starts with a named disabled = true rule. Both come back identically under the old and new expressions, so nobody loses a sane default.

Tests, run on the same worker with the PR linked into the running shell: monitor-toggle-test.sh (12 passed), monitor-test.sh (21), and the other six test/shell.d/monitor-*-test.sh files, all green. With Panel.qml put back to quattro the new toggle test fails on the re-enable assertion, so it tests the fix and not merely that the file changed. The full shell suite was not run, since the change is one expression in one panel function.

Second opinion (Codex Medium): it found no defect and judged the change proportionate. It checked Hyprland 0.56.2's source and confirmed that hl.monitor copies an existing rule for the exact output name and applies only the fields given, which is the behaviour this fix depends on. It agreed with my conclusions, and its independence is not guaranteed. It also named two gaps that exist on quattro already and that this PR does not cause: a display configured through a desc: rule, or through a customised wildcard rule, still loses that layout, because disabling it by connector name creates a new named rule from defaults. Your validation notes already describe the wildcard case. Separately, bin/omarchy-hyprland-monitor-clamshell:173 still forces mode = "preferred" when it re-applies the internal display, which is the path #7326 tracks.

Related: #7036 rewrites the same toggleDisplay function from the old hyprctl keyword form and now conflicts with quattro. Whichever lands second will need its rebase to keep this behaviour.

This is waiting on the maintainer.

@omarchybot omarchybot added bug Something isn't working verified Omarchy Triage has verified that this issue is ready for final review labels Oct 21, 2026
@dhh
dhh merged commit f1d1e9c into omacom:quattro Oct 21, 2026
1 check passed
@emirb emirb added this to the 4.5 milestone Nov 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working verified Omarchy Triage has verified that this issue is ready for final review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Display panel enable/disable re-enables a monitor at position="auto", discarding the configured position

4 participants