Skip to content

Keep the focused workspace in front when a monitor is unplugged - #608

Merged
maralcbr merged 3 commits into
quattro-upstreamfrom
mac/98-keep-workspace-on-unplug
Sep 27, 2026
Merged

maralcbr merged 3 commits into
quattro-upstreamfrom
mac/98-keep-workspace-on-unplug

Conversation

@maralcbr

Copy link
Copy Markdown
Member

Unplugging the display you were working on switched you to the built-in panel's workspace; the one you were on ended up hidden behind it. That is Hyprland 0.56.2 itself, on every platform: CMonitor::onDisconnect warps focus to the first remaining monitor before it moves the removed monitor's workspaces over, so its "keep the active workspace active" branch never runs. Omarchy's monitor watcher doesn't touch workspaces on removal.

default/hypr/monitor-removal.lua reads the workspace of the monitor being left when that warp fires and, if a monitor.removed follows in the same event-loop turn, focuses it again. It gives way to any focus or workspace change made after the removal, leaves an open scratchpad alone, and does nothing if a future Hyprland changes the event order. The same path covers the lid disabling the panel in clamshell mode.

Testing:

  • New test/shell.d/hyprland-monitor-removal-test.sh replays Hyprland's disconnect event order (unplug while on the external, while on the panel, 3 monitors, stale focus, later focus/workspace change, empty/named workspaces, scratchpad, own restore, changed event order); fails without the fix. hyprland-* shell tests pass.
  • Nested Hyprland 0.56.2 on the M1 Pro, before/after: on the external's ws 5, unplug → before: ws 1 on the panel; after: ws 5 on the panel. On the panel, unplug → unchanged both ways. 3 monitors → focus stays on the middle one. Lid close via rule + reload → the panel's workspace stays in front on the external.
  • Owner check on the M2 pending (steps in ticket 98).

Second review: first pass found the tracked workspace went stale on monitor-only focus changes (fixed by reading the outgoing monitor); final pass found no blocking issues.

Hyprland warps focus to the first remaining monitor before moving the removed
monitor's workspaces over, so unplugging the display you were working on left
your workspace hidden behind the built-in panel's own. Refocus it.
monitor.focused fires before Hyprland records the new focus, so a tracked
value went stale on monitor-only focus changes. Read the outgoing monitor
instead, leave an open scratchpad alone, and give way to any focus or
workspace change the user makes before the restore runs.
@maralcbr
maralcbr merged commit f2e89a2 into quattro-upstream Sep 27, 2026
5 checks passed
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