-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Inconsistent char output using Alt key binds in macOS #2017
Comments
What happens if you remove these bindings? This should be the case by default, since the alt modifier will automatically send escape codes. Also does it produce |
@chrisduerr with my settings it produced small letter b. Please note that the carrot before the small letter b (mentioned in my original post above) is different than actual character that you would get by pressing it on the keyboard! I removed my alacrity.yml file & restarted, which I believe causes alacrity to start with So it seems, at least on my end, the recent changes to automatically send escape code is not working! More examples (with default settings): |
It should send |
I just built alacrity on my laptop (macOS) too and it has the same issue as above! |
Might be interesting to show the output of In theory, it should print that the alt key is held down. |
Alacritty is run from iTerm with default settings: Option+I followed by B produces this output (produces Option+F followed by B produces this output (produces Alacritty is run from iTerm with my key bind settings: Option+I followed by B produces this output (produces Option+F followed by B produces this output (produces |
@spamwax Is this with |
in first one, I'm using the default settings where as you mentioned that setting is true. |
It shouldn't matter for the second one since keybindings automatically suppress alt escape characters anyways. I've got a little diff which should help with debugging this. It prints the exact characters that are written to the pty and bypasses potential issues with shell/cat. I'm interested in what this outputs when you use the default config without modified key bindings. diff --git a/src/input.rs b/src/input.rs
index 65b7b6c..a9d3207 100644
--- a/src/input.rs
+++ b/src/input.rs
@@ -748,7 +748,10 @@ impl<'a, A: ActionContext + 'a> Processor<'a, A> {
&& self.ctx.last_modifiers().alt
&& utf8_len == 1
{
+ println!("WRITING ^[{}", c);
bytes.insert(0, b'\x1b');
+ } else {
+ println!("WRITING {}", c);
}
self.ctx.write_to_pty(bytes); In theory this should print the following for you when pressing Option+I -> B:
And I'd assume this is output when pressing Option+F -> B:
|
I get identical outcomes! (Option+I -> B) with default settings:
with my key bindings I get:
for Option+F -> B (default settings)
Option+F -> B (my settings)
|
Okay, so I can see two issues here. The first issue is that the keys you're pressing are automatically being converted to modified keys. So LAlt + F -> ƒ. And LAlt + i -> ^. This is a more complicated issue and I'd like to put this on hold until I've figured out the other one. The second issue is that for some reason alt isn't sending escape sequences. To figure out why exactly that's not the case, I've created another small diff which should print even more debug info in the case that no escapes are written: diff --git a/src/input.rs b/src/input.rs
index 65b7b6c..b9efd0e 100644
--- a/src/input.rs
+++ b/src/input.rs
@@ -748,7 +748,14 @@ impl<'a, A: ActionContext + 'a> Processor<'a, A> {
&& self.ctx.last_modifiers().alt
&& utf8_len == 1
{
+ println!("WRITING ^[{}", c);
bytes.insert(0, b'\x1b');
+ } else {
+ println!("RECEIVED COUNT: {}", self.ctx.received_count());
+ println!("ALT SEND ESC: {}", self.alt_send_esc);
+ println!("UTF8 LEN: {}", utf8_len);
+ println!("ALT: {}", self.ctx.last_modifiers().alt);
+ println!("WRITING {}", c);
}
self.ctx.write_to_pty(bytes); Thanks a ton for your cooperation. Hopefully this can be quickly resolved. |
while i apply the path, i'd like to mention that behavior like LAlt + F -> ƒ seems to be mac specific and is related to diacritic as fas as I can tell. According to some, that PR has caused issues with Meta/Option key. |
The issues discussed in #209 should be resolved with the new The problem with your setup though is that it's not actually sending Ideally we'd want it to send |
Ah, so it turns out that these characters have a utf8 length of 2, so that's why the escape characters aren't printed. So the problem is just that when pressing alt and hitting f/i, that it's putting down modified characters. I think the only way to resolve this problem would be to request with our window library to not send combined characters whenever the alt key is held down and the |
so other than filing a bug, what would help motivate them to resolve this faster? :) |
I'm not sure if this is something that will be included in winit actually since most applications do not have this problem. This is kinda a mess macOS has created by using alt instead of something like an AltGr key. I'm not sure if there's a good solution for this problem. Reading through this whole thread again though, there are some new insights I have obtained. My main focus so far was making this work without having to add any key bindings, which should be the goal, however I kinda ignored that it didn't work with keybindings either. In theory, this should work great when manually adding key bindings. However it clearly does not. Alacritty currently ignores all characters while a keybinding is triggered. However that doesn't seem to be working here. This is the relevant part of your debug output (paraphrased):
Looking at this, it seems like the weird ^ character is received after the B character has been pressed. However it should be received after Would you mind verifying that this is really the case? That would be a separate issue in winit and I'm not sure what's going on. I'd assume it's true that |
Based on alacritty output, this is what's happening:
at this point i waited one minute then pressed B, then this is what got printed:
However you may be right that wininit is messing the order here, as in a native macOS app when I press Option+I, the app actually shows a weird ^ indicating it's waiting for next stroke: So it seems |
Okay, so I think I've got this figured out now. The Since I now actually know what exactly is going on, I'll open an issue upstream and link it here. Maybe we can figure something out. |
I've created an issue upstream to track a solution for this problem: |
This is a duplicate of #1610 . |
@eraserhd Thanks a lot for letting me know. Closing the other issue as duplicate since this one contains a lot more information about the issue at hand. |
Great news that your issue is fixed @spamwax! I had a request upstream to move the change into configuration, so that when |
yes I am. thanks for your PR. |
I don't believe it can distinguish at the event time. The |
Hi there. Where are we with all this? I'm still rather confused and although the mappings listed in the referenced post work for most cases they don't cover all key-combos and I'm running into more and more things that don't work as expected (especially in emacs which relies heavily on all kinds of key combos). Are the patches to the upstream library integrated yet? Is there a branch of this code that fixes things more permenently? Thanks in advance for your help. Jamie |
No to both of those. It's work in progress, but there's very little macOS development capacity. |
Hello @jkp, I live in emacs and running the patch listed in rust-windowing/winit#1449 has covered all emacs bindings that I can realistically test as one person. Would you mind testing out the branch listed in the PR? I can always update against the latest master if you have problems building. I've been running the same custom binaries for most of this year, so the branch may need to be refreshed. |
Hi
Very willing to build and test a version of Alacritty with your fixes
in. Can you give me clear instructions as to what I need to do to build
something with your patches in? I have the code checked out and rust
installed and have built master sucessfully. Which branch do I need to
checkout?
Thanks
Kyle Hubert <notifications@github.com> writes:
… Hello @jkp, I live in emacs and running the patch listed in rust-windowing/
winit#1449 has covered all emacs bindings that I can realistically test as one
person. Would you mind testing out the branch listed in the PR? I can always
update against the latest master if you have problems building. I've been
running the same custom binaries for most of this year, so it may need to be
refreshed.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or unsubscribe.*
|
OK I did three things to get a build with this patch included:
I've built the code and am running the binary but things still don't work as I expect. Maybe I just don't understand what you've done here (to be fair I haven't read the patches properly so I'm unversed). I'm expecting these fixes to make it possible to have my "alt" key act as a meta key (as per terminal.app). Do I need to do something in my config? Do I still need the key mappings that you originally listed above (those seemed like workarounds so i was assuming those could be removed once things work properly). Thanks for the pointers. Would love to help get this tested and merged and am at your disposal to try to make that happen. Jamie |
OK - I added one more line to I'll run with this for a while but initially it looks good. One question that you may know the answer to @kjmph - I have some emacs bindings that use both
Any ideas whats going on? |
Some further info pertinent to the issue i mentioned above.
|
Thanks for the test case! I can reproduce it. It looks at first glance that if you have an Escape key on a Mac the escape key is sent through as |
Sorry for the delay, day job.. The underlying problem is that when |
@kjmph Just built and tested your updated branch and it fixed the |
Bump: I've been running this for a couple of months now with no issues. Is there anything I can do to help get this merged in for good so I can get back to running a vanilla release? |
Hello @jkp, my apologies on my delayed response, I lost steam trying to get winit to accept my patches. They were focused on having virtual keyboards work as well, which the patch didn't make any worse than what was previously existing. I moved back to Terminal.app myself, maintaining the patches for about a year got time consuming for me. |
@kjmph do you know if they merged your patches to |
They did not. One reviewer marked a change request for the name of the paramter and field, I could do that and see if one last push could get it accepted.. |
@kjmph that would be ace. I could try to pick up the patch here and take it the last mile then. |
I'll invite you to the repository. |
hi, people @kjmph any news about fix merge? |
Would love to see this happen as well. |
Likely fixed on master given that it looks like duplicate of #62. |
With Others do not. E.g. when I press
Is this expected, or should I open a separate issue? |
Likely just receiving the wrong character sequence or something like that. I'd imagine it would get fixed by #458. |
Sets whether the window should get IME events. When IME is not allowed, the window won’t receive Ime events, and will receive KeyboardInput events for every keypress instead. Without allowing IME, the window will also get ReceivedCharacter events for certain keyboard input. Not allowing IME is useful for games for example. https://docs.rs/winit/latest/winit/window/struct.Window.html#method.set_ime_purpose rust-windowing/winit#518 rust-windowing/winit#625 alacritty/alacritty#2017 servo/servo#20770
Which operating system does the issue occur on? macOS (10.13.6)
Alacritty: 0.2.5
I have following in my settings file
Doing a
/bin/cat
and typing Option+F followed by a B produces^[fb
while Option +I followed by a B produces^[iˆb
I came across this issue while using kakoune editor. I reported the issue there but it seems it is alacritty's issue (both iTerm & Terminal print
^[ib
)The text was updated successfully, but these errors were encountered: