Skip to content

Fix: apply gaps to half-tiles when maximize-with-gap is enabled - #456

Open
gabriel-kassai wants to merge 4 commits into
ubuntu:mainfrom
gabriel-kassai:fix-half-tile-gaps
Open

gabriel-kassai wants to merge 4 commits into
ubuntu:mainfrom
gabriel-kassai:fix-half-tile-gaps

Conversation

@gabriel-kassai

Copy link
Copy Markdown

Fixes #448.

Half-tiled windows lost their gaps on the maximized axis because verticalMaximize / horizontalMaximize apply set_maximize_flags(...), and Meta's maximize snaps the window to the full work-area extent, overriding the gapped rect from addGaps(). Quarter-tiles are unaffected (they use the override_constraints path, which preserves gaps); full maximize-with-gap is also unaffected (it already skips window.maximize() when gaps are on).

This makes the vertical/horizontal cases consistent: when maximize-with-gap is enabled they skip the maximize flag and fall through to the override_constraints branch, so half-tiles keep their configured gaps. When maximize-with-gap is off, behaviour is unchanged.

Trade-off (intentional, matches existing behaviour): a gapped half-tile is no longer reported to Meta as vertically/horizontally maximized — it's a normal constrained tile, exactly like a gapped quarter-tile and like the full maximize-with-gap window. Tile-group/restore behaviour is driven by the extension's own tiledRect/untiledRect tracking, not Meta's maximize state.

Testing: with gaps + maximize-with-gap on, half-tiles now show gaps on all four edges; with maximize-with-gap off, half-tiles behave as before. Verified on GNOME Shell 50 / Wayland.

Half-tiled windows lost their gaps on the maximized axis because
verticalMaximize / horizontalMaximize apply set_maximize_flags(...), and
Meta's maximize snaps the window to the full work-area extent, overriding the
gapped rect from addGaps(). Quarter-tiles are unaffected (they use the
override_constraints path, which preserves gaps); full maximize-with-gap is
also unaffected (it already skips window.maximize() when gaps are on).

When maximize-with-gap is enabled, skip the VERTICAL/HORIZONTAL maximize flag
so half-tiles fall through to the same gap-preserving override_constraints path
quarter-tiles use. When maximize-with-gap is off, behaviour is unchanged.

Fixes ubuntu#448

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a gaps regression for half-tiling (vertical/horizontal maximize) when the maximize-with-gap setting is enabled, by avoiding Meta’s maximize behavior that snaps windows to the full work-area and overrides the gapped rectangle.

Changes:

  • Skip applying VERTICAL / HORIZONTAL maximize flags when maximize-with-gap is enabled, so half-tiles keep gaps.
  • Let half-tiles use the same override_constraints-based path as quarter-tiles (and consistent with existing full maximize-with-gap behavior).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +241 to +243
// top/bottom (or left/right) gaps. Fall through to the override_constraints
// path used by quarter-tiles, which preserves gaps. Mirrors the
// full-maximize-with-gap handling above.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would be more concerned with what happens if window.override_constraints does not exist (i.e. on non-Ubuntu)?

gabriel-kassai and others added 3 commits September 15, 2026 18:00
The gap-preserving fallback for a half-tile is the override_constraints()
branch, which is not present on every Mutter build. Gate the new behaviour
on it so that where it is missing the VERTICAL/HORIZONTAL maximize flag is
still applied, keeping the previous behaviour instead of leaving the
half-tile unmaximized.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@gabriel-kassai

Copy link
Copy Markdown
Author

Sorry for the long silence here. I was away and then buried in school, and this fell off my radar. Thanks for the review and for the patience.

Also sorry for the commit noise above. I reverted the fix by accident while cleaning up the branch, then put it back. The current head is the one to look at.

You're right, and the first version was wrong on non-Ubuntu. Skipping the maximize flag only works because override_constraints() picks up the gapped rect. Where that isn't available there's nothing to replace it, so the half-tile just ends up unmaximized. The gaps would be kept, but the window is no longer in a maximized state, which changes how unmaximize and restore behave.

I've pushed a commit that gates the new path on window.override_constraints being present. Without it, the VERTICAL/HORIZONTAL flag is applied exactly as before. So the change is a no-op on those builds, and the fix only applies where the constraint path can actually honor the gaps.

That also covers the Copilot note about the comment wording. The comment now says the fallback is conditional and why.

One caveat: I've only tested this on Ubuntu 26.04 with GNOME Shell 50, where the bug reproduces. The unpatched-Mutter case is reasoned rather than tested, but it should now be the old behavior exactly.

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.

Bug Report: Top and bottom gaps are missing in vertical maximization tiling

3 participants