Skip to content

Fix monitor scaling toggle for multi-monitor setups#4778

Open
tmn73 wants to merge 1 commit intobasecamp:devfrom
tmn73:fix/monitor-scaling-preserves-position
Open

Fix monitor scaling toggle for multi-monitor setups#4778
tmn73 wants to merge 1 commit intobasecamp:devfrom
tmn73:fix/monitor-scaling-preserves-position

Conversation

@tmn73
Copy link
Copy Markdown
Contributor

@tmn73 tmn73 commented Feb 27, 2026

Problem

On multi-monitor setups, using Super+/ to cycle monitor scaling causes several issues:

  1. Monitor positions swap. The script used auto for position, which at runtime places monitors by hardware detection order (internal display first) rather than config order — swapping left/right.

  2. Mouse can't cross between monitors. Changing a monitor's scale changes its logical width (e.g. 2560px at 1x → 1600px at 1.6x), but adjacent monitors aren't repositioned — leaving a dead zone the mouse can't cross.

  3. Window gaps and layout settings are lost. hyprctl keyword monitor resets layout properties like gaps_in, gaps_out, border size, and rounding.

  4. Position drift after full cycle. Using relative deltas to reposition monitors causes cumulative drift (e.g. 53px after a 1x→1.6x→2x→3x→1x cycle) because Hyprland auto-adjusts positions between sequential commands.

Fix

  • Preserve position: use each monitor's current x/y instead of auto.
  • Reposition adjacent monitors with absolute positioning: compute exact positions from scratch (active_x + new_logical_width, then stack each subsequent monitor) to avoid drift from Hyprland's inter-command adjustments.
  • Order operations to prevent overlap warnings: when the monitor gets wider (scale decreasing), move adjacent monitors out of the way first; when it gets narrower (scale increasing), scale first, then close the gap.
  • Preserve current mode: use each monitor's actual width x height @ refreshRate instead of preferred, which may select a lower refresh rate.
  • Restore layout settings: re-source looknfeel.conf after reconfiguration to restore gaps, borders, rounding, and other layout properties.

Note

Only repositions monitors to the right of the active one. This covers the common layout (laptop + external to the right). Monitors to the left are unaffected.

Testing

Tested on a 2-monitor setup (external left at 2560x1440@360Hz + laptop right at 2560x1600@240Hz) through full scale cycles (1x → 1.6x → 2x → 3x → 1x) on both monitors. Positions return to exact original values after a full cycle, mouse movement works at every scale, no overlap warnings, and layout settings are preserved.

Copilot AI review requested due to automatic review settings February 27, 2026 11:37
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot wasn't able to review any files in this pull request.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@tmn73 tmn73 marked this pull request as draft February 27, 2026 12:03
Copilot AI review requested due to automatic review settings February 27, 2026 12:11
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot wasn't able to review any files in this pull request.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@tmn73 tmn73 force-pushed the fix/monitor-scaling-preserves-position branch from 7b45989 to 253c617 Compare February 27, 2026 12:16
@tmn73 tmn73 changed the title Fix monitor scaling toggle swapping positions on multi-monitor setups Fix monitor scaling toggle for multi-monitor setups Feb 27, 2026
@tmn73 tmn73 force-pushed the fix/monitor-scaling-preserves-position branch from 253c617 to edb2395 Compare February 27, 2026 12:20
Copilot AI review requested due to automatic review settings February 27, 2026 12:20
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot wasn't able to review any files in this pull request.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@tmn73 tmn73 force-pushed the fix/monitor-scaling-preserves-position branch from edb2395 to 4643b23 Compare February 27, 2026 12:31
@tmn73 tmn73 marked this pull request as ready for review February 27, 2026 12:33
Copilot AI review requested due to automatic review settings February 27, 2026 12:33
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot wasn't able to review any files in this pull request.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@joaobnobre
Copy link
Copy Markdown

+1, reproduces on my dual 1080p setup (HDMI-A-1 at 0x0, DP-2 at 1920x0). Every Super + / flips DP-2 to 0x0 and shoves HDMI-A-1 out of place. I had independently patched just the autox,y part locally and that alone fixes the position swap — glad to see this PR also covers the logical-width gap, operation ordering, and the looknfeel reset. Hope it lands in dev soon.

@joaobnobre
Copy link
Copy Markdown

Heads-up @tmn73 — this PR targets bin/omarchy-hyprland-monitor-scaling-toggle, but that file was renamed to -cycle the day after you opened this (commit 8f5c1ee5 "Promote monitor scaling to Super + /" — pure git mv, zero content changes). Since then 39f1ca77 landed a partial refresh-rate fix that overlaps a bit with yours. As it stands GitHub can't auto-merge this PR because the target path no longer exists upstream.

If you're around and want to rebase onto the renamed -cycle file, your fix is meaningfully more complete than what I'm about to submit (I'm only tackling the autox,y position piece). Happy to close mine in favor of yours if you update this one.

joaobnobre added a commit to joaobnobre/omarchy that referenced this pull request Apr 11, 2026
The cycle script passed `auto` as the monitor position to
`hyprctl keyword monitor`, which makes Hyprland re-auto-place
the monitor based on hardware detection order rather than its
configured position. On multi-monitor setups this swaps monitor
positions every time Super + / is pressed.

Capture the monitor's current x,y from `hyprctl monitors -j`
(already parsed into $MONITOR_INFO) and pass it explicitly so
the layout stays stable.

Closes basecamp#4785. A more comprehensive fix was proposed in basecamp#4778
against the pre-rename `-toggle` file, but has not been rebased.
@tmn73
Copy link
Copy Markdown
Contributor Author

tmn73 commented Apr 11, 2026

On it

Heads-up @tmn73 — this PR targets bin/omarchy-hyprland-monitor-scaling-toggle, but that file was renamed to -cycle the day after you opened this (commit 8f5c1ee5 "Promote monitor scaling to Super + /" — pure git mv, zero content changes). Since then 39f1ca77 landed a partial refresh-rate fix that overlaps a bit with yours. As it stands GitHub can't auto-merge this PR because the target path no longer exists upstream.

If you're around and want to rebase onto the renamed -cycle file, your fix is meaningfully more complete than what I'm about to submit (I'm only tackling the autox,y position piece). Happy to close mine in favor of yours if you update this one.

@tmn73 tmn73 force-pushed the fix/monitor-scaling-preserves-position branch from 4643b23 to 68ee64e Compare April 11, 2026 18:52
@joaobnobre
Copy link
Copy Markdown

Rebase is clean — diff is +41/-4 against the current bin/omarchy-hyprland-monitor-scaling-cycle, applies without conflicts. Closing my stopgap #5278 in favor of this one.

Quick notes from reading the diff:

  • Adjacent-monitor logic only touches monitors to the right (.x > $ax) — correct, since left-side monitors' positions don't depend on the focused monitor's width.
  • Refresh rate | round handles fractional rates like 240.00101 cleanly.
  • Commit subject still references Super+Ctrl+Backspace (the pre-rename binding) — cosmetic only.

+1 on behalf of a user reproducing the bug. Thanks for the fast rebase @tmn73 — hope this lands soon.

Preserve monitor positions when cycling display scales with
Super+/ on multi-monitor setups.

The original script used `auto` positioning which, at runtime via
hyprctl keyword, uses hardware detection order (internal display first)
rather than config order — swapping monitor positions.

This fix:
- Uses each monitor's current absolute position instead of `auto`
- Repositions adjacent monitors to account for logical width changes
- Uses absolute positioning to prevent cumulative drift across cycles
- Orders operations to avoid overlap warnings (wider → move first, narrower → scale first)
- Preserves current mode/refresh rate instead of `preferred` (which may pick a lower refresh rate)
- Re-sources looknfeel.conf to restore layout settings reset by monitor reconfiguration
@tmn73 tmn73 force-pushed the fix/monitor-scaling-preserves-position branch from 68ee64e to df8b86b Compare April 11, 2026 19:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants