Skip to content
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

binding: match single-key bindings if no multi-key binding matched #3021

Merged
merged 1 commit into from
Nov 3, 2018

Conversation

Snaipe
Copy link
Contributor

@Snaipe Snaipe commented Oct 29, 2018

This makes bindings more snappy when the user is typing faster than
his keycaps are releasing.

Signed-off-by: Franklin "Snaipe" Mathieu me@snai.pe

This makes bindings more snappy when the user is typing faster than
his keycaps are releasing.

Signed-off-by: Franklin "Snaipe" Mathieu <me@snai.pe>
@ddevault
Copy link
Contributor

I'm not sure what this is trying to accomplish.

@Snaipe
Copy link
Contributor Author

Snaipe commented Oct 29, 2018

This is something that has been biting me. Essentially, consider the following config:

bindsym Left focus left
bindsym Up focus up

If you press Left, then Up while still releasing Left, then there's a chance that the keypress for Up happens while the keypress for Left isn't quite completely released, which makes the binding resolution try to find a binding for Left+Up. When Left is completely released, you're left with the Up key pressed, and the binding for Up not running.

These sorts of things happen quite often when using movement bindings, which are pretty much used in rapid succession.

This patch essentially makes the Up binding run as soon as it is pressed if, and only if, there is no Left+Up binding already taking precedence.

@Snaipe
Copy link
Contributor Author

Snaipe commented Oct 29, 2018

Another way to put it:

Press and hold Left, then press Up, then release Left. In i3, this makes the binding for Left run, then the binding for Up run. In sway, only the binding for Left runs.

@ddevault
Copy link
Contributor

Hm.

@Snaipe
Copy link
Contributor Author

Snaipe commented Oct 29, 2018

Sorry, I might have not explained that too well. Is something the matter?

@ddevault
Copy link
Contributor

Just thinking it over, even if i3 does that I'm not sure it's the right behavior.

@Snaipe
Copy link
Contributor Author

Snaipe commented Oct 29, 2018

Oh, my point about i3 is more about comparison more than a compatibility thing.

I think Sway's current behaviour is correct when taking into account that bindings can have multiple non-modifiers keys, but at the same time, I'm inclined to believe that the vast majority of bindings out there are single-key (in fact, sway's default config doesn't have multi-key bindings).

Triggering single-key bindings when no multi-key binding has matched seems like a sensible middle ground.

What it does mean, however, is that if a user defines the bindings b and a+b+c, and presses+hold a, then b, then c, then both bindings will be executed. It's weird, but I think it's also consistent with the fact that if a user defines a and a+b, and presses+hold a then b, then both bindings are executed (this is what Sway is currently doing).

@ddevault ddevault merged commit c18cd9d into swaywm:master Nov 3, 2018
@ddevault
Copy link
Contributor

ddevault commented Nov 3, 2018

Thanks!

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

Successfully merging this pull request may close these issues.

None yet

2 participants