Fix search results being clipped in app list.
[chromium-blink-merge.git] / ui / events / keycodes / keyboard_code_conversion.h
blob0c14ed74cee248798e11f3abfeb90cc9251c1548
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef UI_EVENTS_KEYCODES_KEYBOARD_CODE_CONVERSION_H_
6 #define UI_EVENTS_KEYCODES_KEYBOARD_CODE_CONVERSION_H_
8 #include "base/strings/string16.h"
9 #include "ui/events/events_base_export.h"
10 #include "ui/events/keycodes/keyboard_codes.h"
12 namespace ui {
14 enum class DomCode;
15 enum class DomKey;
17 // Helper functions to get the meaning of a Windows key code in a
18 // platform independent way. It supports control characters as well.
19 // It assumes a US keyboard layout is used, so it may only be used when there
20 // is no native event or no better way to get the character.
21 // For example, if a virtual keyboard implementation can only generate key
22 // events with key_code and flags information, then there is no way for us to
23 // determine the actual character that should be generate by the key. Because
24 // a key_code only represents a physical key on the keyboard, it has nothing
25 // to do with the actual character printed on that key. In such case, the only
26 // thing we can do is to assume that we are using a US keyboard and get the
27 // character according to US keyboard layout definition.
28 // If a virtual keyboard implementation wants to support other keyboard
29 // layouts, that may generate different text for a certain key than on a US
30 // keyboard, a special native event object should be introduced to carry extra
31 // information to help determine the correct character.
32 // Take XKeyEvent as an example, it contains not only keycode and modifier
33 // flags but also group and other extra XKB information to help determine the
34 // correct character. That's why we can use XLookupString() function to get
35 // the correct text generated by a X key event (See how is GetCharacter()
36 // implemented in event_x.cc).
37 EVENTS_BASE_EXPORT base::char16 GetCharacterFromKeyCode(KeyboardCode key_code,
38 int flags);
39 EVENTS_BASE_EXPORT bool GetMeaningFromKeyCode(KeyboardCode key_code,
40 int flags,
41 DomKey* dom_key,
42 base::char16* character);
44 // Determine the non-located VKEY corresponding to a located VKEY.
45 // Most modifier keys have two kinds of KeyboardCode: located (e.g.
46 // VKEY_LSHIFT and VKEY_RSHIFT), that indentify one of two specific
47 // physical keys, and non-located (e.g. VKEY_SHIFT) that identify
48 // only the operation.
49 EVENTS_BASE_EXPORT KeyboardCode
50 LocatedToNonLocatedKeyboardCode(KeyboardCode key_code);
52 // Determine the located VKEY corresponding to a non-located VKEY.
53 EVENTS_BASE_EXPORT KeyboardCode
54 NonLocatedToLocatedKeyboardCode(KeyboardCode key_code, DomCode dom_code);
56 } // namespace ui
58 #endif // UI_EVENTS_KEYCODES_KEYBOARD_CODE_CONVERSION_H_