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

Unified Diff: remoting/host/input_injector_x11.cc

Issue 2346643003: [Remoting Host] Handle text event characters that are not presented on the keyboard (Closed)
Patch Set: Merge ToT 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/input_injector_x11.cc
diff --git a/remoting/host/input_injector_x11.cc b/remoting/host/input_injector_x11.cc
index 3c9d0a88fe17565532968acb8a2f348e25f0d80d..978e8b6cf9df60f191fd3f40a6e0b8db6f845200 100644
--- a/remoting/host/input_injector_x11.cc
+++ b/remoting/host/input_injector_x11.cc
@@ -25,6 +25,7 @@
#include "remoting/base/logging.h"
#include "remoting/host/clipboard.h"
#include "remoting/host/linux/unicode_to_keysym.h"
+#include "remoting/host/linux/x11_character_injector.h"
#include "remoting/host/linux/x11_util.h"
#include "remoting/proto/internal.pb.h"
#include "third_party/webrtc/modules/desktop_capture/desktop_geometry.h"
@@ -45,56 +46,6 @@ using protocol::TextEvent;
using protocol::MouseEvent;
using protocol::TouchEvent;
-bool FindKeycodeForKeySym(Display* display,
- KeySym key_sym,
- uint32_t* keycode,
- uint32_t* modifiers) {
- *keycode = XKeysymToKeycode(display, key_sym);
-
- const uint32_t kModifiersToTry[] = {
- 0,
- ShiftMask,
- Mod2Mask,
- Mod3Mask,
- Mod4Mask,
- ShiftMask | Mod2Mask,
- ShiftMask | Mod3Mask,
- ShiftMask | Mod4Mask,
- };
-
- // TODO(sergeyu): Is there a better way to find modifiers state?
- for (size_t i = 0; i < arraysize(kModifiersToTry); ++i) {
- unsigned long key_sym_with_mods;
- if (XkbLookupKeySym(display, *keycode, kModifiersToTry[i], nullptr,
- &key_sym_with_mods) &&
- key_sym_with_mods == key_sym) {
- *modifiers = kModifiersToTry[i];
- return true;
- }
- }
-
- return false;
-}
-
-// Finds a keycode and set of modifiers that generate character with the
-// specified |code_point|.
-bool FindKeycodeForUnicode(Display* display,
- uint32_t code_point,
- uint32_t* keycode,
- uint32_t* modifiers) {
- std::vector<uint32_t> keysyms;
- GetKeySymsForUnicode(code_point, &keysyms);
-
- for (std::vector<uint32_t>::iterator it = keysyms.begin();
- it != keysyms.end(); ++it) {
- if (FindKeycodeForKeySym(display, *it, keycode, modifiers)) {
- return true;
- }
- }
-
- return false;
-}
-
bool IsModifierKey(ui::DomCode dom_code) {
return dom_code == ui::DomCode::CONTROL_LEFT ||
dom_code == ui::DomCode::SHIFT_LEFT ||
@@ -199,6 +150,8 @@ class InputInjectorX11 : public InputInjector {
std::unique_ptr<Clipboard> clipboard_;
+ std::unique_ptr<X11CharacterInjector> character_injector_;
+
bool saved_auto_repeat_enabled_;
DISALLOW_COPY_AND_ASSIGN(Core);
@@ -364,21 +317,8 @@ void InputInjectorX11::Core::InjectTextEvent(const TextEvent& event) {
text.c_str(), text.size(), &index, &code_point)) {
continue;
}
-
- uint32_t keycode;
- uint32_t modifiers;
- if (!FindKeycodeForUnicode(display_, code_point, &keycode, &modifiers))
- continue;
-
- XkbLockModifiers(display_, XkbUseCoreKbd, modifiers, modifiers);
-
- XTestFakeKeyEvent(display_, keycode, True, CurrentTime);
- XTestFakeKeyEvent(display_, keycode, False, CurrentTime);
-
- XkbLockModifiers(display_, XkbUseCoreKbd, modifiers, 0);
+ character_injector_->Inject(code_point);
}
-
- XFlush(display_);
}
InputInjectorX11::Core::~Core() {
@@ -634,6 +574,8 @@ void InputInjectorX11::Core::Start(
InitMouseButtonMap();
clipboard_->Start(std::move(client_clipboard));
+
+ character_injector_.reset(new X11CharacterInjector(display_));
}
void InputInjectorX11::Core::Stop() {
@@ -643,6 +585,7 @@ void InputInjectorX11::Core::Stop() {
}
clipboard_.reset();
+ character_injector_.reset();
}
} // namespace

Powered by Google App Engine
This is Rietveld 408576698