Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
31e2618b
Unverified
Commit
31e2618b
authored
Sep 28, 2022
by
Tong Mu
Committed by
GitHub
Sep 28, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[RawKeyboard] Allow inconsistent modifiers for iOS and Android (#108926)
parent
23d17e30
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
71 additions
and
10 deletions
+71
-10
raw_keyboard.dart
packages/flutter/lib/src/services/raw_keyboard.dart
+7
-4
raw_keyboard_test.dart
packages/flutter/test/services/raw_keyboard_test.dart
+64
-6
No files found.
packages/flutter/lib/src/services/raw_keyboard.dart
View file @
31e2618b
...
...
@@ -836,10 +836,13 @@ class RawKeyboard {
// exist in the modifier list. Enforce the pressing state.
if
(
event
is
RawKeyDownEvent
&&
thisKeyModifier
!=
null
&&
!
_keysPressed
.
containsKey
(
event
.
physicalKey
))
{
// So far this inconsistancy is only found on Linux GTK for AltRight in a
// rare case. (See https://github.com/flutter/flutter/issues/93278 .) In
// other cases, this inconsistancy will be caught by an assertion later.
if
(
event
.
data
is
RawKeyEventDataLinux
&&
event
.
physicalKey
==
PhysicalKeyboardKey
.
altRight
)
{
// This inconsistancy is found on Linux GTK for AltRight:
// https://github.com/flutter/flutter/issues/93278
// And also on Android and iOS:
// https://github.com/flutter/flutter/issues/101090
if
((
event
.
data
is
RawKeyEventDataLinux
&&
event
.
physicalKey
==
PhysicalKeyboardKey
.
altRight
)
||
event
.
data
is
RawKeyEventDataIos
||
event
.
data
is
RawKeyEventDataAndroid
)
{
final
LogicalKeyboardKey
?
logicalKey
=
_allModifiersExceptFn
[
event
.
physicalKey
];
if
(
logicalKey
!=
null
)
{
_keysPressed
[
event
.
physicalKey
]
=
logicalKey
;
...
...
packages/flutter/test/services/raw_keyboard_test.dart
View file @
31e2618b
...
...
@@ -759,12 +759,11 @@ void main() {
}
else
{
keyEventMessage
=
const
<
String
,
dynamic
>{
'type'
:
'keydown'
,
'keymap'
:
'android'
,
'keyCode'
:
0x3b
,
// Left shift key keyCode
'scanCode'
:
0x2a
,
'metaState'
:
0x0
,
// No shift key metaState set!
'source'
:
0x101
,
'deviceId'
:
1
,
'keymap'
:
'windows'
,
'keyCode'
:
16
,
// Left shift key keyCode
'characterCodePoint'
:
0
,
'scanCode'
:
42
,
'modifiers'
:
0x0
,
// No shift key metaState set!
};
}
...
...
@@ -784,6 +783,65 @@ void main() {
);
});
testWidgets
(
'Allows inconsistent modifier for iOS'
,
(
WidgetTester
_
)
async
{
// Use `testWidgets` for clean-ups.
final
List
<
RawKeyEvent
>
events
=
<
RawKeyEvent
>[];
RawKeyboard
.
instance
.
addListener
(
events
.
add
);
addTearDown
(()
{
RawKeyboard
.
instance
.
removeListener
(
events
.
add
);
});
await
TestDefaultBinaryMessengerBinding
.
instance
!.
defaultBinaryMessenger
.
handlePlatformMessage
(
SystemChannels
.
keyEvent
.
name
,
SystemChannels
.
keyEvent
.
codec
.
encodeMessage
(
const
<
String
,
dynamic
>{
'type'
:
'keydown'
,
'keymap'
:
'ios'
,
'keyCode'
:
0x00000039
,
'characters'
:
''
,
'charactersIgnoringModifiers'
:
''
,
'modifiers'
:
0
,
}),
(
ByteData
?
data
)
{
},
);
expect
(
events
,
hasLength
(
1
));
final
RawKeyEvent
capsLockKey
=
events
[
0
];
final
RawKeyEventDataIos
data
=
capsLockKey
.
data
as
RawKeyEventDataIos
;
expect
(
data
.
physicalKey
,
equals
(
PhysicalKeyboardKey
.
capsLock
));
expect
(
data
.
logicalKey
,
equals
(
LogicalKeyboardKey
.
capsLock
));
expect
(
RawKeyboard
.
instance
.
keysPressed
,
contains
(
LogicalKeyboardKey
.
capsLock
));
},
skip:
isBrowser
);
// [intended] This is an iOS-specific group.
testWidgets
(
'Allows inconsistent modifier for Android'
,
(
WidgetTester
_
)
async
{
// Use `testWidgets` for clean-ups.
final
List
<
RawKeyEvent
>
events
=
<
RawKeyEvent
>[];
RawKeyboard
.
instance
.
addListener
(
events
.
add
);
addTearDown
(()
{
RawKeyboard
.
instance
.
removeListener
(
events
.
add
);
});
await
TestDefaultBinaryMessengerBinding
.
instance
!.
defaultBinaryMessenger
.
handlePlatformMessage
(
SystemChannels
.
keyEvent
.
name
,
SystemChannels
.
keyEvent
.
codec
.
encodeMessage
(
const
<
String
,
dynamic
>{
'type'
:
'keydown'
,
'keymap'
:
'android'
,
'keyCode'
:
115
,
'plainCodePoint'
:
0
,
'codePoint'
:
0
,
'scanCode'
:
58
,
'metaState'
:
0
,
'source'
:
0x101
,
'deviceId'
:
1
,
}),
(
ByteData
?
data
)
{
},
);
expect
(
events
,
hasLength
(
1
));
final
RawKeyEvent
capsLockKey
=
events
[
0
];
final
RawKeyEventDataAndroid
data
=
capsLockKey
.
data
as
RawKeyEventDataAndroid
;
expect
(
data
.
physicalKey
,
equals
(
PhysicalKeyboardKey
.
capsLock
));
expect
(
data
.
logicalKey
,
equals
(
LogicalKeyboardKey
.
capsLock
));
expect
(
RawKeyboard
.
instance
.
keysPressed
,
contains
(
LogicalKeyboardKey
.
capsLock
));
},
skip:
isBrowser
);
// [intended] This is an Android-specific group.
testWidgets
(
'Dispatch events to all handlers'
,
(
WidgetTester
tester
)
async
{
final
FocusNode
focusNode
=
FocusNode
();
final
List
<
int
>
logs
=
<
int
>[];
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment