Skip to content

Commit

Permalink
Ensure that keyboard input works in Windows 8 Metro Ash
Browse files Browse the repository at this point in the history
This regressed with the recent InputMethod changes. Fix is to implement the InputMethodWin::DispatchFabricatedKeyEvent
function to handle characters and keyboard events. Removed the corresponding implementation from the MockInputMethod class.

BUG=151718
R=sky
Review URL: https://codereview.chromium.org/11474031

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@171901 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
ananta@chromium.org committed Dec 8, 2012
1 parent 1ff4d28 commit e61449d
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 17 deletions.
17 changes: 17 additions & 0 deletions ui/base/ime/input_method_win.cc
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,23 @@ void InputMethodWin::DispatchKeyEvent(
DispatchKeyEventPostIME(native_key_event);
}

void InputMethodWin::DispatchFabricatedKeyEvent(const ui::KeyEvent& event) {
// TODO(ananta)
// Support IMEs and RTL layout in Windows 8 metro Ash. The code below won't
// work with IMEs.
// Bug: https://code.google.com/p/chromium/issues/detail?id=164964
if (event.is_char()) {
if (GetTextInputClient()) {
GetTextInputClient()->InsertChar(event.key_code(),
ui::GetModifiersFromKeyState());
return;
}
}
DispatchFabricatedKeyEventPostIME(event.type(),
event.key_code(),
event.flags());
}

void InputMethodWin::OnTextInputTypeChanged(const TextInputClient* client) {
if (IsTextInputClientFocused(client)) {
ime_input_.CancelIME(hwnd_);
Expand Down
2 changes: 1 addition & 1 deletion ui/base/ime/input_method_win.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class UI_EXPORT InputMethodWin : public InputMethodBase {
virtual void OnBlur() OVERRIDE;
virtual void DispatchKeyEvent(
const base::NativeEvent& native_key_event) OVERRIDE;
virtual void DispatchFabricatedKeyEvent(const ui::KeyEvent& event) OVERRIDE {}
virtual void DispatchFabricatedKeyEvent(const ui::KeyEvent& event) OVERRIDE;
virtual void OnTextInputTypeChanged(const TextInputClient* client) OVERRIDE;
virtual void OnCaretBoundsChanged(const TextInputClient* client) OVERRIDE;
virtual void CancelComposition(const TextInputClient* client) OVERRIDE;
Expand Down
15 changes: 0 additions & 15 deletions ui/base/ime/mock_input_method.cc
Original file line number Diff line number Diff line change
Expand Up @@ -94,21 +94,6 @@ void MockInputMethod::DispatchKeyEvent(const base::NativeEvent& native_event) {
#endif
}

void MockInputMethod::DispatchFabricatedKeyEvent(const ui::KeyEvent& event) {
#if defined(OS_WIN)
if (event.is_char()) {
if (GetTextInputClient()) {
GetTextInputClient()->InsertChar(event.key_code(),
ui::GetModifiersFromKeyState());
return;
}
}
delegate_->DispatchFabricatedKeyEventPostIME(event.type(),
event.key_code(),
event.flags());
#endif
}

void MockInputMethod::Init(bool focused) {}
void MockInputMethod::OnFocus() {}
void MockInputMethod::OnBlur() {}
Expand Down
3 changes: 2 additions & 1 deletion ui/base/ime/mock_input_method.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ class UI_EXPORT MockInputMethod : NON_EXPORTED_BASE(public InputMethod) {
virtual void SetFocusedTextInputClient(TextInputClient* client) OVERRIDE;
virtual TextInputClient* GetTextInputClient() const OVERRIDE;
virtual void DispatchKeyEvent(const base::NativeEvent& native_event) OVERRIDE;
virtual void DispatchFabricatedKeyEvent(const ui::KeyEvent& event) OVERRIDE;
virtual void DispatchFabricatedKeyEvent(const ui::KeyEvent& event) OVERRIDE {
}
virtual void OnTextInputTypeChanged(const TextInputClient* client) OVERRIDE;
virtual void OnCaretBoundsChanged(const TextInputClient* client) OVERRIDE;
virtual void CancelComposition(const TextInputClient* client) OVERRIDE;
Expand Down

0 comments on commit e61449d

Please sign in to comment.