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

Side by Side Diff: ui/base/ime/mock_input_method.cc

Issue 8964011: Do not use ui::GetCharacterFromXEvent when Control is pressed. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/base/ime/input_method_ibus.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/base/ime/mock_input_method.h" 5 #include "ui/base/ime/mock_input_method.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/string16.h" 8 #include "base/string16.h"
9 #include "ui/base/events.h" 9 #include "ui/base/events.h"
10 #include "ui/base/glib/glib_integers.h" 10 #include "ui/base/glib/glib_integers.h"
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 TextInputClient* MockInputMethod::GetTextInputClient() const { 55 TextInputClient* MockInputMethod::GetTextInputClient() const {
56 return text_input_client_; 56 return text_input_client_;
57 } 57 }
58 58
59 void MockInputMethod::DispatchKeyEvent(const base::NativeEvent& native_event) { 59 void MockInputMethod::DispatchKeyEvent(const base::NativeEvent& native_event) {
60 #if defined(USE_X11) 60 #if defined(USE_X11)
61 if (native_event->type == KeyRelease) { 61 if (native_event->type == KeyRelease) {
62 // On key release, just dispatch it. 62 // On key release, just dispatch it.
63 delegate_->DispatchKeyEventPostIME(native_event); 63 delegate_->DispatchKeyEventPostIME(native_event);
64 } else { 64 } else {
65 const uint32 state = 65 const uint32 state = EventFlagsFromXFlags(native_event->xkey.state);
66 EventFlagsFromXFlags(reinterpret_cast<XKeyEvent*>(native_event)->state);
67 if (consume_next_key_) { 66 if (consume_next_key_) {
68 // Send the VKEY_PROCESSKEY RawKeyDown event. 67 // Send the VKEY_PROCESSKEY RawKeyDown event.
69 SendFakeProcessKeyEvent(true, state); 68 SendFakeProcessKeyEvent(true, state);
70 } else { 69 } else {
71 // Send a RawKeyDown event first, 70 // Send a RawKeyDown event first,
72 delegate_->DispatchKeyEventPostIME(native_event); 71 delegate_->DispatchKeyEventPostIME(native_event);
73 if (text_input_client_) { 72 if (text_input_client_) {
74 // then send a Char event via ui::TextInputClient. 73 // then send a Char event via ui::TextInputClient.
75 const KeyboardCode key_code = ui::KeyboardCodeFromNative(native_event); 74 const KeyboardCode key_code = ui::KeyboardCodeFromNative(native_event);
76 uint16 ch = ui::GetCharacterFromXEvent(native_event); 75 uint16 ch = 0;
76 if (!(state & ui::EF_CONTROL_DOWN))
77 ch = ui::GetCharacterFromXEvent(native_event);
77 if (!ch) 78 if (!ch)
78 ch = ui::GetCharacterFromKeyCode(key_code, state); 79 ch = ui::GetCharacterFromKeyCode(key_code, state);
79 if (ch) 80 if (ch)
80 text_input_client_->InsertChar(ch, state); 81 text_input_client_->InsertChar(ch, state);
81 } 82 }
82 } 83 }
83 } 84 }
84 consume_next_key_ = false; 85 consume_next_key_ = false;
85 #else 86 #else
86 // TODO(yusukes): Support Windows. 87 // TODO(yusukes): Support Windows.
(...skipping 27 matching lines...) Expand all
114 void MockInputMethod::ConsumeNextKey() { 115 void MockInputMethod::ConsumeNextKey() {
115 consume_next_key_ = true; 116 consume_next_key_ = true;
116 } 117 }
117 118
118 void MockInputMethod::SendFakeProcessKeyEvent(bool pressed, int flags) const { 119 void MockInputMethod::SendFakeProcessKeyEvent(bool pressed, int flags) const {
119 delegate_->DispatchFabricatedKeyEventPostIME( 120 delegate_->DispatchFabricatedKeyEventPostIME(
120 pressed ? ET_KEY_PRESSED : ET_KEY_RELEASED, VKEY_PROCESSKEY, flags); 121 pressed ? ET_KEY_PRESSED : ET_KEY_RELEASED, VKEY_PROCESSKEY, flags);
121 } 122 }
122 123
123 } // namespace ui 124 } // namespace ui
OLDNEW
« no previous file with comments | « ui/base/ime/input_method_ibus.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698