Skip to content

Have windows from an unplugged monitor redraw at their new scale - #670

Closed
oliverlukschander wants to merge 1 commit into
omacom:quattro-upstreamfrom
oliverlukschander:fix/chromium-redraw-after-unplug
Closed

oliverlukschander wants to merge 1 commit into
omacom:quattro-upstreamfrom
oliverlukschander:fix/chromium-redraw-after-unplug

Conversation

@oliverlukschander

Copy link
Copy Markdown

After a monitor is unplugged, Chromium windows that were on it can go on drawing at its scale, in a corner of the window, until they're resized. This has them redraw at the scale of the monitor they're on now.

Why

  • Hyprland 0.56.2 tells a window it has left a monitor only while that monitor is still enabled (CWindow::updateSurfaceScaleTransformDetails). So the windows of a monitor that's unplugged are never told they left it.
  • Chromium then keeps laying the window out at the old monitor's scale until the window next changes size. After a desk monitor at 1.25, a MacBook panel at 3 shows each Chromium window's content in about 40% of its tile.
  • Foot, moved the same way, draws correctly.

This is a workaround. Going by Hyprland's source, the cause lies in Hyprland and Chromium.

How

default/hypr/monitor-removal-redraw.lua, loaded right after monitor-removal.lua:

  • When a monitor is removed, every window open at that moment is marked.
  • 300 ms later, and whenever a workspace is shown, each marked window on a showing workspace gets one pixel more border, and its own border back 100 ms later. Nobody sees that resize, and afterwards the window draws at its monitor's scale.
  • Each window gets it once, and windows closed meanwhile are let go.

It doesn't depend on #638, which lists the bug as a known issue.

Testing

  • On hardware: a MacBook Pro 16" M2 Pro with a BenQ 27" 1440p on USB-C, Hyprland 0.56.2, Chromium 153.
    • Without the workaround, one of two unplugs left Chromium's windows cut, and toggling fullscreen repaired them.
    • With it, Chromium's windows drew correctly on the laptop after each of several unplugs.
  • Tests: test/shell.d/hyprland-monitor-removal-redraw-test.sh covers the timing, windows on hidden workspaces, one nudge per window, and windows opened or closed meanwhile. It, hyprland-monitor-removal-test.sh and architecture-gates-test.sh pass.

Built with Claude Code, and tried on my own machine. I can walk through any part of it in review.

🤖 Generated with Claude Code

Hyprland 0.56.2 tells a window it has left a monitor only while that monitor
is still enabled, so the windows of a monitor that's unplugged are never told
they left it. Chromium keeps laying such a window out at the scale of the
monitor it never left, drawing it in a corner of the window when the monitor
it's on now has another scale, until the window next changes size: after a
desk monitor at 1.25, a MacBook panel at 3 shows each Chromium window's
content in about 40% of its tile. Foot and the others draw at the right scale.

This is a workaround until Hyprland or Chromium fix it. Once a removal has
reached the clients, each window that was open then gets a pixel more border
when its workspace is showing, and its own border back a moment later: a
resize nobody sees, after which it draws at the scale of the monitor it's on.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@oliverlukschander

Copy link
Copy Markdown
Author

Closing: the Mac desktop now lives in upstream Omarchy, whose AGENTS.md asks for an upstream fix before a platform workaround, and I'm not taking this Hyprland/Chromium behaviour there. I keep the hook in my own build; the analysis is in the description above if anyone hits the same thing.

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.

1 participant