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
760635e6
Unverified
Commit
760635e6
authored
Aug 14, 2019
by
Francisco Magdaleno
Committed by
GitHub
Aug 14, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[linux] Receives the unmodified characters obtained from GLFW (#34752)
parent
43f118ad
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
62 additions
and
30 deletions
+62
-30
raw_keyboard.dart
dev/manual_tests/lib/raw_keyboard.dart
+1
-1
raw_keyboard.dart
packages/flutter/lib/src/services/raw_keyboard.dart
+1
-1
raw_keyboard_linux.dart
packages/flutter/lib/src/services/raw_keyboard_linux.dart
+18
-17
raw_keyboard_test.dart
packages/flutter/test/services/raw_keyboard_test.dart
+42
-11
No files found.
dev/manual_tests/lib/raw_keyboard.dart
View file @
760635e6
...
...
@@ -105,7 +105,7 @@ class _HardwareKeyDemoState extends State<RawKeyboardDemo> {
}
else
if
(
data
is
RawKeyEventDataLinux
)
{
dataText
.
add
(
Text
(
'keyCode:
${data.keyCode}
(
${_asHex(data.keyCode)}
)'
));
dataText
.
add
(
Text
(
'scanCode:
${data.scanCode}
'
));
dataText
.
add
(
Text
(
'
codePoint:
${data.codePoint
}
'
));
dataText
.
add
(
Text
(
'
unicodeScalarValues:
${data.unicodeScalarValues
}
'
));
dataText
.
add
(
Text
(
'modifiers:
${data.modifiers}
(
${_asHex(data.modifiers)}
)'
));
}
dataText
.
add
(
Text
(
'logical:
${_event.logicalKey}
'
));
...
...
packages/flutter/lib/src/services/raw_keyboard.dart
View file @
760635e6
...
...
@@ -279,7 +279,7 @@ abstract class RawKeyEvent extends Diagnosticable {
case
'linux'
:
data
=
RawKeyEventDataLinux
(
keyHelper:
KeyHelper
(
message
[
'toolkit'
]
??
''
),
codePoint:
message
[
'codePoint
'
]
??
0
,
unicodeScalarValues:
message
[
'unicodeScalarValues
'
]
??
0
,
keyCode:
message
[
'keyCode'
]
??
0
,
scanCode:
message
[
'scanCode'
]
??
0
,
modifiers:
message
[
'modifiers'
]
??
0
);
...
...
packages/flutter/lib/src/services/raw_keyboard_linux.dart
View file @
760635e6
...
...
@@ -19,16 +19,17 @@ import 'raw_keyboard.dart';
class
RawKeyEventDataLinux
extends
RawKeyEventData
{
/// Creates a key event data structure specific for macOS.
///
/// The [toolkit], [scanCode], [
codePoint], [keyCode], and [modifiers], arguments
/// must not be null.
/// The [toolkit], [scanCode], [
unicodeScalarValues], [keyCode], and [modifiers],
///
arguments
must not be null.
const
RawKeyEventDataLinux
({
@required
this
.
keyHelper
,
this
.
unicodeScalarValues
=
0
,
this
.
scanCode
=
0
,
this
.
codePoint
=
0
,
this
.
keyCode
=
0
,
this
.
modifiers
=
0
,
})
:
assert
(
scanCode
!=
null
),
assert
(
codePoint
!=
null
),
assert
(
unicodeScalarValues
!=
null
),
assert
((
unicodeScalarValues
&
~
LogicalKeyboardKey
.
valueMask
)
==
0
),
assert
(
keyCode
!=
null
),
assert
(
modifiers
!=
null
),
assert
(
keyHelper
!=
null
);
...
...
@@ -39,32 +40,32 @@ class RawKeyEventDataLinux extends RawKeyEventData {
/// (GLFW, GTK, QT, etc) may have a different key code mapping.
final
KeyHelper
keyHelper
;
/// An int with up to two Unicode scalar values generated by a single keystroke. An assertion
/// will fire if more than two values are encoded in a single keystroke.
///
/// This is typically the character that [keyCode] would produce without any modifier keys.
/// For dead keys, it is typically the diacritic it would add to a character. Defaults to 0,
/// asserted to be not null.
final
int
unicodeScalarValues
;
/// The hardware scan code id corresponding to this key event.
///
/// These values are not reliable and vary from device to device, so this
/// information is mainly useful for debugging.
final
int
scanCode
;
/// The Unicode code point represented by the key event, if any.
///
/// If there is no Unicode code point, this value is zero.
///
/// Dead keys are represented as Unicode combining characters.
final
int
codePoint
;
/// The hardware key code corresponding to this key event.
///
/// This is the physical key that was pressed, not the Unicode character.
/// See [codePoint] for the Unicode character. This value may be different depending
/// on the window toolkit used (See [toolkit]).
/// This value may be different depending on the window toolkit used. See [KeyHelper].
final
int
keyCode
;
/// A mask of the current modifiers using the values in Modifier Flags.
/// This value may be different depending on the window toolkit used
(See [toolkit])
.
/// This value may be different depending on the window toolkit used
. See [KeyHelper]
.
final
int
modifiers
;
@override
String
get
keyLabel
=>
codePoint
==
0
?
null
:
String
.
fromCharCode
(
codePoint
);
String
get
keyLabel
=>
unicodeScalarValues
==
0
?
null
:
String
.
fromCharCode
(
unicodeScalarValues
);
@override
PhysicalKeyboardKey
get
physicalKey
=>
kLinuxToPhysicalKey
[
scanCode
]
??
PhysicalKeyboardKey
.
none
;
...
...
@@ -85,7 +86,7 @@ class RawKeyEventDataLinux extends RawKeyEventData {
// plane.
if
(
keyLabel
!=
null
&&
!
LogicalKeyboardKey
.
isControlCharacter
(
keyLabel
))
{
final
int
keyId
=
LogicalKeyboardKey
.
unicodePlane
|
(
codePoint
&
LogicalKeyboardKey
.
valueMask
);
final
int
keyId
=
LogicalKeyboardKey
.
unicodePlane
|
(
unicodeScalarValues
&
LogicalKeyboardKey
.
valueMask
);
return
LogicalKeyboardKey
.
findKeyByKeyId
(
keyId
)
??
LogicalKeyboardKey
(
keyId
,
keyLabel:
keyLabel
,
...
...
@@ -123,7 +124,7 @@ class RawKeyEventDataLinux extends RawKeyEventData {
@override
String
toString
()
{
return
'
$runtimeType
(keyLabel:
$keyLabel
, keyCode:
$keyCode
, scanCode:
$scanCode
,'
'
codePoint:
$codePoint
, modifiers:
$modifiers
, '
'
unicodeScalarValues:
$unicodeScalarValues
, modifiers:
$modifiers
, '
'modifiers down:
$modifiersPressed
)'
;
}
}
...
...
packages/flutter/test/services/raw_keyboard_test.dart
View file @
760635e6
...
...
@@ -467,9 +467,9 @@ void main() {
'type'
:
'keydown'
,
'keymap'
:
'linux'
,
'toolkit'
:
'glfw'
,
'keyCode'
:
0x04
,
'scanCode'
:
0x0
1
,
'
codePoint'
:
0x10
,
'keyCode'
:
65
,
'scanCode'
:
0x0
0000026
,
'
unicodeScalarValues'
:
97
,
'modifiers'
:
modifier
,
});
final
RawKeyEventDataLinux
data
=
event
.
data
;
...
...
@@ -501,9 +501,9 @@ void main() {
'type'
:
'keydown'
,
'keymap'
:
'linux'
,
'toolkit'
:
'glfw'
,
'keyCode'
:
0x04
,
'scanCode'
:
0x
64
,
'
codePoint'
:
0x1
,
'keyCode'
:
65
,
'scanCode'
:
0x
00000026
,
'
unicodeScalarValues'
:
97
,
'modifiers'
:
modifier
|
GLFWKeyHelper
.
modifierControl
,
});
final
RawKeyEventDataLinux
data
=
event
.
data
;
...
...
@@ -538,13 +538,44 @@ void main() {
'toolkit'
:
'glfw'
,
'keyCode'
:
65
,
'scanCode'
:
0x00000026
,
'
codePoint'
:
97
,
'
unicodeScalarValues'
:
113
,
'modifiers'
:
0x0
,
});
final
RawKeyEventDataLinux
data
=
keyAEvent
.
data
;
expect
(
data
.
physicalKey
,
equals
(
PhysicalKeyboardKey
.
keyA
));
expect
(
data
.
logicalKey
,
equals
(
LogicalKeyboardKey
.
keyA
));
expect
(
data
.
keyLabel
,
equals
(
'a'
));
expect
(
data
.
logicalKey
,
equals
(
LogicalKeyboardKey
.
keyQ
));
expect
(
data
.
keyLabel
,
equals
(
'q'
));
});
test
(
'Code points with two Unicode scalar values are allowed'
,
()
{
final
RawKeyEvent
keyAEvent
=
RawKeyEvent
.
fromMessage
(
const
<
String
,
dynamic
>{
'type'
:
'keydown'
,
'keymap'
:
'linux'
,
'toolkit'
:
'glfw'
,
'keyCode'
:
65
,
'scanCode'
:
0x00000026
,
'unicodeScalarValues'
:
0x10FFFF
,
'modifiers'
:
0x0
,
});
final
RawKeyEventDataLinux
data
=
keyAEvent
.
data
;
expect
(
data
.
physicalKey
,
equals
(
PhysicalKeyboardKey
.
keyA
));
expect
(
data
.
logicalKey
.
keyId
,
equals
(
0x10FFFF
));
expect
(
data
.
keyLabel
,
equals
(
''
));
});
test
(
'Code points with more than three Unicode scalar values are not allowed'
,
()
{
// |keyCode| and |scanCode| are arbitrary values. This test should fail due to an invalid |unicodeScalarValues|.
void
_createFailingKey
()
{
RawKeyEvent
.
fromMessage
(
const
<
String
,
dynamic
>{
'type'
:
'keydown'
,
'keymap'
:
'linux'
,
'toolkit'
:
'glfw'
,
'keyCode'
:
65
,
'scanCode'
:
0x00000026
,
'unicodeScalarValues'
:
0x1F00000000
,
'modifiers'
:
0x0
,
});
}
expect
(()
=>
_createFailingKey
(),
throwsAssertionError
);
});
test
(
'Control keyboard keys are correctly translated'
,
()
{
final
RawKeyEvent
escapeKeyEvent
=
RawKeyEvent
.
fromMessage
(
const
<
String
,
dynamic
>{
...
...
@@ -553,7 +584,7 @@ void main() {
'toolkit'
:
'glfw'
,
'keyCode'
:
256
,
'scanCode'
:
0x00000009
,
'
codePoint
'
:
0
,
'
unicodeScalarValues
'
:
0
,
'modifiers'
:
0x0
,
});
final
RawKeyEventDataLinux
data
=
escapeKeyEvent
.
data
;
...
...
@@ -568,7 +599,7 @@ void main() {
'toolkit'
:
'glfw'
,
'keyCode'
:
340
,
'scanCode'
:
0x00000032
,
'
codePoint
'
:
0
,
'
unicodeScalarValues
'
:
0
,
});
final
RawKeyEventDataLinux
data
=
shiftLeftKeyEvent
.
data
;
expect
(
data
.
physicalKey
,
equals
(
PhysicalKeyboardKey
.
shiftLeft
));
...
...
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