Skip to content

fix: clamp tiling windows with their working rects #1043

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

mzhu-zx
Copy link

@mzhu-zx mzhu-zx commented Apr 25, 2025

If a window is on the edge of the monitor and has a large shadow border, the computed rectangle can exceed it ancestor monitor's the working rectangle, which places it on a neighbor monitor instead. The DWM will render the window either too long or too wide in a dual monitor setting where two monitors of different sizes are not perfectly aligned.

To fix this, a new function clamp_strictly is added to restrict all computed rectangles in tiling mode to the working rectangle of the ancestor monitor. The existing clamp function cannot guarantee this. Consider rectangles in (x, y, w, h): (0, 0, 3, 3) and (1, 1, 3, 3) where the latter is the outer. The intersection of those 2 rectangles needs to have width and height 2 instead of 3.

@github-project-automation github-project-automation bot moved this to 📬 Needs triage in glazewm Apr 25, 2025
@lars-berger
Copy link
Member

@mzhu-zx Thank you for the PR! 🙌

I just tried your fix branch - it's clamping successfully to the bounds of the monitor. Added a fix just now so that it only affects tiling windows (e.g. to allow floating windows in between the edges of two monitors).

However, I'm having trouble finding an example window to test this out with. Would you mind showing a screenshot of a window with excessive window borders before/after the fix?

A problem I'm noticing with the fix is that it causes the windows to not take up the proper width/height with 0px outer gaps:
image

Also, not sure if this affects your use case but there's an adjust-borders command available for tweaking window-specific borders.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: 📬 Needs triage
Development

Successfully merging this pull request may close these issues.

2 participants