Chromium Code Reviews| Index: remoting/host/linux/x_server_key_mapper.h |
| diff --git a/remoting/host/linux/x_server_key_mapper.h b/remoting/host/linux/x_server_key_mapper.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..62cbde053e607e7bafc97d205c71ddc3660b1c11 |
| --- /dev/null |
| +++ b/remoting/host/linux/x_server_key_mapper.h |
| @@ -0,0 +1,61 @@ |
| +// Copyright 2016 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 REMOTING_HOST_LINUX_X_SERVER_KEY_MAPPER_H_ |
| +#define REMOTING_HOST_LINUX_X_SERVER_KEY_MAPPER_H_ |
| + |
| +#include <stdint.h> |
| +#include <X11/Xlib.h> |
| + |
| +#include <vector> |
| + |
| +#include "base/macros.h" |
| +#include "base/time/time.h" |
| + |
| +namespace remoting { |
| + |
| +class KeyboardInterface; |
| + |
| +/** |
|
Sergey Ulanov
2016/09/21 19:59:23
Use C++ style comments please: //
Yuwei
2016/09/23 01:40:37
Done.
|
| + * This is a helper class for assigning unused keycodes to characters. When all |
| + * keycodes are used, newly added character will take the keycode of the oldest |
| + * character. |
| + * When the key mapper is destructed, all keycodes used by the mapper will be |
| + * reset to map NoSymbol. |
| + * The key mapper must be used on single thread thread. |
| + */ |
| +class XServerKeyMapper { |
|
Sergey Ulanov
2016/09/21 19:59:23
X11KeyMapper?
Yuwei
2016/09/23 01:40:37
Done.
|
| + public: |
| + struct MapResult { |
| + bool success; |
| + |
| + // |keycode| will only be valid if success == true. |
|
Sergey Ulanov
2016/09/21 19:59:23
Maybe remove success and use keycode=0 to indicate
Yuwei
2016/09/23 01:40:37
Just think could keycode 0 be used for mapping...
|
| + uint32_t keycode; |
| + |
| + // If success == false and |retry_after| is not zero, user may retry |
| + // AddNewCharacter() after |retry_after| has elapsed. |
| + base::TimeDelta retry_after; |
| + }; |
| + |
| + explicit XServerKeyMapper(KeyboardInterface* keyboard); |
| + ~XServerKeyMapper(); |
| + |
| + // |code_point|: The Unicode code point for the character. |
| + // Returns the result of the mapping attempt. |
| + MapResult AddNewCharacter(uint32_t code_point); |
| + |
| + private: |
| + struct KeyInfo; |
| + |
| + KeyboardInterface* keyboard_; |
| + |
| + std::vector<KeyInfo> available_keycodes_; |
| + int current_keycode_index_ = 0; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(XServerKeyMapper); |
| +}; |
| + |
| +} // namespace remoting |
| + |
| +#endif // REMOTING_HOST_LINUX_X_SERVER_KEY_MAPPER_H_ |