Skip to content

Commit

Permalink
MacOS keyboard: RawKeyboard uses filtered modifier (#28666)
Browse files Browse the repository at this point in the history
Removes the uninterested bits from the modifiers sent to the framework to keep consistency.
  • Loading branch information
dkwingsmt authored Oct 4, 2021
1 parent b874967 commit 2d0c025
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ - (void)handleEvent:(NSEvent*)event callback:(FlutterAsyncKeyCallback)callback {
@"keymap" : @"macos",
@"type" : type,
@"keyCode" : @(event.keyCode),
@"modifiers" : @(event.modifierFlags),
@"modifiers" : @(modifierFlags),
} mutableCopy];
// Calling these methods on any other type of event
// (e.g NSEventTypeFlagsChanged) will raise an exception.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
EXPECT_STREQ([[messages lastObject][@"keymap"] UTF8String], "macos");
EXPECT_STREQ([[messages lastObject][@"type"] UTF8String], "keydown");
EXPECT_EQ([[messages lastObject][@"keyCode"] intValue], 0);
EXPECT_EQ([[messages lastObject][@"modifiers"] intValue], 0x100);
EXPECT_EQ([[messages lastObject][@"modifiers"] intValue], 0x0);
EXPECT_EQ([[messages lastObject][@"characters"] UTF8String], "a");
EXPECT_EQ([[messages lastObject][@"charactersIgnoringModifiers"] UTF8String], "a");

Expand All @@ -96,7 +96,7 @@
EXPECT_STREQ([[messages lastObject][@"keymap"] UTF8String], "macos");
EXPECT_STREQ([[messages lastObject][@"type"] UTF8String], "keyup");
EXPECT_EQ([[messages lastObject][@"keyCode"] intValue], 0);
EXPECT_EQ([[messages lastObject][@"modifiers"] intValue], 0x100);
EXPECT_EQ([[messages lastObject][@"modifiers"] intValue], 0);
EXPECT_EQ([[messages lastObject][@"characters"] UTF8String], "a");
EXPECT_EQ([[messages lastObject][@"charactersIgnoringModifiers"] UTF8String], "a");

Expand All @@ -117,7 +117,7 @@
EXPECT_STREQ([[messages lastObject][@"keymap"] UTF8String], "macos");
EXPECT_STREQ([[messages lastObject][@"type"] UTF8String], "keydown");
EXPECT_EQ([[messages lastObject][@"keyCode"] intValue], 56);
EXPECT_EQ([[messages lastObject][@"modifiers"] intValue], 0x20102);
EXPECT_EQ([[messages lastObject][@"modifiers"] intValue], 0x20002);

EXPECT_EQ([responses count], 1u);
EXPECT_EQ([[responses lastObject] boolValue], TRUE);
Expand All @@ -127,7 +127,7 @@

// RShift down
next_response = false;
[responder handleEvent:keyEvent(NSEventTypeFlagsChanged, 0x20106, @"", @"", FALSE, 60)
[responder handleEvent:keyEvent(NSEventTypeFlagsChanged, 0x20006, @"", @"", FALSE, 60)
callback:^(BOOL handled) {
[responses addObject:@(handled)];
}];
Expand All @@ -136,7 +136,7 @@
EXPECT_STREQ([[messages lastObject][@"keymap"] UTF8String], "macos");
EXPECT_STREQ([[messages lastObject][@"type"] UTF8String], "keydown");
EXPECT_EQ([[messages lastObject][@"keyCode"] intValue], 60);
EXPECT_EQ([[messages lastObject][@"modifiers"] intValue], 0x20106);
EXPECT_EQ([[messages lastObject][@"modifiers"] intValue], 0x20006);

EXPECT_EQ([responses count], 1u);
EXPECT_EQ([[responses lastObject] boolValue], FALSE);
Expand All @@ -155,7 +155,7 @@
EXPECT_STREQ([[messages lastObject][@"keymap"] UTF8String], "macos");
EXPECT_STREQ([[messages lastObject][@"type"] UTF8String], "keyup");
EXPECT_EQ([[messages lastObject][@"keyCode"] intValue], 56);
EXPECT_EQ([[messages lastObject][@"modifiers"] intValue], 0x20104);
EXPECT_EQ([[messages lastObject][@"modifiers"] intValue], 0x20004);

EXPECT_EQ([responses count], 1u);
EXPECT_EQ([[responses lastObject] boolValue], FALSE);
Expand All @@ -165,7 +165,7 @@

// RShift up
next_response = false;
[responder handleEvent:keyEvent(NSEventTypeFlagsChanged, 0x100, @"", @"", FALSE, 60)
[responder handleEvent:keyEvent(NSEventTypeFlagsChanged, 0, @"", @"", FALSE, 60)
callback:^(BOOL handled) {
[responses addObject:@(handled)];
}];
Expand All @@ -174,7 +174,7 @@
EXPECT_STREQ([[messages lastObject][@"keymap"] UTF8String], "macos");
EXPECT_STREQ([[messages lastObject][@"type"] UTF8String], "keyup");
EXPECT_EQ([[messages lastObject][@"keyCode"] intValue], 60);
EXPECT_EQ([[messages lastObject][@"modifiers"] intValue], 0x100);
EXPECT_EQ([[messages lastObject][@"modifiers"] intValue], 0);

EXPECT_EQ([responses count], 1u);
EXPECT_EQ([[responses lastObject] boolValue], FALSE);
Expand Down Expand Up @@ -221,7 +221,7 @@
EXPECT_STREQ([[messages lastObject][@"keymap"] UTF8String], "macos");
EXPECT_STREQ([[messages lastObject][@"type"] UTF8String], "keydown");
EXPECT_EQ([[messages lastObject][@"keyCode"] intValue], 0);
EXPECT_EQ([[messages lastObject][@"modifiers"] intValue], 0x100);
EXPECT_EQ([[messages lastObject][@"modifiers"] intValue], 0);
EXPECT_EQ([[messages lastObject][@"characters"] UTF8String], "a");
EXPECT_EQ([[messages lastObject][@"charactersIgnoringModifiers"] UTF8String], "a");

Expand Down

0 comments on commit 2d0c025

Please sign in to comment.