-
Notifications
You must be signed in to change notification settings - Fork 27.7k
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
macOS: Should never encounter KeyData when transitMode is rawKeyData. #87339
Comments
/cc @dkwingsmt |
Hi, this issue might have been fixed by flutter/engine#27774 (which has been merged but not rolled in yet). Can you checkout the latest engine and see if the problem persists? |
I tried it with flutter/engine#27774 in and there is no difference. It have something to with CMD key being held down when new window is opened. Cocoa sends |
Ok. In that case, is it possible to resolve by changing the embedder responder to send an empty event, instead of changing the channel responder to not sending the raw event? |
I'm not sure I understand why. Why should |
All empty |
@dkwingsmt , I modified
What happens is that this is key-up event of CMD (meta key) delivered to newly opened window, which |
In other words, if I'm not mistaken something like this should not exist:
In macOS modifiers 256 means no modifiers. Meta Left KeyDown event should have meta in the modifiers. |
Thanks for investigation! That's interesting. Now, let's submit the embedder responder PR separately, and talk about the channel responder fix. It seems like we're receiving more modifier flags than we care, which sounds like a dangerous move since we are directly comparing modifier flags with |
I'm not entirely sure why no modifier in So something like this seems to works fine: NSEventModifierFlags modifierFlags = event.modifierFlags & ~0x100;
if (modifierFlags < _previouslyPressedFlags) {
type = @"keyup";
} else if (modifierFlags > _previouslyPressedFlags) {
type = @"keydown";
} else {
// ignore duplicate modifiers; This can happen in situations like switching
// between application windows when MacOS only sends the up event to new window.
return;
} I assume masking this with flags in There is also |
I was considering
|
I'll update the original PR. Just a sec. |
@dkwingsmt, the PR is here. |
FWIW, with this in place I have no need for the empty event in |
I'd still appreciate if you can add that change in (otherwise I will do it anyway). We're changing the protocol so that every key message (anything received by the system) must send some key data, even an empty one. Otherwise it might cause future problems. |
Sure, I can do it tomorrow. |
@dkwingsmt, I gave it a shot (I added |
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of |
Happens after the keyboard event refactor landed.
It happens in the following scenario: Register macOS global hot key, on hot key create new flutter window/engine and show it. However I assume this would also happen in different multi window scenarios (and is not necessarily tied to a hot key).
What happens is that cocoa immediately sends
NSEventTypeFlagsChanged
to the new window withevent.modifierFlags == 256
, which basically means no modifiers.However the code in
FlutterChannelKeyResponder
does this:_previouslyPressedFlags
is 0, so this always generates key down event even though there aren't any modifiers present. Which in turns sets_transitMode
inHardwareKeyboard
toKeyDataTransitMode.rawKeyData
, because this is sent before any actual ui keyboard event. After this the keyboard no longer works in window resulting in message above.Potential solution would be either initializing
_previouslyPressedFlags
to256
, or check ifevent.modifierFlags > 256
before generating key down event.The text was updated successfully, but these errors were encountered: