Skip to content

Fix controls disappearing after dragging a window to another monitor - #2

Open
Qurtison wants to merge 1 commit into
DjaboDev:mainfrom
Qurtison:fix/adopt-window-on-monitor-change
Open

Qurtison wants to merge 1 commit into
DjaboDev:mainfrom
Qurtison:fix/adopt-window-on-monitor-change

Conversation

@Qurtison

@Qurtison Qurtison commented Oct 6, 2026

Copy link
Copy Markdown

Problem

After dragging a window to another monitor with the top-edge strip (or SUPER + drag), the minimize, maximize and close buttons disappear.

The drag controller moves windows with hl.dsp.window.move({ x, y, relative = false }). That changes the window's position but not the monitor or workspace Hyprland files it under. So once the drag ends, win.monitor still names the old monitor, and winMonitor falls back to it. The old monitor's overlay keeps hosting the controls at coordinates outside its own screen, so they can't be seen.

Reproduced on Hyprland 0.56.2 with two monitors (DP-1 3440×1440 at 0,0 and DP-2 1920×1080 at 3440,0): a floating window moved to x=4000 still reported monitor: DP-1, workspace: 1.

Fix

  • src/lua/mousefirst.lua: new MOUSE_FIRST.adopt(address, x, y, w, h). It finds the monitor under the window's top-center point, using the same logical size calculation as monitor_state. If that differs from the window's current monitor, it moves the window to that monitor's active workspace (follow = true) and re-applies the final size and position, because the workspace move shifts floating windows on its own.
  • src/js/hypr.js: evalAdopt() builder.
  • src/DragController.qml: _finish() calls it after the final move or snap. Both overlay drags and handed-over native drags go through this path.

It does nothing when the window stays on the same monitor.

Testing

  • node --test tests/*.test.mjs: 18/18 pass.
  • Moved a floating window to DP-2 coordinates and called MOUSE_FIRST.adopt. Afterwards Hyprland reported monitor: DP-2, workspace: 2 at the same position, and mousefirst status showed the active window on DP-2.

🤖 Generated with Claude Code

…kspace

The drag controller moves windows with absolute coordinates, which never
changes the monitor or workspace Hyprland files them under. A window
dropped on another monitor kept reporting its old monitor, so the overlay
for that monitor hosted the controls at coordinates outside its screen
and the buttons disappeared.

When a drag finishes, MOUSE_FIRST.adopt now checks which monitor the
window landed on and, if it changed, moves the window to that monitor's
active workspace and re-applies the final geometry.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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