Skip to content

Fit a floating window to the monitor it is moved to - #18143

Open
LOLCATATONIA wants to merge 20 commits into
omacom:quattrofrom
LOLCATATONIA:floating-fit-to-monitor
Open

LOLCATATONIA wants to merge 20 commits into
omacom:quattrofrom
LOLCATATONIA:floating-fit-to-monitor

Conversation

@LOLCATATONIA

@LOLCATATONIA LOLCATATONIA commented Nov 8, 2026 •

Copy link
Copy Markdown

What changes

Stacked on #18142 (Super + L keeping places), itself on #18141 (snapping), so their commits show here too.

Hyprland keeps a floating window's size when it moves to another monitor. A half moved from a laptop to a 1440p monitor is a narrow strip there, and a half moved back hangs off the laptop's screen.

  • Moved with Super + Shift + Ctrl + Arrow, a window in a tile, or close to one (within 5%, as after resizing it to a half by hand), takes that tile on the new monitor; any other window keeps its place and size relative to the screen, so moving it back gives it its own box again.
  • A window whose own limits refuse the scaled size is held within them, and still placed wholly on the screen.
  • A snap still waiting (a maximized window first gets its own size back) gives up if the window has moved to another monitor meanwhile.
  • Dragged onto another monitor and let go away from an edge, a window stays where it was put, shrunk to fit when it is larger than that screen; only on a floating workspace, so a dialog dropped onto a tiled one is left alone. Dropped on an edge, it snaps as before.

Lua learns of a move only after Hyprland made it, and not which monitor it came from, so o.workspaces.move_window_to_monitor reads the window's box before it moves and hands it to snapping (o.snap.carried). Only floating workspaces: a window moved to a tiled one tiles there as before. It uses near_tile from #18142, hence the stacking.

Verification

  • ./test/all: see Snap windows on floating workspaces #18141 (run on the whole stack).
  • On this PR: the floating-workspaces and monitor-workspaces tests pass, with geometry checks for a half carried to a larger monitor, a hand-resized near-half carried as a half, a free window's relative box, and a box fitted inside a smaller screen. The move and drop handlers have tests of their own on two monitors: a half moved by key, a window held at its minimum size staying on screen, a window too big for the laptop dropped onto it, and a dialog dropped onto a tiled workspace left alone (66 to 69 checks).
  • In a nested Hyprland 0.57.1 with a real Omarchy config, on a laptop at 1.5 beside a 2560x1440 monitor (5 checks on top of the snapping PR's 18): a half moved by key both ways, a hand-resized near-half, a free window at twice the size and back within a few pixels, and a window bigger than the laptop dragged onto it.
  • In use on my laptop with an external monitor.

Screenshots

Not recorded: it needs two monitors. The snapping PR (#18141) has a recording of what it builds on, and the two-monitor checks above run on a laptop at 1.5 beside a 2560x1440 monitor. Happy to add screenshots if it helps.

🤖 Generated with Claude Code

QuixoticGitHub and others added 4 commits November 8, 2026 10:39
Super + arrows put the window in that half, then a quarter (KWin's rules), and
towards the edge it is against already they maximize it; anywhere but a
floating workspace they move focus as before. Dragging a window to a side edge
snaps it to that half, near a corner to a quarter, and to the top edge
maximizes, with an outline of the target drawn by a new shell plugin; on an
edge shared with another monitor it snaps only after a pause. A snapped window
dragged away gets its size back, and a window too large for a tile is left as
it is. The drags come from the titlebars plugin's hyprbars.drag_* events.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A window the floating mode opens beside snapped ones goes into the one tile
they leave free: the right half beside a left half, the fourth quarter beside
three. With the screen filled exactly, the half used last makes room, keeping
its top (or left) quarter. Closing a window on a quarter gives its space back
to the window sharing its half. Only snapped windows are arranged, never while
one is maximized, and nothing else moves windows.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Floating a tiled workspace sized every window the same and centred them in a
cascade, a pile of cards. Each window now keeps the box tiling gave it: near a
half or quarter (within 5%) it becomes that snapped tile, any other box on
screen stays as it is, and one off the screen, such as a scrolling column,
joins the snapped windows as a new window would, on the half on its side.
Dragged away, a kept window takes the mode's comfortable size.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Hyprland keeps a floating window's size when it moves to another monitor, so
a half from a laptop was smaller than a half on a larger monitor, and one from
there hung off the laptop. Moved by Super + Shift + Ctrl + arrows, a window in
a tile, or close to one, takes that tile on the new monitor, and any other
keeps its place and size relative to the screen; Lua learns of the move only
afterwards, so the move command reads the window's box first. Dragged onto
another monitor and let go away from an edge, a window stays where it was
put, shrunk to fit that screen when it is larger.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@LOLCATATONIA
LOLCATATONIA marked this pull request as ready for review November 8, 2026 10:27
@greptile-apps

greptile-apps Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; both numbered findings are addressed.

Summary

This PR fits floating windows to the monitor they move to and builds on the stacked snapping changes.

  • Floating windows snap into halves, quarters, and maximized areas.
  • Floating windows keep a useful size and place when moved to another monitor.
  • Snapped windows make room for new windows and keep their layout when workspaces float.
  • The shell outlines where a dragged window will snap.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Move a window by key] --> B[Save its old box and monitor]
  B --> C[Move to the destination workspace]
  C --> D{Destination workspace floats?}
  D -->|No| E[Keep normal tiling behavior]
  D -->|Yes| F{Window matches a tile?}
  F -->|Yes| G[Take that tile on the destination]
  F -->|No| H[Scale its box and fit it to the screen]
  G --> I{Still on the expected monitor?}
  I -->|No| J[Cancel the delayed snap]
  I -->|Yes| K[Apply the snap]
Loading

Reviews (4) · Last reviewed commit: "Drop a waiting snap whose window moved t..." · Reviewed by Greptile

Comment thread default/hypr/window-snapping.lua Resolved
Comment thread default/hypr/window-snapping.lua Resolved
Comment thread default/hypr/window-snapping.lua Resolved
QuixoticGitHub and others added 12 commits November 17, 2026 17:24
Beside a shorter monitor only part of an edge is shared, so a drag could enter
a zone where the edge is outer, snapping at once, and slide on into the part
the other monitor shares without leaving the zone: the early return kept the
snap, and letting go there skipped the pause meant for crossing over. The drag
now keeps whether the edge under the pointer is shared, and starts over when
that changes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A snap from maximized first waits for the window's own size, and an arrow
pressed meanwhile read the window as it was, not the tile already asked for:
Left then Up gave the top half. A pending placement now carries its tile, and
the next arrow starts from it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts:
#	test/shell.d/hyprland-floating-workspaces-test.sh
On the first switch to floating in a session the titlebars plugin is only
asked for, and Hyprland loads it on the next config pass: windows kept in
place then took their whole tile, and the titlebar added afterwards stuck out
above it, so they no longer counted as snapped. The height now comes from
Omarchy's own titlebar setting rather than from the plugin. An app that draws
its own frame (Chromium, Omarchy's browser) gets no titlebar at all, so it is
tagged where that rule is made, and keeps its whole tile.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…g drops

Moved to another monitor, a window whose own limits refused the scaled size got
its old size back at the position worked out for the smaller box, partly off
a smaller screen. Its size is now held within its limits and the box fitted
onto the screen at that size. Dropped onto another monitor, a dialog landing
on a tiled workspace was fitted too; that is only for floating workspaces.
Both handlers, by key and by drag, now have tests of their own.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
On the first switch to floating in a session, windows are kept in place before
the titlebars plugin is in and before the rule marking apps that draw their own
frame applies, so a browser was left room for a titlebar it never gets. Once
the plugin is in, a window snapping placed whose box would be its tile with the
titlebar the other way round goes back into that tile; a window already in its
tile, or resized by hand, stays as it is. Checked with Chromium in a nested
Hyprland through the layout toggle's own reload.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Whether the edge under the pointer is shared is now asked on every motion in a
zone; the monitor layout behind it stays put during a drag, so it is read once.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Comment thread default/hypr/window-snapping.lua Resolved
Comment thread default/hypr/window-snapping.lua Resolved
QuixoticGitHub and others added 4 commits November 17, 2026 20:53
…our's

A closing window has lost its titlebar, so its tile was measured with a snapped
neighbour's decorations, which miss when one of them is a browser drawing its
own frame. It is now measured with the neighbour's decorations, then with a
titlebar more or less; the two differ by far less than any two tiles, so at
most one fits. Tested both ways round.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts:
#	test/shell.d/hyprland-floating-workspaces-test.sh
A snap from maximized waits for the window's own size first. A window moved to
another monitor meanwhile was pulled back to the tile on the old one; the snap
now gives up when the window is on another monitor by the time it runs, however
it got there.

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

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants