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

Unified Diff: remoting/host/linux/x_server_key_mapper.h

Issue 2346643003: [Remoting Host] Handle text event characters that are not presented on the keyboard (Closed)
Patch Set: Create KeyboardInterface and XServerKeyboardInterface Created 4 years, 3 months 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: 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_

Powered by Google App Engine
This is Rietveld 408576698