| Index: remoting/host/linux/x11_key_mapper.h
|
| diff --git a/remoting/host/linux/x11_key_mapper.h b/remoting/host/linux/x11_key_mapper.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..404847b8abe34971934f1606acd45fb9b9b21e77
|
| --- /dev/null
|
| +++ b/remoting/host/linux/x11_key_mapper.h
|
| @@ -0,0 +1,74 @@
|
| +// 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_X11_KEY_MAPPER_H_
|
| +#define REMOTING_HOST_LINUX_X11_KEY_MAPPER_H_
|
| +
|
| +#include <stdint.h>
|
| +
|
| +#include <memory>
|
| +#include <vector>
|
| +
|
| +#include "base/macros.h"
|
| +#include "base/time/time.h"
|
| +
|
| +namespace base {
|
| +class TickClock;
|
| +} // namespace base
|
| +
|
| +namespace remoting {
|
| +
|
| +class X11Keyboard;
|
| +
|
| +// This is a helper class for finding keycode for a character and assigning
|
| +// unused keycode to the character when it is not mapped.
|
| +// When the key mapper is destructed, all keycodes changed by the mapper will be
|
| +// reset to map NoSymbol.
|
| +// The key mapper must be used on single thread thread.
|
| +class X11KeyMapper {
|
| + public:
|
| + struct MapResult {
|
| + bool success;
|
| +
|
| + uint32_t keycode;
|
| + uint32_t modifiers;
|
| +
|
| + // If success == false and |retry_after| is not zero, user may retry
|
| + // AddNewCharacter() after |retry_after| has elapsed.
|
| + base::TimeDelta retry_after;
|
| + };
|
| +
|
| + explicit X11KeyMapper(X11Keyboard* keyboard);
|
| + ~X11KeyMapper();
|
| +
|
| + // |code_point|: The Unicode code point for the character.
|
| + // If the returned result indicates success, caller can use the returned
|
| + // keycode and modifiers to simulate a key press that can generate the
|
| + // character.
|
| + //
|
| + // Note that the returned result will expire after some amount of time so do
|
| + // not store the result for later use.
|
| + MapResult MapCharacter(uint32_t code_point);
|
| +
|
| + void SetClockForTesting(std::unique_ptr<base::TickClock> clock);
|
| +
|
| + private:
|
| + struct KeyInfo;
|
| +
|
| + // Resets the expiration time of the KeyInfo in available_keycodes_[index]
|
| + // to now + the expire duration constant.
|
| + void ResetKeyInfoExpirationTime(std::vector<KeyInfo>::iterator position);
|
| +
|
| + X11Keyboard* keyboard_;
|
| + std::unique_ptr<base::TickClock> clock_;
|
| +
|
| + // Sorted by ascending expiration time.
|
| + std::vector<KeyInfo> available_keycodes_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(X11KeyMapper);
|
| +};
|
| +
|
| +} // namespace remoting
|
| +
|
| +#endif // REMOTING_HOST_LINUX_X11_KEY_MAPPER_H_
|
|
|