Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(855)

Unified Diff: ui/views/controls/textfield/textfield.cc

Issue 2580483002: [Linux] Ctrl should be considered as system modifier and not producing characters (Closed)
Patch Set: msw's comment 3: Add comments for ctrl modifier on Linux Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | ui/views/controls/textfield/textfield_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/controls/textfield/textfield.cc
diff --git a/ui/views/controls/textfield/textfield.cc b/ui/views/controls/textfield/textfield.cc
index 1f4a7f63bc1d107b5229858a8ff76f843f06aac1..c9987ca6331d2b1b83eb0dec90978aea00a7dd30 100644
--- a/ui/views/controls/textfield/textfield.cc
+++ b/ui/views/controls/textfield/textfield.cc
@@ -216,6 +216,18 @@ base::TimeDelta GetPasswordRevealDuration() {
: base::TimeDelta();
}
+bool IsControlKeyModifier(int flags) {
+// XKB layout doesn't natively generate printable characters from a
+// Control-modified key combination, but we cannot extend it to other platforms
+// as Control has different meanings and behaviors.
+// https://crrev.com/2580483002/#msg46
+#if defined(OS_LINUX)
+ return flags & ui::EF_CONTROL_DOWN;
+#else
+ return false;
+#endif
+}
+
} // namespace
// static
@@ -1289,13 +1301,14 @@ void Textfield::InsertChar(const ui::KeyEvent& event) {
}
// Filter out all control characters, including tab and new line characters,
- // and all characters with Alt modifier (and Search on ChromeOS). But allow
- // characters with the AltGr modifier. On Windows AltGr is represented by
- // Alt+Ctrl or Right Alt, and on Linux it's a different flag that we don't
- // care about.
+ // and all characters with Alt modifier (and Search on ChromeOS, Ctrl on
+ // Linux). But allow characters with the AltGr modifier. On Windows AltGr is
+ // represented by Alt+Ctrl or Right Alt, and on Linux it's a different flag
+ // that we don't care about.
const base::char16 ch = event.GetCharacter();
const bool should_insert_char = ((ch >= 0x20 && ch < 0x7F) || ch > 0x9F) &&
- !ui::IsSystemKeyModifier(event.flags());
+ !ui::IsSystemKeyModifier(event.flags()) &&
+ !IsControlKeyModifier(event.flags());
if (GetTextInputType() == ui::TEXT_INPUT_TYPE_NONE || !should_insert_char)
return;
« no previous file with comments | « no previous file | ui/views/controls/textfield/textfield_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698