Skip to content

add new focus_fit_method: clamped_center#13345

Draft
egormalyutin wants to merge 2 commits intohyprwm:mainfrom
egormalyutin:feature-clamped-center
Draft

add new focus_fit_method: clamped_center#13345
egormalyutin wants to merge 2 commits intohyprwm:mainfrom
egormalyutin:feature-clamped-center

Conversation

@egormalyutin
Copy link

Describe your PR, what does it fix/add?

I like center focus_fit_method, however I think it looks cringy when I focus the last strip:

2026-02-23.19-22-06.mp4

This PR adds a new focus_fit_method called clamped_center (2) which combines best of the fit and center worlds:

2026-02-23.19-22-44.mp4

No ugly empty space past the last strip now.

I also removed some code duplicating the centerOrFitCol contents.

Is there anything you want to mention? (unchecked code, possible bugs, found problems, breaking compatibility, etc.)

Is it ready for merging, or does it need work?

Idk seems to work

@github-actions
Copy link

Hello and thank you for making a PR to Hyprland!

Please check the PR Guidelines and make sure your PR follows them.
It will make the entire review process faster. :)

If your code can be tested, please always add tests. See more here.

beep boop, I'm just a bot. A real human will review your PR soon.

CScrollingAlgorithm::layoutMsg
@nnra6864
Copy link
Contributor

This is really interesting, I could definitely see myself using it.
I would like to note that since this is an actual option now, would it be possible to make the center method also center the leftmost(first) window?
I find it really awkward that since the layouts rewrite, everything except the first window gets centered, it's really annoying on a super ultrawide.
I mentioned this issue in a forum post too:
https://forum.hypr.land/t/scrolling-layout-regressions/1427

Appreciate the work you've done!

@egormalyutin
Copy link
Author

@nnra6864 you want something like this?

2026-02-24.11-57-29.mp4

As you see here, if the tape fits into viewport, windows are centered "as a whole". However there's another possibility - to always align viewport with the centered window, even if windows fit into viewport:

2026-02-24.12-00-41.mp4

I think it's better to give the user the both choices. Also now I think it's better to remove clamped_center and instead introduce config options like allow_empty_space_before_first_strip_when_centering and allow_empty_space_after_last_strip_when_centering (idk about naming xD).

What's causing your issue is CScrollTapeController::calculateCameraOffset which replaces negative offsets with 0 and centers the content if it fits into viewport, so I just removed it. I'm not quite sure though, maybe I broke some logic here. Code looks very fragile here (and not just here haha)

@egormalyutin
Copy link
Author

egormalyutin commented Feb 24, 2026

Also I kinda don't like that current scrolling code assumes that user scrolls the tape using keyboard or whatever or by focusing nearby clients. I don't think there's currently a way to scroll using mouse wheel or touchpad gestures without causing viewport alignment, just like I scroll a page in my browser?

@egormalyutin egormalyutin marked this pull request as draft February 24, 2026 12:34
@nnra6864
Copy link
Contributor

nnra6864 commented Feb 24, 2026

What you implemented above is exactly what I was talking about, it's perfect!
I would personally prefer the option where the focused window is always centered, but I can definitely see other preferring the option where if everything fits, it just fits, both are great.
As for scrolling with a mouse wheel, I genuinely have 0 clue.
The only tip I can give you for using mwheel binds is to set binds:scroll_event_delay = 1(it's 300 by default), otherwise, you might end up scrolling to a browser, and then the next scroll counts not as a bind, but an actual scroll in a browser.
Well that's at least what happened to me when making a zoom bind, I could just be slow tbh.

@egormalyutin
Copy link
Author

@nnra6864 okay. I'm currently not sure how to organize my changes, as I noticed some other scroll related bugs and fixed them (and for some I did not 🤪), so maybe I'll split them into different PRs or idk. I'm not really familiar with this code base very much and vaxry seems to frequently change some things so idk what are the chances of these changes ending up in the upstream

@vaxerski
Copy link
Member

rebase needed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants