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

Unified Diff: ui/events/ozone/layout/xkb/xkb_keyboard_layout_engine.h

Issue 786813004: Generate correct KeyboardCode (VKEY). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@x430194-xkb
Patch Set: Created 6 years 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
Index: ui/events/ozone/layout/xkb/xkb_keyboard_layout_engine.h
diff --git a/ui/events/ozone/layout/xkb/xkb_keyboard_layout_engine.h b/ui/events/ozone/layout/xkb/xkb_keyboard_layout_engine.h
index 44f678aca062f83201f7220c898d63fd921b93a1..283849cc4068c1e95c372fbf5686707b147a92a0 100644
--- a/ui/events/ozone/layout/xkb/xkb_keyboard_layout_engine.h
+++ b/ui/events/ozone/layout/xkb/xkb_keyboard_layout_engine.h
@@ -15,6 +15,10 @@
namespace ui {
+// XKB scan code values are platform-dependent; this provides the layout engine
+// with the mapping from DomCode to xkb_keycode_t. (This mapping is in principle
+// derivable from the XKB keyboard layout, but xkbcommon does not provide a
+// practical interface to do so.)
class EVENTS_OZONE_LAYOUT_EXPORT XkbKeyCodeConverter {
public:
XkbKeyCodeConverter();
@@ -45,6 +49,28 @@ class EVENTS_OZONE_LAYOUT_EXPORT XkbKeyboardLayoutEngine
base::char16* character,
KeyboardCode* key_code) const override;
+ protected:
+ // Table for EventFlagsToXkbFlags().
+ struct XkbFlagMapEntry {
+ int ui_flag;
+ xkb_mod_mask_t xkb_flag;
+ };
+ std::vector<XkbFlagMapEntry> xkb_flag_map_;
+
+ // Determines the Windows-based KeyboardCode (VKEY) for a character key,
+ // accounting for non-US layouts. May return VKEY_UNKNOWN, in which case the
+ // caller should use |DomCodeToNonLocatedKeyboardCode()| as a last resort.
+ KeyboardCode DifficultKeyboardCode(DomCode dom_code,
+ int ui_flags,
+ xkb_keycode_t xkb_keycode,
+ xkb_mod_mask_t xkb_flags,
+ xkb_keysym_t xkb_keysym,
+ DomKey dom_key,
+ base::char16 character) const;
+
+ // Maps DomCode to xkb_keycode_t.
+ const XkbKeyCodeConverter& key_code_converter_;
+
private:
// Sets a new XKB keymap, updating object fields.
void SetKeymap(xkb_keymap* keymap);
@@ -53,14 +79,19 @@ class EVENTS_OZONE_LAYOUT_EXPORT XkbKeyboardLayoutEngine
xkb_mod_mask_t EventFlagsToXkbFlags(int ui_flags) const;
// Determines the XKB KeySym and character associated with a key.
- // Returns true on success.
- bool XkbLookup(xkb_keycode_t xkb_keycode,
- xkb_mod_mask_t xkb_flags,
- xkb_keysym_t* xkb_keysym,
- base::char16* character) const;
-
- // Maps DomCode to xkb_keycode_t.
- const XkbKeyCodeConverter& key_code_converter_;
+ // Returns true on success. This is virtual for testing.
+ virtual bool XkbLookup(xkb_keycode_t xkb_keycode,
+ xkb_mod_mask_t xkb_flags,
+ xkb_keysym_t* xkb_keysym,
+ base::char16* character) const;
+
+ // Helper for difficult VKEY lookup. If |ui_flags| matches |base_flags|,
+ // returns |base_character|; otherwise returns the XKB character for
+ // the keycode and mapped |ui_flags|.
+ base::char16 XkbSubCharacter(xkb_keycode_t xkb_keycode,
+ xkb_mod_mask_t base_flags,
+ base::char16 base_character,
+ int ui_flags) const;
// libxkbcommon uses explicit reference counting for its structures,
// so we need to trigger its cleanup.
@@ -72,13 +103,6 @@ class EVENTS_OZONE_LAYOUT_EXPORT XkbKeyboardLayoutEngine
void operator()(xkb_state* state) { xkb_state_unref(state); }
};
scoped_ptr<xkb_state, XkbstateDeleter> xkb_state_;
-
- // Table for EventFlagsToXkbFlags().
- struct XkbFlagMapEntry {
- int ui_flag;
- xkb_mod_mask_t xkb_flag;
- };
- std::vector<XkbFlagMapEntry> xkb_flag_map_;
};
} // namespace ui

Powered by Google App Engine
This is Rietveld 408576698