Skip to content

Keep follow_mouse with the monitor focus actually moved to - #16747

Open
AnPod wants to merge 4 commits into
omacom:quattrofrom
AnPod:fix-follow-mouse-monitor-focus-lag
Open

AnPod wants to merge 4 commits into
omacom:quattrofrom
AnPod:fix-follow-mouse-monitor-focus-lag

Conversation

@AnPod

@AnPod AnPod commented Oct 27, 2026

Copy link
Copy Markdown
Contributor

Fixes #16745

Problem

With window-mode (floating) workspaces in use, update_input() in default/hypr/workspace-modes.lua sets input.follow_mouse to 0 on a floating workspace and restores the user's value on tiled ones. It runs on both workspace.active and monitor.focused, but on monitor.focused it re-reads hl.get_active_workspace(), which at that moment can still report the workspace of the monitor the pointer just left. The stale result leaves follow_mouse one monitor behind: after moving from a floating-mode monitor to a tiled one, follow_mouse stays 0 and hovering between tiled windows no longer changes focus until another event fires.

Fix

The monitor.focused event passes the monitor it is for (Hyprland's LuaEventHandler.cpp dispatches it with the PHLMONITOR), and a monitor object exposes its own active_workspace — already used by default/hypr/monitor-workspaces.lua. The handler now passes that monitor's active workspace to update_input(), which falls back to hl.get_active_workspace() when no workspace is handed in (the workspace.active handler and M.apply() keep the old path).

Test

Extended test/shell.d/hyprland-workspace-layout-test.sh: the stub's active workspace is now mutable, and the new cases fire the monitor.focused subscription with a stale active-workspace report while the event's monitor carries a workspace of the opposite mode, in both directions, plus the no-monitor fallback. Without the fix the first new assertion fails (follow_mouse stays 0 after focus moves to a tiled monitor); with it the whole file passes. Verified: the test fails on clean quattro with the fix stashed and passes with it.

The monitor.focused handler re-read hl.get_active_workspace(), which can
still report the workspace of the monitor the pointer just left, leaving
input.follow_mouse one monitor behind: after moving from a floating-mode
monitor to a tiled one, hover focus stayed off. The event hands over the
monitor, whose own active workspace is already the right one, so the
handler now reads that and falls back to the active workspace when no
monitor arrives.

Fixes omacom#16745
@greptile-apps

greptile-apps Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5 · The PR appears safe to merge; no actionable defects were found.RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no actionable defects were found.

Summary

The PR makes pointer focus follow the workspace on the monitor that received focus.

  • Pointer focus settings now follow the focused monitor's workspace.

No actionable issues were found. Tests were inspected but not executed.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Monitor receives focus] --> B[Read its active workspace]
  C[Workspace event or mode update] --> D[Read globally active workspace]
  B --> E{Workspace floats?}
  D --> E
  E -->|Yes| F[Keep pointer events without hover focus]
  E -->|No| G[Restore saved input settings]
Loading

Reviews (3) · Last reviewed commit: "Keep pointer events on unfocused floatin..." · Reviewed by Greptile

update_input now takes a workspace, and the workspace.active handler passed Hyprland's event workspace straight into it. That workspace is not always the focused one: switching a monitor to an empty workspace with follow_mouse on hit-tests the pointer and can focus a window on another monitor, then still emits workspace.active for the workspace it switched to. Switching to an empty floating workspace that way turned follow_mouse off while a tiled monitor held focus. The handler goes back to reading the focused workspace, as it did before.

Co-Authored-By: Codex Medium <noreply@openai.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@omarchybot omarchybot added the verified Omarchy Triage has verified that this issue is ready for final review label Nov 2, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

Reviewed and verified on a worker VM built from the Omarchy ISO, running Hyprland 0.57.0, with a second headless monitor added so the pointer could move between a tiled monitor and one showing a floating-mode workspace.

The bug reproduces, and your fix resolves it. Before your commit, follow_mouse came out one monitor behind on every move, three times in a row: 0 on the tiled monitor and 1 on the floating one, which is what #16745 describes. With your commit it was 1 on the tiled monitor and 0 on the floating one every time, and switching workspaces with the keyboard or focusing a monitor by dispatch also gave the right value. Your new test fails on the unfixed code with "focus moving to a tiled monitor kept follow_mouse off" and passes with the fix. Hyprland's LuaEventHandler.cpp does pass the monitor to monitor.focused, and rawMonitorFocus emits that event before it updates the focused monitor that hl.get_active_workspace() reads, which explains why the old read was stale.

I pushed one fix to your branch (ba8169f). Because update_input now accepts a workspace, the unchanged hl.on("workspace.active", update_input) line started passing Hyprland's event workspace into it as well. That workspace is not always the focused one. Here is the case: keyboard focus on one monitor, the pointer over a window on the other, and the focused monitor switched to an empty floating-mode workspace. CMonitor::changeWorkspace hit-tests the pointer and moves focus to the window on the tiled monitor, but it still emits workspace.active for the floating workspace. I reproduced this on the worker. With your commit alone, follow_mouse ended at 0 while a tiled workspace had focus. The fix wraps the workspace.active handler so it reads the focused workspace again, as it did before your change and as your description says it should. It also adds one test case that fails without the wrapper. With the fix applied, that scenario gives 1 and every case above behaves the same.

Tests: ./test/cli and test/shell.d/hyprland-workspace-layout-test.sh (14 of 14) pass on the worker at ba8169f.

Second opinion: Codex Medium and muse-wonder (via pi, thinking high) reviewed it. Both agreed the monitor.focused fix is correct. Codex found the workspace.active regression described above, and I confirmed it in Hyprland's source before reproducing it. muse-wonder also suggested that the workspace swap and Omarchy's monitor reconcile could trigger it. I rejected those two paths: the swap only emits the focused monitor's workspace, and set_workspace on an unfocused monitor passes noFocus, so neither emits the event. Both models found nothing left to change in a second round on ba8169f. They can read this session's notes, so their agreement may not be independent.

Related: #16888 changes the same function for a separate bug (a runtime follow_mouse change being lost). It is not a competing fix. Both test additions land at the end of the same Lua block, so whichever merges second will need a small rebase of the test file.

What it waits on: CI. The test job on ba8169f failed in a single file, test/shell.d/dropdown-test.sh, a QML popup-geometry test that this change does not touch. That file passed 56 of 56 on a worker both on current quattro (a69b19f) and on quattro merged with this branch, so the failure looks unrelated to this change. Once CI is green, this is waiting on the maintainer.

omarchybot and others added 2 commits November 26, 2026 00:23
Fold the additional input handling from omacom#18568 into the older monitor-focus fix. follow_mouse=0 holds pointer events on the focused window; 2 lets an unfocused floating window receive hover and scroll without moving keyboard focus. Disable float_switch_override_focus while floating as well, so arriving from a tiled window does not override that choice, and restore both user settings on tiled workspaces.

Co-Authored-By: Random <65575762+rndaom@users.noreply.github.com>
Co-Authored-By: GPT-6 in Codex (effort not exposed) <noreply@openai.com>
@omarchybot omarchybot added verified Omarchy Triage has verified that this issue is ready for final review and removed verified Omarchy Triage has verified that this issue is ready for final review labels Nov 25, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

I folded #18568’s additional pointer handling into this branch in fd507e71010091a73c2db3f8e193fa3b46022271, crediting @rndaom as co-author. Floating workspaces use follow_mouse = 2 so unfocused windows receive hover and scroll events, and float_switch_override_focus = 0 to keep the tiled-to-floating override from taking keyboard focus. Tiled workspaces restore both user settings. The monitor-focus handler still reads the incoming monitor’s own workspace.

I tested this on an Omarchy ISO worker running Hyprland 0.57.2 with a second headless monitor. On the base, the input setting lagged one monitor behind in all three crossings each way, and an unfocused floating terminal received no pointer events. On this head, tiled workspaces got 1/1 and floating workspaces got 2/0; the unfocused terminal received motion and wheel events while keyboard focus stayed on the other window until a click. Restoring the base source reproduced both failures and broke both updated test files; restoring this head passed again.

Before: after five wheel notches over the unfocused terminal, it still shows lines 275–300

After: the same wheel input scrolls the unfocused terminal back to lines 210–236

./test/cli passed all 143 checks, hyprland-floating-workspaces-test.sh passed 44, and hyprland-workspace-layout-test.sh passed 14 on the worker. GPT-6 in Codex (reasoning effort not exposed), Opus 5.5 High, and muse-wonder via pi (thinking high) reviewed this head. Both second reviewers found no correctness defects and agreed it is proportionate; their independence is not guaranteed.

The first pointer event onto a window touching a monitor edge can still use the previous monitor’s setting, as on the base; this does not change Hyprland’s event ordering. #16888 remains a separate fix for restoring settings changed at runtime.

CI is green on this head, and Greptile scored it 5/5 with no findings. This waits on the maintainer to decide whether #18568’s floating-window pointer changes should ship together with the monitor-focus fix or remain separate.

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.

follow_mouse lags one monitor behind with window-mode workspaces: hover-focus stops working on tiled monitors

2 participants