summaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-22 23:53:55 +0000
committerananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-22 23:53:55 +0000
commit35cd96d167a100094727640b7832d9d3a2b3eb06 (patch)
tree5cc8dd401ea161f2c93886d6aad2227b555afc2a /ui
parent4907c84d52411cdc8dd78b613eeeb5bbad5ad0ab (diff)
downloadchromium_src-35cd96d167a100094727640b7832d9d3a2b3eb06.zip
chromium_src-35cd96d167a100094727640b7832d9d3a2b3eb06.tar.gz
chromium_src-35cd96d167a100094727640b7832d9d3a2b3eb06.tar.bz2
Get text input to be plumbed through to the RenderWidgetHostViewAura instance on Windows in desktop mode.
This is achieved by passing the InputMethod instance to the InputMethodWin class which handles text input. In the OnChar handling we look for the TextInputClient implementation on the focused view and on failing to find that we retrieve that from the InputMethod instance. BUG=157172 R=ben Review URL: https://codereview.chromium.org/11228032 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@163446 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r--ui/views/ime/input_method_win.cc18
-rw-r--r--ui/views/ime/input_method_win.h13
-rw-r--r--ui/views/widget/desktop_root_window_host_win.cc13
-rw-r--r--ui/views/widget/native_widget_win.cc2
4 files changed, 41 insertions, 5 deletions
diff --git a/ui/views/ime/input_method_win.cc b/ui/views/ime/input_method_win.cc
index 585c001..f64c5d2 100644
--- a/ui/views/ime/input_method_win.cc
+++ b/ui/views/ime/input_method_win.cc
@@ -10,6 +10,7 @@
#include "ui/base/events/event.h"
#include "ui/base/events/event_constants.h"
#include "ui/base/ime/composition_text.h"
+#include "ui/base/ime/input_method.h"
#include "ui/base/ime/text_input_client.h"
#include "ui/base/keycodes/keyboard_codes.h"
@@ -20,11 +21,13 @@ static const size_t kExtraNumberOfChars = 20;
namespace views {
InputMethodWin::InputMethodWin(internal::InputMethodDelegate* delegate,
- HWND hwnd)
+ HWND hwnd,
+ ui::InputMethod* host)
: hwnd_(hwnd),
active_(false),
direction_(base::i18n::UNKNOWN_DIRECTION),
- pending_requested_direction_(base::i18n::UNKNOWN_DIRECTION) {
+ pending_requested_direction_(base::i18n::UNKNOWN_DIRECTION),
+ host_(host) {
set_delegate(delegate);
}
@@ -108,6 +111,14 @@ bool InputMethodWin::IsActive() {
return active_;
}
+ui::TextInputClient* InputMethodWin::GetTextInputClient() const {
+ if (InputMethodBase::GetTextInputClient())
+ return InputMethodBase::GetTextInputClient();
+
+ return host_ ? host_->GetTextInputClient() : NULL;
+}
+
+
LRESULT InputMethodWin::OnImeMessages(
UINT message, WPARAM w_param, LPARAM l_param, BOOL* handled) {
LRESULT result = 0;
@@ -275,6 +286,9 @@ LRESULT InputMethodWin::OnDeadChar(
if (IsTextInputTypeNone())
return 0;
+ if (!GetTextInputClient())
+ return 0;
+
// Shows the dead character as a composition text, so that the user can know
// what dead key was pressed.
ui::CompositionText composition;
diff --git a/ui/views/ime/input_method_win.h b/ui/views/ime/input_method_win.h
index 6304b97..730a950 100644
--- a/ui/views/ime/input_method_win.h
+++ b/ui/views/ime/input_method_win.h
@@ -16,12 +16,18 @@
#include "ui/views/view.h"
#include "ui/views/widget/widget.h"
+namespace ui {
+class InputMethod;
+} // namespace ui
+
namespace views {
// An InputMethod implementation based on Windows IMM32 API.
class InputMethodWin : public InputMethodBase {
public:
- InputMethodWin(internal::InputMethodDelegate* delegate, HWND hwnd);
+ InputMethodWin(internal::InputMethodDelegate* delegate,
+ HWND hwnd,
+ ui::InputMethod* host);
virtual ~InputMethodWin();
// Overridden from InputMethod:
@@ -36,6 +42,9 @@ class InputMethodWin : public InputMethodBase {
virtual base::i18n::TextDirection GetInputTextDirection() OVERRIDE;
virtual bool IsActive() OVERRIDE;
+ // Overridden from InputMethodBase.
+ virtual ui::TextInputClient* GetTextInputClient() const OVERRIDE;
+
// Handles IME messages.
LRESULT OnImeMessages(UINT message, WPARAM wparam, LPARAM lparam,
BOOL* handled);
@@ -96,6 +105,8 @@ class InputMethodWin : public InputMethodBase {
// (See "ui/base/win/ime_input.h" for its details.)
ui::ImeInput ime_input_;
+ ui::InputMethod* const host_;
+
DISALLOW_COPY_AND_ASSIGN(InputMethodWin);
};
diff --git a/ui/views/widget/desktop_root_window_host_win.cc b/ui/views/widget/desktop_root_window_host_win.cc
index 88826a8..3a319b5 100644
--- a/ui/views/widget/desktop_root_window_host_win.cc
+++ b/ui/views/widget/desktop_root_window_host_win.cc
@@ -6,6 +6,7 @@
#include "third_party/skia/include/core/SkPath.h"
#include "third_party/skia/include/core/SkRegion.h"
+#include "ui/aura/client/aura_constants.h"
#include "ui/aura/desktop/desktop_activation_client.h"
#include "ui/aura/desktop/desktop_cursor_client.h"
#include "ui/aura/desktop/desktop_dispatcher_client.h"
@@ -224,7 +225,17 @@ void DesktopRootWindowHostWin::SetAlwaysOnTop(bool always_on_top) {
}
InputMethod* DesktopRootWindowHostWin::CreateInputMethod() {
- return new InputMethodWin(message_handler_.get(), message_handler_->hwnd());
+ // TODO(ime): This is wrong. We need to hook up the native win32 IME on the
+ // InputMethodEventFilter, and instead create an InputMethodBridge
+ // per-NativeWidget implementation. Once we achieve that we can get rid of
+ // this function on this object and DesktopRootWindowHostLinux and just
+ // create the InputMethodBridge directly in DesktopNativeWidgetAura. Also
+ // at that time DNWA can become the InputMethodDelegate.
+ ui::InputMethod* host =
+ root_window_->GetProperty(aura::client::kRootWindowInputMethodKey);
+ return new InputMethodWin(message_handler_.get(),
+ message_handler_->hwnd(),
+ host);
}
internal::InputMethodDelegate*
diff --git a/ui/views/widget/native_widget_win.cc b/ui/views/widget/native_widget_win.cc
index de8341f..904e8c1 100644
--- a/ui/views/widget/native_widget_win.cc
+++ b/ui/views/widget/native_widget_win.cc
@@ -246,7 +246,7 @@ bool NativeWidgetWin::HasCapture() const {
InputMethod* NativeWidgetWin::CreateInputMethod() {
return views::Textfield::IsViewsTextfieldEnabled() ?
- new InputMethodWin(GetMessageHandler(), GetNativeWindow()) : NULL;
+ new InputMethodWin(GetMessageHandler(), GetNativeWindow(), NULL) : NULL;
}
internal::InputMethodDelegate* NativeWidgetWin::GetInputMethodDelegate() {