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
Show 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 {
...
@@ -836,10 +836,13 @@ class RawKeyboard {
// exist in the modifier list. Enforce the pressing state.
// exist in the modifier list. Enforce the pressing state.
if
(
event
is
RawKeyDownEvent
&&
thisKeyModifier
!=
null
if
(
event
is
RawKeyDownEvent
&&
thisKeyModifier
!=
null
&&
!
_keysPressed
.
containsKey
(
event
.
physicalKey
))
{
&&
!
_keysPressed
.
containsKey
(
event
.
physicalKey
))
{
// So far this inconsistancy is only found on Linux GTK for AltRight in a
// This inconsistancy is found on Linux GTK for AltRight:
// rare case. (See https://github.com/flutter/flutter/issues/93278 .) In
// https://github.com/flutter/flutter/issues/93278
// other cases, this inconsistancy will be caught by an assertion later.
// And also on Android and iOS:
if
(
event
.
data
is
RawKeyEventDataLinux
&&
event
.
physicalKey
==
PhysicalKeyboardKey
.
altRight
)
{
// 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
];
final
LogicalKeyboardKey
?
logicalKey
=
_allModifiersExceptFn
[
event
.
physicalKey
];
if
(
logicalKey
!=
null
)
{
if
(
logicalKey
!=
null
)
{
_keysPressed
[
event
.
physicalKey
]
=
logicalKey
;
_keysPressed
[
event
.
physicalKey
]
=
logicalKey
;
...
...
packages/flutter/test/services/raw_keyboard_test.dart
View file @
31e2618b
...
@@ -759,12 +759,11 @@ void main() {
...
@@ -759,12 +759,11 @@ void main() {
}
else
{
}
else
{
keyEventMessage
=
const
<
String
,
dynamic
>{
keyEventMessage
=
const
<
String
,
dynamic
>{
'type'
:
'keydown'
,
'type'
:
'keydown'
,
'keymap'
:
'android'
,
'keymap'
:
'windows'
,
'keyCode'
:
0x3b
,
// Left shift key keyCode
'keyCode'
:
16
,
// Left shift key keyCode
'scanCode'
:
0x2a
,
'characterCodePoint'
:
0
,
'metaState'
:
0x0
,
// No shift key metaState set!
'scanCode'
:
42
,
'source'
:
0x101
,
'modifiers'
:
0x0
,
// No shift key metaState set!
'deviceId'
:
1
,
};
};
}
}
...
@@ -784,6 +783,65 @@ void main() {
...
@@ -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
{
testWidgets
(
'Dispatch events to all handlers'
,
(
WidgetTester
tester
)
async
{
final
FocusNode
focusNode
=
FocusNode
();
final
FocusNode
focusNode
=
FocusNode
();
final
List
<
int
>
logs
=
<
int
>[];
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