Chromium Code Reviews| Index: ui/events/ozone/layout/keyboard_layout_engine.h |
| diff --git a/ui/events/ozone/layout/keyboard_layout_engine.h b/ui/events/ozone/layout/keyboard_layout_engine.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..21b46b0d969f0b35da92bb19c7467c1527efb91d |
| --- /dev/null |
| +++ b/ui/events/ozone/layout/keyboard_layout_engine.h |
| @@ -0,0 +1,66 @@ |
| +// Copyright 2014 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef UI_OZONE_PUBLIC_KEYBOARD_LAYOUT_ENGINE_H_ |
| +#define UI_OZONE_PUBLIC_KEYBOARD_LAYOUT_ENGINE_H_ |
| + |
| +#include <string> |
| + |
| +#include "base/strings/string16.h" |
| +#include "ui/events/keycodes/keyboard_codes.h" |
| +#include "ui/events/ozone/layout/events_ozone_layout_export.h" |
| + |
| +namespace ui { |
| + |
| +enum class DomCode; |
| +enum class DomKey; |
| + |
| +// A KeyboardLayoutEngine provides a platform-independent interface to |
| +// key mapping. Key mapping provides a meaning (DomKey and character, |
| +// and optionally Windows key code) for a physical key press (DomCode |
| +// and modifier flags). |
| +// |
| +// The interface must support platforms that only provide a single opaque |
| +// system layout, so there is no standalone 'KeyboardLayout' object. |
| +class EVENTS_OZONE_LAYOUT_EXPORT KeyboardLayoutEngine { |
| + public: |
| + KeyboardLayoutEngine() {} |
| + virtual ~KeyboardLayoutEngine() {} |
| + |
| + // Returns true if it is possible to change the current layout. |
| + virtual bool CanSetCurrentLayout() const = 0; |
| + |
| + // Sets the current layout; returns true on success. |
| + virtual bool SetCurrentLayoutByName(const std::string& layout_name) = 0; |
|
Wez
2014/12/09 07:00:33
What's the format of the layout name? Or is that p
kpschoedel
2014/12/09 19:58:44
This is currently a drop-in replacement for ImeKey
Wez
2014/12/12 20:04:17
OK, SGTM; consider referencing the corresponding b
kpschoedel
2014/12/12 21:20:39
Done.
|
| + |
| + // Returns true if the current layout makes use of the ISO Level 5 Shift key. |
| + virtual bool UsesISOLevel5Shift() const = 0; |
|
Wez
2014/12/09 07:00:33
Do you mean Level 5 shift, or Level 3?
kpschoedel
2014/12/09 19:58:44
Level 5. This again is a drop-in for ImeKeyboard::
|
| + |
| + // Returns true if the current layout makes use of the AltGr |
| + // (ISO Level 3 Shift) key. |
| + virtual bool UsesAltGr() const = 0; |
| + |
| + // Provides the meaning of a physical key. |
| + // |
| + // The caller must supply valid addresses for all the output parameters; |
| + // the function must not use their initial values. |
| + // |
| + // Returns true if it can determine the meaning of the (dom_code, flags) |
| + // values, OR if it can determine that they have no meaning in the current |
| + // layout (e.g. the key is unbound). In the latter case, the function sets |
| + // *dom_key to UNIDENTIFIED, *character to 0, and *key_code to VKEY_UNKNOWN. |
|
Wez
2014/12/09 07:00:33
Do all implementations have to set all of the fiel
kpschoedel
2014/12/09 19:58:44
This was up in the air for a while, but I've settl
Wez
2014/12/12 20:04:17
OK, sounds reasonable.
|
| + // |
| + // Returns false if it cannot determine the meaning (and cannot determine |
| + // that there is none); in this case it does not set any of the output |
| + // parameters. |
| + virtual bool Lookup(DomCode dom_code, |
| + int flags, |
|
Wez
2014/12/09 07:00:33
What are the contents of |flags|?
kpschoedel
2014/12/09 19:58:44
ui::EventFlags, which is an unscoped enum. Most ex
Wez
2014/12/12 20:04:17
Suggest clarifying that it's ui::EventFlags in the
kpschoedel
2014/12/12 21:20:39
Done.
|
| + DomKey* dom_key, |
| + base::char16* character, |
|
Wez
2014/12/09 07:00:33
There isn't a 1:1 correspondence between keys and
kpschoedel
2014/12/09 19:58:44
Not in the short term; it's currently wrapped up w
|
| + KeyboardCode* key_code) const = 0; |
| +}; |
| + |
| +} // namespace ui |
| + |
| +#endif // UI_OZONE_PUBLIC_KEYBOARD_LAYOUT_ENGINE_H_ |