Skip to content

binds: drag_threshold for click/drag isolation #9839

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

Merged
merged 2 commits into from
Apr 12, 2025

Conversation

alaricljs
Copy link
Contributor

This code was abandoned in #9658 and I'm picking it back up.

New features

Added binds:drag_threshold to yoink windows with mouse binds only after moving a few pixels
Added bindc / bindg (click / drag) flags for release binds that check if inside/outside drag_threshold on release

Threshold handling is slightly different whether there is a bindm on the same button or not:

If there is no bindm on the same button, any amount of movement that ends inside the threshold will trigger a click
If bindm exists and has been triggered, returning inside the threshold will not trigger a click (triggers drag)

These are mutually exclusive.

Simple example that adds more window handling to the same 2 buttons:

binds {
drag_threshold = 20
}

bindm = SUPER, mouse:272, movewindow
bindc = SUPER, mouse:272, togglefloating
bindm = SUPER, mouse:273, resizewindow
bindc = SUPER, mouse:273, fullscreen

Thoughts

The default threshold = 0 should work like current default behavior, i.e. windows are grabbed immediately on mousedown. With threshold > 0 yoinking happens later on mousemove.

This probably obsoletes #8143 and fixes #9631.

Is it ready for merging:

@alaricljs alaricljs force-pushed the feat-drag-threshold branch from 4ac0cef to c161848 Compare April 3, 2025 01:43
@vaxerski
Copy link
Member

vaxerski commented Apr 5, 2025

ping me tomorrow pls

@alaricljs
Copy link
Contributor Author

ping @vaxerski, a day late but I'm not at my desk much on weekends.

Copy link
Member

@vaxerski vaxerski left a comment

Choose a reason for hiding this comment

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

looks pretty ok to me. Needs a wiki mr

@alaricljs
Copy link
Contributor Author

@vaxerski hyprwm/hyprland-wiki#1023

Feedback?

@vaxerski
Copy link
Member

vaxerski commented Apr 9, 2025

hm. Now that I look at it, wouldn't c and g be better as extensions to m?

bindmc bindmg

and error out if it's not m? Otherwise it's less intuitive

@Dregu
Copy link

Dregu commented Apr 9, 2025

I originally though about including the m too, but decided it would also be confusing, because m implies you can only use mouse binds, which is not true at all with c/g. I guess it's just about how you document it. In the end I did it this way simply because I thought the other way would've made the flag parsing code and documentation more complicated for me, and obviously I'm lazy.

Anyway glad you picked this up again.

@alaricljs
Copy link
Contributor Author

As Dregu points out, the drag_threshold is measured for c, g, and m bind flags. c and g are only applicable to non-m binds since drag_threshold is fundamentally part of bindm. Are you looking to have a bindm option to toggle off drag_threshold?

@alaricljs
Copy link
Contributor Author

I've pushed a wiki change with hopefully a clearer explanation/description.

@vaxerski
Copy link
Member

yes, that's clearer. Thanks

@vaxerski vaxerski merged commit 6538970 into hyprwm:main Apr 12, 2025
12 checks passed
@nnyyxxxx
Copy link
Contributor

ugh. this reverts a few commits

@nnyyxxxx
Copy link
Contributor

nnyyxxxx commented Apr 13, 2025

It was nearly at the finish line. I removed the duplicate modifactions of layout: center floating window at cursor when picked up from fullscreen #9780

that's wrong since you are moving the same affected codepaths around, #9658 (comment) vaxry was wrong here as well #9780 should have been superseded by #9658

@Dregu
Copy link

Dregu commented Apr 13, 2025

Oh no exactly the thing I said would happen happened /s

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.

mutually exclusive bindm and bind on the same mouse button
4 participants