summaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-12-06 21:27:16 +0000
committerben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-12-06 21:27:16 +0000
commitd386ba0e78a3f811e299458f06be6a2328a7eb51 (patch)
tree2b71ec9d03663cb51ec4f07735be811f17245ef3 /ui
parentde15534df87f1bf156b961bc94ee347cbaa3c432 (diff)
downloadchromium_src-d386ba0e78a3f811e299458f06be6a2328a7eb51.zip
chromium_src-d386ba0e78a3f811e299458f06be6a2328a7eb51.tar.gz
chromium_src-d386ba0e78a3f811e299458f06be6a2328a7eb51.tar.bz2
Revert 113224 - IME (input method editor) support for Aura, part 3 of 3: Use ui::InputMethod in ui/aura/.
Part 1: http://codereview.chromium.org/8659033/ Part 2: http://codereview.chromium.org/8687027/ The basic design of the feature is that to add an input method object to DesktopHost to feed all KeyPress and KeyRelease events from the system message loop to the input method, and let the input method send IME results (e.g. composition text) to RenderWidgetHostViewAura or NativeWidgetAura as needed. RenderWidgetHostViewAura: - Just like RWHVV, implement ui::TextInputClient interface so that RWHVA could receive an event such as 'SetComposition' and 'InsertChar' from an input method object owned by DesktopHost. - Send a notification to the input method object on focus, blur, text input type change, etc. - OnKeyEvent() handler is now able to handle a non-native key event, e.g. a VKEY_PROCESSKEY event, which is fabricated by the input method editor. NativeWidgetAura: - Use views::InputMethodBridge instead of views::InputMethodIBus. - InputMethodBridge, which implements ui::TextInputClient interface, just receives IME results (e.g. composition text) from ui::InputMethod and forwards them to UI (e.g. a text field). - InputMethodBridge also receives a request like 'CancelComposition' from the UI and forwards the request to ui::InputMethod. DesktopHostLinux: - Creates and owns a ui::InputMethodIBusAura object. If IBus-1.4 is not available (e.g. Goobuntu), creates an instance of ui::MockInputMethod. - In Dispatch(), send a KeyPress and KeyRelease aura event to the input method. - Implement ui::InputMethodDelegate interface so that DesktopHostLinux could receive an key press and key release event which should be sent to NWA or RWHVA. Note that an "is_char" event is always sent directly from the input method to a TextInputClient. the ui::InputMethodDelegate is not used for that purpose. - ShouldSendCharEventForKeyboardCode() is moved to ui::InputMethod since DesktopHostLinux no longer generates a Char event. DesktopHostWin: - IME is not supported yet. Supported platforms: - Aura + Chrome OS (IME works!) - Aura + Chrome OS + TOUCH_UI (compiles, but virtual keyboard is not shown since views::TextInputTypeTracker is not ported to Aura yet.) - Aura + Linux, with and without IBus-1.4 - Aura + Windows (compiles, but IME does not work. views::InputMethodWin is not ported to Aura yet.) BUG=97261 TEST=ran aura_unittests Review URL: http://codereview.chromium.org/8576005 TBR=yusukes@chromium.org Review URL: http://codereview.chromium.org/8824007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@113259 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r--ui/aura/aura.gyp8
-rw-r--r--ui/aura/desktop.cc5
-rw-r--r--ui/aura/desktop.h10
-rw-r--r--ui/aura/desktop_host.h16
-rw-r--r--ui/aura/desktop_host_ime_unittest.cc314
-rw-r--r--ui/aura/desktop_host_linux.cc119
-rw-r--r--ui/aura/desktop_host_win.cc25
-rw-r--r--ui/aura/desktop_host_win.h18
-rw-r--r--ui/aura/event.h1
-rw-r--r--ui/base/keycodes/keyboard_code_conversion.cc4
-rw-r--r--ui/base/keycodes/keyboard_code_conversion_x.h1
-rw-r--r--ui/views/widget/native_widget_aura.cc11
12 files changed, 61 insertions, 471 deletions
diff --git a/ui/aura/aura.gyp b/ui/aura/aura.gyp
index c87ce3e..6d98b42 100644
--- a/ui/aura/aura.gyp
+++ b/ui/aura/aura.gyp
@@ -53,13 +53,6 @@
'window_observer.h',
'window_types.h',
],
- 'conditions': [
- ['use_ibus==1', {
- 'dependencies': [
- '../../build/linux/system.gyp:ibus',
- ],
- }],
- ],
},
{
'target_name': 'test_support_aura',
@@ -138,7 +131,6 @@
'test/run_all_unittests.cc',
'test/test_suite.cc',
'test/test_suite.h',
- 'desktop_host_ime_unittest.cc',
'desktop_unittest.cc',
'event_filter_unittest.cc',
'window_unittest.cc',
diff --git a/ui/aura/desktop.cc b/ui/aura/desktop.cc
index 4fae6fb..7bf25d3 100644
--- a/ui/aura/desktop.cc
+++ b/ui/aura/desktop.cc
@@ -24,7 +24,6 @@
#include "ui/aura/window.h"
#include "ui/aura/window_delegate.h"
#include "ui/base/hit_test.h"
-#include "ui/base/ime/input_method.h"
#include "ui/gfx/compositor/compositor.h"
#include "ui/gfx/compositor/layer.h"
#include "ui/gfx/compositor/layer_animator.h"
@@ -609,8 +608,4 @@ gfx::Rect Desktop::GetInitialHostWindowBounds() const {
return bounds;
}
-ui::InputMethod* Desktop::GetInputMethod() {
- return host_->GetInputMethod();
-}
-
} // namespace aura
diff --git a/ui/aura/desktop.h b/ui/aura/desktop.h
index b0ff82a..d76e43e 100644
--- a/ui/aura/desktop.h
+++ b/ui/aura/desktop.h
@@ -26,17 +26,12 @@ class Size;
}
namespace ui {
-class InputMethod;
class LayerAnimationSequence;
class Transform;
}
namespace aura {
-namespace test {
-class DesktopHostIMETest;
-} // namespace test
-
class DesktopHost;
class DesktopObserver;
class KeyEvent;
@@ -150,9 +145,6 @@ class AURA_EXPORT Desktop : public ui::CompositorDelegate,
// Overridden from Window:
virtual void SetTransform(const ui::Transform& transform) OVERRIDE;
- // Gets the input method for the desktop.
- ui::InputMethod* GetInputMethod();
-
#if !defined(NDEBUG)
// Toggles the host's full screen state.
void ToggleFullScreen();
@@ -162,8 +154,6 @@ class AURA_EXPORT Desktop : public ui::CompositorDelegate,
virtual void ScheduleDraw();
private:
- friend class aura::test::DesktopHostIMETest; // need to access |host_|.
-
Desktop();
virtual ~Desktop();
diff --git a/ui/aura/desktop_host.h b/ui/aura/desktop_host.h
index b74c8b4..f72fc52 100644
--- a/ui/aura/desktop_host.h
+++ b/ui/aura/desktop_host.h
@@ -8,13 +8,8 @@
#include "base/message_loop.h"
#include "ui/aura/cursor.h"
-#include "ui/base/ime/input_method_delegate.h"
#include "ui/gfx/native_widget_types.h"
-namespace ui {
-class InputMethod;
-}
-
namespace gfx {
class Point;
class Rect;
@@ -27,8 +22,7 @@ class Desktop;
// DesktopHost bridges between a native window and the embedded Desktop. It
// provides the accelerated widget and maps events from the native os to aura.
-class DesktopHost : public MessageLoop::Dispatcher,
- public ui::internal::InputMethodDelegate {
+class DesktopHost : public MessageLoop::Dispatcher {
public:
virtual ~DesktopHost() {}
@@ -70,14 +64,6 @@ class DesktopHost : public MessageLoop::Dispatcher,
// Posts |native_event| to the platform's event queue.
virtual void PostNativeEvent(const base::NativeEvent& native_event) = 0;
-
- // Sets the input method for the desktop. DesktopHost owns the input method.
- // The function is only for unit tests.
- virtual void SetInputMethod(ui::InputMethod* input_method) = 0;
-
- // Gets the input method for the desktop. The caller does not own the returned
- // value.
- virtual ui::InputMethod* GetInputMethod() const = 0;
};
} // namespace aura
diff --git a/ui/aura/desktop_host_ime_unittest.cc b/ui/aura/desktop_host_ime_unittest.cc
deleted file mode 100644
index 61a0b87..0000000
--- a/ui/aura/desktop_host_ime_unittest.cc
+++ /dev/null
@@ -1,314 +0,0 @@
-// Copyright (c) 2011 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.
-
-#include "ui/aura/desktop_host.h"
-
-#if defined(USE_X11)
-#include <X11/keysym.h>
-#include <X11/Xlib.h>
-#undef Bool
-#undef None
-#undef Status
-#endif
-
-#include <cstring>
-
-#include "base/message_loop.h"
-#include "testing/gtest/include/gtest/gtest.h"
-#include "ui/aura/desktop.h"
-#include "ui/aura/event.h"
-#include "ui/aura/test/aura_test_base.h"
-#include "ui/aura/test/test_window_delegate.h"
-#include "ui/aura/test/test_windows.h"
-#include "ui/base/ime/input_method_delegate.h"
-#include "ui/base/ime/mock_input_method.h"
-#include "ui/base/ime/text_input_client.h"
-#if defined(USE_X11)
-#include "ui/base/x/x11_util.h"
-#endif
-#include "ui/gfx/rect.h"
-
-#if !defined(USE_X11)
-#define PostKeyEvent DISABLED_PostKeyEvent
-#define PostKeyEventNoDummyDelegate DISABLED_PostKeyEventNoDummyDelegate
-#define PostKeyEventWithInputMethodNoDummyDelegate \
-DISABLED_PostKeyEventWithInputMethodNoDummyDelegate
-#endif
-
-namespace aura {
-namespace test {
-
-namespace {
-
-// A dummy WindowDelegate implementation which quits a current message loop
-// when it receives a key event.
-class DummyWindowDelegate : public TestWindowDelegate {
- public:
- virtual ~DummyWindowDelegate() {
- }
- virtual bool OnKeyEvent(KeyEvent* event) OVERRIDE {
- MessageLoopForUI::current()->Quit();
- return true;
- }
-};
-
-// A dummy InputMethodDelegate implementation which quits a current message loop
-// when it receives a native or fabricated key event.
-class DummyInputMethodDelegate : public ui::internal::InputMethodDelegate {
- public:
- DummyInputMethodDelegate() {
- ResetFlags();
- }
- virtual ~DummyInputMethodDelegate() {}
-
- virtual void DispatchKeyEventPostIME(
- const base::NativeEvent& native_key_event) OVERRIDE {
- has_key_event_ = true;
- MessageLoopForUI::current()->Quit();
- }
- virtual void DispatchFabricatedKeyEventPostIME(
- ui::EventType type, ui::KeyboardCode key_code, int flags) OVERRIDE {
- has_fabricated_key_event_ = true;
- MessageLoopForUI::current()->Quit();
- }
-
- void ResetFlags() {
- has_key_event_ = has_fabricated_key_event_ = false;
- }
-
- bool has_key_event_;
- bool has_fabricated_key_event_;
-};
-
-// A dummy TextInputClient implementation which remembers if InsertChar function
-// is called.
-class DummyTextInputClient : public ui::TextInputClient {
- public:
- DummyTextInputClient() {
- ResetFlag();
- }
- virtual ~DummyTextInputClient() {
- }
-
- virtual void SetCompositionText(
- const ui::CompositionText& composition) OVERRIDE {}
- virtual void ConfirmCompositionText() OVERRIDE {}
- virtual void ClearCompositionText() OVERRIDE {}
- virtual void InsertText(const string16& text) OVERRIDE {}
- virtual void InsertChar(char16 ch, int flags) OVERRIDE {
- has_char_event_ = true;
- }
- virtual ui::TextInputType GetTextInputType() const OVERRIDE {
- return ui::TEXT_INPUT_TYPE_NONE;
- }
- virtual gfx::Rect GetCaretBounds() OVERRIDE {
- return gfx::Rect();
- }
- virtual bool HasCompositionText() OVERRIDE {
- return false;
- }
- virtual bool GetTextRange(ui::Range* range) OVERRIDE {
- return false;
- }
- virtual bool GetCompositionTextRange(ui::Range* range) OVERRIDE {
- return false;
- }
- virtual bool GetSelectionRange(ui::Range* range) OVERRIDE {
- return false;
- }
- virtual bool SetSelectionRange(const ui::Range& range) OVERRIDE {
- return false;
- }
- virtual bool DeleteRange(const ui::Range& range) OVERRIDE {
- return false;
- }
- virtual bool GetTextFromRange(
- const ui::Range& range, string16* text) OVERRIDE {
- return false;
- }
- virtual void OnInputMethodChanged() OVERRIDE {
- }
- virtual bool ChangeTextDirectionAndLayoutAlignment(
- base::i18n::TextDirection direction) OVERRIDE {
- return false;
- }
-
- void ResetFlag() {
- has_char_event_ = false;
- }
-
- bool has_char_event_;
-};
-
-// Returns a native key press or key release event.
-// TODO(yusukes): Add function parameters like |key_name| and |modifiers| so
-// that it could generate an event other than XK_space.
-base::NativeEvent SynthesizeKeyEvent(bool is_press) {
- base::NativeEvent event = base::NativeEvent();
-
-#if defined(USE_X11)
- event = new XEvent;
- std::memset(event, 0, sizeof(XEvent));
-
- Display* display = ui::GetXDisplay();
- ::Window focused;
- int dummy;
- XGetInputFocus(display, &focused, &dummy);
-
- XKeyEvent* key_event = &event->xkey;
- key_event->display = display;
- key_event->keycode = XKeysymToKeycode(display, XK_space);
- key_event->root = ui::GetX11RootWindow();
- key_event->same_screen = True;
- key_event->send_event = False;
- key_event->state = 0;
- key_event->subwindow = 0L; // None;
- key_event->time = CurrentTime;
- key_event->type = is_press ? KeyPress : KeyRelease;
- key_event->window = focused;
- key_event->x = key_event->x_root = key_event->y = key_event->y_root = 1;
-#else
- // TODO(yusukes): Support Windows.
- NOTIMPLEMENTED();
-#endif
-
- return event;
-}
-
-// Deletes a native event generated by SynthesizeKeyEvent() above.
-void Delete(base::NativeEvent event) {
-#if defined(USE_X11)
- delete event;
-#else
- // TODO(yusukes): Support Windows.
- NOTIMPLEMENTED();
-#endif
-}
-
-// Enters a nested message loop.
-void RunMessageLoop() {
- MessageLoop* loop = MessageLoop::current();
- const bool did_allow_task_nesting = loop->NestableTasksAllowed();
- loop->SetNestableTasksAllowed(true);
- aura::Desktop::GetInstance()->Run();
- loop->SetNestableTasksAllowed(did_allow_task_nesting);
-}
-
-} // namespace
-
-class DesktopHostIMETest : public AuraTestBase {
- protected:
- DesktopHostIMETest() : desktop_(Desktop::GetInstance()),
- host_(desktop_->host_.get()),
- input_method_(new ui::MockInputMethod(host_)),
- window_(CreateTestWindowWithDelegate(
- &window_delegate_, -1,
- gfx::Rect(2, 3, 4, 5), NULL)) {
- }
-
- virtual void SetUp() OVERRIDE {
- input_method_->Init(true);
- input_method_->SetFocusedTextInputClient(&text_input_client_);
- host_->SetInputMethod(input_method_); // pass ownership
- AuraTestBase::SetUp();
- }
-
- Desktop* desktop_;
- DesktopHost* host_;
- ui::MockInputMethod* input_method_;
-
- DummyInputMethodDelegate input_method_delegate_;
- DummyTextInputClient text_input_client_;
-
- DummyWindowDelegate window_delegate_;
- scoped_ptr<aura::Window> window_;
-};
-
-// Test if DesktopHost correctly passes a key press/release event to an IME.
-TEST_F(DesktopHostIMETest, PostKeyEvent) {
- input_method_->SetDelegate(&input_method_delegate_);
-
- // Press space. The press event should directly go to |input_method_delegate_|
- // and then, a 'Char' event should also be generated and passed to
- // |text_input_client_|.
- base::NativeEvent event = SynthesizeKeyEvent(true /* press */);
- host_->PostNativeEvent(event);
- // Enter a new message loop and wait for an InputMethodDelegate function to
- // be called.
- RunMessageLoop();
- EXPECT_TRUE(input_method_delegate_.has_key_event_);
- EXPECT_FALSE(input_method_delegate_.has_fabricated_key_event_);
- EXPECT_TRUE(text_input_client_.has_char_event_);
- input_method_delegate_.ResetFlags();
- text_input_client_.ResetFlag();
- Delete(event);
-
- // Release space. A Char event should NOT be generated.
- event = SynthesizeKeyEvent(false);
- host_->PostNativeEvent(event);
- RunMessageLoop();
- EXPECT_TRUE(input_method_delegate_.has_key_event_);
- EXPECT_FALSE(input_method_delegate_.has_fabricated_key_event_);
- EXPECT_FALSE(text_input_client_.has_char_event_);
- input_method_delegate_.ResetFlags();
- text_input_client_.ResetFlag();
- Delete(event);
-}
-
-// Do the same as above, but use the |host_| itself as ui::InputMethodDelegate
-// to see if DesktopHost::DispatchKeyEventPostIME() function correctly passes
-// a key event to the |desktop_|.
-TEST_F(DesktopHostIMETest, PostKeyEventNoDummyDelegate) {
- input_method_->SetDelegate(host_);
- // Call SetActiveWindow here so DummyWindowDelegate could receive a key event.
- desktop_->SetActiveWindow(window_.get(), NULL);
-
- // Press space. DummyWindowDelegate will quit the loop. A Char event should
- // be generated.
- base::NativeEvent event = SynthesizeKeyEvent(true /* press */);
- host_->PostNativeEvent(event);
- RunMessageLoop();
- EXPECT_TRUE(text_input_client_.has_char_event_);
- text_input_client_.ResetFlag();
- Delete(event);
-
- // Release space.
- event = SynthesizeKeyEvent(false);
- host_->PostNativeEvent(event);
- RunMessageLoop();
- EXPECT_FALSE(text_input_client_.has_char_event_);
- text_input_client_.ResetFlag();
- Delete(event);
-}
-
-// Do the same as above, but this time, |input_method_| consumes the key press
-// event. Checks if DesktopHost::DispatchFabricatedKeyEventPostIME() function
-// called by |input_method_| correctly passes a VK_PROCESS key event to the
-// |desktop_|.
-TEST_F(DesktopHostIMETest, PostKeyEventWithInputMethodNoDummyDelegate) {
- input_method_->SetDelegate(host_);
- input_method_->ConsumeNextKey();
- desktop_->SetActiveWindow(window_.get(), NULL);
-
- // Press space. The press event will be consumed by the mock IME and will not
- // be passed to the delegate. Instead, a fabricated key event (VK_PROCESSKEY)
- // will be passed to it. Char event should not be generated this time.
- base::NativeEvent event = SynthesizeKeyEvent(true);
- host_->PostNativeEvent(event);
- RunMessageLoop();
- EXPECT_FALSE(text_input_client_.has_char_event_);
- text_input_client_.ResetFlag();
- Delete(event);
-
- // Release space. A Char event should not be generated.
- event = SynthesizeKeyEvent(false);
- host_->PostNativeEvent(event);
- RunMessageLoop();
- EXPECT_FALSE(text_input_client_.has_char_event_);
- text_input_client_.ResetFlag();
- Delete(event);
-}
-
-} // namespace test
-} // namespace aura
diff --git a/ui/aura/desktop_host_linux.cc b/ui/aura/desktop_host_linux.cc
index 23b4907..5743936 100644
--- a/ui/aura/desktop_host_linux.cc
+++ b/ui/aura/desktop_host_linux.cc
@@ -12,8 +12,6 @@
#include <algorithm>
-#include "base/event_types.h"
-#include "base/memory/scoped_ptr.h"
#include "base/message_loop.h"
#include "base/message_pump_x.h"
#include "ui/aura/cursor.h"
@@ -28,12 +26,6 @@
#include <X11/extensions/XInput2.h>
#include <X11/Xlib.h>
-#if defined(HAVE_IBUS)
-#include "ui/base/ime/input_method_ibus.h"
-#else
-#include "ui/base/ime/mock_input_method.h"
-#endif
-
using std::max;
using std::min;
@@ -238,6 +230,47 @@ int CoalescePendingXIMotionEvents(const XEvent* xev, XEvent* last_event) {
return num_coalesed;
}
+// We emulate Windows' WM_KEYDOWN and WM_CHAR messages. WM_CHAR events are only
+// generated for certain keys; see
+// http://msdn.microsoft.com/en-us/library/windows/desktop/ms646268.aspx.
+bool ShouldSendCharEventForKeyboardCode(ui::KeyboardCode keycode) {
+ if ((keycode >= ui::VKEY_0 && keycode <= ui::VKEY_9) ||
+ (keycode >= ui::VKEY_A && keycode <= ui::VKEY_Z) ||
+ (keycode >= ui::VKEY_NUMPAD0 && keycode <= ui::VKEY_NUMPAD9)) {
+ return true;
+ }
+
+ switch (keycode) {
+ case ui::VKEY_BACK:
+ case ui::VKEY_RETURN:
+ case ui::VKEY_ESCAPE:
+ case ui::VKEY_SPACE:
+ case ui::VKEY_TAB:
+ // In addition to the keys listed at MSDN, we include other
+ // graphic-character and numpad keys.
+ case ui::VKEY_MULTIPLY:
+ case ui::VKEY_ADD:
+ case ui::VKEY_SUBTRACT:
+ case ui::VKEY_DECIMAL:
+ case ui::VKEY_DIVIDE:
+ case ui::VKEY_OEM_1:
+ case ui::VKEY_OEM_2:
+ case ui::VKEY_OEM_3:
+ case ui::VKEY_OEM_4:
+ case ui::VKEY_OEM_5:
+ case ui::VKEY_OEM_6:
+ case ui::VKEY_OEM_7:
+ case ui::VKEY_OEM_102:
+ case ui::VKEY_OEM_PLUS:
+ case ui::VKEY_OEM_COMMA:
+ case ui::VKEY_OEM_MINUS:
+ case ui::VKEY_OEM_PERIOD:
+ return true;
+ default:
+ return false;
+ }
+}
+
class DesktopHostLinux : public DesktopHost,
public MessageLoop::DestructionObserver {
public:
@@ -259,14 +292,6 @@ class DesktopHostLinux : public DesktopHost,
virtual void SetCursor(gfx::NativeCursor cursor_type) OVERRIDE;
virtual gfx::Point QueryMouseLocation() OVERRIDE;
virtual void PostNativeEvent(const base::NativeEvent& event) OVERRIDE;
- virtual void SetInputMethod(ui::InputMethod*) OVERRIDE;
- virtual ui::InputMethod* GetInputMethod() const OVERRIDE;
-
- // ui::internal::InputMethodDelegate Override.
- virtual void DispatchKeyEventPostIME(const base::NativeEvent& event) OVERRIDE;
- virtual void DispatchFabricatedKeyEventPostIME(ui::EventType type,
- ui::KeyboardCode key_code,
- int flags) OVERRIDE;
// MessageLoop::DestructionObserver Overrides.
virtual void WillDestroyCurrentMessageLoop() OVERRIDE;
@@ -285,9 +310,6 @@ class DesktopHostLinux : public DesktopHost,
// The native root window.
::Window root_window_;
- // The input method for the desktop.
- scoped_ptr<ui::InputMethod> input_method_;
-
// Current Aura cursor.
gfx::NativeCursor current_cursor_;
@@ -302,14 +324,6 @@ DesktopHostLinux::DesktopHostLinux(const gfx::Rect& bounds)
xdisplay_(base::MessagePumpX::GetDefaultXDisplay()),
xwindow_(0),
root_window_(DefaultRootWindow(xdisplay_)),
-#if defined(HAVE_IBUS)
- ALLOW_THIS_IN_INITIALIZER_LIST(
- input_method_(new ui::InputMethodIBus(this))),
-#else
- ALLOW_THIS_IN_INITIALIZER_LIST(
- input_method_(new ui::MockInputMethod(this))),
-#endif
-
current_cursor_(aura::kCursorNull),
bounds_(bounds) {
xwindow_ = XCreateSimpleWindow(xdisplay_, root_window_,
@@ -317,7 +331,7 @@ DesktopHostLinux::DesktopHostLinux(const gfx::Rect& bounds)
bounds.width(), bounds.height(),
0, 0, 0);
- long event_mask = ButtonPressMask | ButtonReleaseMask | FocusChangeMask |
+ long event_mask = ButtonPressMask | ButtonReleaseMask |
KeyPressMask | KeyReleaseMask |
EnterWindowMask | LeaveWindowMask |
ExposureMask | VisibilityChangeMask |
@@ -335,11 +349,6 @@ DesktopHostLinux::DesktopHostLinux(const gfx::Rect& bounds)
base::MessagePumpX::SetDefaultDispatcher(this);
MessageLoopForUI::current()->AddDestructionObserver(this);
-
- ::Window focused_window = None;
- int revert_to = 0;
- XGetInputFocus(xdisplay_, &focused_window, &revert_to);
- input_method_->Init(focused_window == xwindow_);
}
DesktopHostLinux::~DesktopHostLinux() {
@@ -363,10 +372,19 @@ base::MessagePumpDispatcher::DispatchStatus DesktopHostLinux::Dispatch(
desktop_->ScheduleDraw();
handled = true;
break;
- case KeyPress:
+ case KeyPress: {
+ KeyEvent keydown_event(xev, false);
+ handled = desktop_->DispatchKeyEvent(&keydown_event);
+ if (ShouldSendCharEventForKeyboardCode(keydown_event.key_code())) {
+ KeyEvent char_event(xev, true);
+ handled |= desktop_->DispatchKeyEvent(&char_event);
+ }
+ break;
+ }
case KeyRelease: {
- input_method_->DispatchKeyEvent(xev);
- handled = true;
+ KeyEvent keyup_event(xev, false);
+ handled = desktop_->DispatchKeyEvent(&keyup_event);
+ break;
}
case ButtonPress:
case ButtonRelease: {
@@ -444,14 +462,6 @@ base::MessagePumpDispatcher::DispatchStatus DesktopHostLinux::Dispatch(
XFreeEventData(xev->xgeneric.display, &last_event.xcookie);
break;
}
- case FocusIn: {
- input_method_->OnFocus();
- break;
- }
- case FocusOut: {
- input_method_->OnBlur();
- break;
- }
case MapNotify: {
// If there's no window manager running, we need to assign the X input
// focus to our host window.
@@ -601,27 +611,6 @@ bool DesktopHostLinux::IsWindowManagerPresent() {
return XGetSelectionOwner(xdisplay_, wm_s0_atom) != None;
}
-void DesktopHostLinux::SetInputMethod(ui::InputMethod* input_method) {
- input_method_.reset(input_method);
-}
-
-ui::InputMethod* DesktopHostLinux::GetInputMethod() const {
- return input_method_.get();
-}
-
-void DesktopHostLinux::DispatchKeyEventPostIME(const base::NativeEvent& event) {
- KeyEvent aura_event(event, false /* is_char */);
- desktop_->DispatchKeyEvent(&aura_event);
- // We don't send a Char event here since the input method takes care of it.
-}
-
-void DesktopHostLinux::DispatchFabricatedKeyEventPostIME(
- ui::EventType type, ui::KeyboardCode key_code, int flags) {
- // Dispatch a ui::VKEY_PROCESSKEY event etc. generated by |input_method_|.
- KeyEvent aura_event(type, key_code, flags);
- desktop_->DispatchKeyEvent(&aura_event);
-}
-
} // namespace
// static
diff --git a/ui/aura/desktop_host_win.cc b/ui/aura/desktop_host_win.cc
index 2e0d0e2..1809dda 100644
--- a/ui/aura/desktop_host_win.cc
+++ b/ui/aura/desktop_host_win.cc
@@ -11,7 +11,6 @@
#include "base/message_loop.h"
#include "ui/aura/desktop.h"
#include "ui/aura/event.h"
-#include "ui/base/ime/mock_input_method.h"
using std::max;
using std::min;
@@ -115,15 +114,11 @@ gfx::Size DesktopHost::GetNativeScreenSize() {
DesktopHostWin::DesktopHostWin(const gfx::Rect& bounds)
: desktop_(NULL),
- // TODO(yusukes): implement and use ui::InputMethodWin.
- ALLOW_THIS_IN_INITIALIZER_LIST(
- input_method_(new ui::MockInputMethod(this))),
fullscreen_(false),
saved_window_style_(0),
saved_window_ex_style_(0) {
Init(NULL, bounds);
SetWindowText(hwnd(), L"aura::Desktop!");
- input_method_->Init(true);
}
DesktopHostWin::~DesktopHostWin() {
@@ -242,25 +237,6 @@ void DesktopHostWin::PostNativeEvent(const base::NativeEvent& native_event) {
hwnd(), native_event.message, native_event.wParam, native_event.lParam);
}
-void DesktopHostWin::SetInputMethod(ui::InputMethod* input_method) {
- input_method_.reset(input_method);
-}
-
-ui::InputMethod* DesktopHostWin::GetInputMethod() const {
- return input_method_.get();
-}
-
-void DesktopHostWin::DispatchKeyEventPostIME(const base::NativeEvent& event) {
- // TODO(yusukes): Support input method.
- NOTIMPLEMENTED();
-}
-
-void DesktopHostWin::DispatchFabricatedKeyEventPostIME(
- ui::EventType type, ui::KeyboardCode key_code, int flags) {
- // TODO(yusukes): Support input method.
- NOTIMPLEMENTED();
-}
-
void DesktopHostWin::OnClose() {
// TODO: this obviously shouldn't be here.
MessageLoopForUI::current()->Quit();
@@ -269,7 +245,6 @@ void DesktopHostWin::OnClose() {
LRESULT DesktopHostWin::OnKeyEvent(UINT message,
WPARAM w_param,
LPARAM l_param) {
- // TODO(yusukes): Support input method.
MSG msg = { hwnd(), message, w_param, l_param };
KeyEvent keyev(msg, message == WM_CHAR);
SetMsgHandled(desktop_->DispatchKeyEvent(&keyev));
diff --git a/ui/aura/desktop_host_win.h b/ui/aura/desktop_host_win.h
index f6acdfb..cd9c136 100644
--- a/ui/aura/desktop_host_win.h
+++ b/ui/aura/desktop_host_win.h
@@ -7,18 +7,12 @@
#pragma once
#include "base/compiler_specific.h"
-#include "base/memory/scoped_ptr.h"
#include "ui/aura/desktop_host.h"
#include "ui/base/win/window_impl.h"
-namespace ui {
-class InputMethod;
-} // namespace ui
-
namespace aura {
-class DesktopHostWin : public DesktopHost,
- public ui::WindowImpl {
+class DesktopHostWin : public DesktopHost, public ui::WindowImpl {
public:
explicit DesktopHostWin(const gfx::Rect& bounds);
virtual ~DesktopHostWin();
@@ -38,14 +32,6 @@ class DesktopHostWin : public DesktopHost,
virtual gfx::Point QueryMouseLocation() OVERRIDE;
virtual void PostNativeEvent(const base::NativeEvent& native_event) OVERRIDE;
- virtual void SetInputMethod(ui::InputMethod* input_method) OVERRIDE;
- virtual ui::InputMethod* GetInputMethod() const OVERRIDE;
-
- // ui::internal::InputMethodDelegate Override.
- virtual void DispatchKeyEventPostIME(const base::NativeEvent& event) OVERRIDE;
- virtual void DispatchFabricatedKeyEventPostIME(
- ui::EventType type, ui::KeyboardCode key_code, int flags) OVERRIDE;
-
private:
BEGIN_MSG_MAP_EX(DesktopHostWin)
// Range handlers must go first!
@@ -74,8 +60,6 @@ class DesktopHostWin : public DesktopHost,
Desktop* desktop_;
- scoped_ptr<ui::InputMethod> input_method_;
-
bool fullscreen_;
RECT saved_window_rect_;
DWORD saved_window_style_;
diff --git a/ui/aura/event.h b/ui/aura/event.h
index 91e92cb..5dcb726 100644
--- a/ui/aura/event.h
+++ b/ui/aura/event.h
@@ -144,7 +144,6 @@ class AURA_EXPORT TouchEvent : public LocatedEvent {
class AURA_EXPORT KeyEvent : public Event {
public:
- // TODO(yusukes): Remove |is_char| when IME support for Aura is submitted.
KeyEvent(const base::NativeEvent& native_event, bool is_char);
// Used for synthetic events in testing.
diff --git a/ui/base/keycodes/keyboard_code_conversion.cc b/ui/base/keycodes/keyboard_code_conversion.cc
index 2ec06c3..0016f6d 100644
--- a/ui/base/keycodes/keyboard_code_conversion.cc
+++ b/ui/base/keycodes/keyboard_code_conversion.cc
@@ -56,10 +56,6 @@ uint16 GetCharacterFromKeyCode(KeyboardCode key_code, int flags) {
}
}
- // For IME support
- if (key_code == ui::VKEY_PROCESSKEY)
- return 0xE5;
-
// Normal characters
if (key_code >= VKEY_0 && key_code <= VKEY_9) {
return shift ? ")!@#$%^&*("[key_code - VKEY_0] :
diff --git a/ui/base/keycodes/keyboard_code_conversion_x.h b/ui/base/keycodes/keyboard_code_conversion_x.h
index 950a48a..7779483 100644
--- a/ui/base/keycodes/keyboard_code_conversion_x.h
+++ b/ui/base/keycodes/keyboard_code_conversion_x.h
@@ -17,7 +17,6 @@ UI_EXPORT KeyboardCode KeyboardCodeFromXKeyEvent(XEvent* xev);
UI_EXPORT KeyboardCode KeyboardCodeFromXKeysym(unsigned int keysym);
// Returns a key symbol on a standard US PC keyboard from an XEvent.
-// TODO(suzhe,yusukes): Rename this to GetCharacterFromXEvent().
UI_EXPORT unsigned int DefaultSymbolFromXEvent(XEvent* xev);
// Converts a KeyboardCode into an X KeySym.
diff --git a/ui/views/widget/native_widget_aura.cc b/ui/views/widget/native_widget_aura.cc
index c480722..2bdba97 100644
--- a/ui/views/widget/native_widget_aura.cc
+++ b/ui/views/widget/native_widget_aura.cc
@@ -32,7 +32,7 @@
#endif
#if defined(HAVE_IBUS)
-#include "ui/views/ime/input_method_bridge.h"
+#include "ui/views/ime/input_method_ibus.h"
#else
#include "ui/views/ime/mock_input_method.h"
#endif
@@ -278,10 +278,8 @@ bool NativeWidgetAura::HasMouseCapture() const {
InputMethod* NativeWidgetAura::CreateInputMethod() {
#if defined(HAVE_IBUS)
- ui::InputMethod* host = aura::Desktop::GetInstance()->GetInputMethod();
- InputMethod* input_method = new InputMethodBridge(this, host);
+ InputMethod* input_method = new InputMethodIBus(this);
#else
- // Use the mock IME for unit tests.
InputMethod* input_method = new MockInputMethod(this);
#endif
input_method->Init(GetWidget());
@@ -573,14 +571,15 @@ void NativeWidgetAura::OnBlur() {
}
bool NativeWidgetAura::OnKeyEvent(aura::KeyEvent* event) {
- // TODO(yusukes): Need an ui::InputMethod to properly handle character events.
- // Right now, we just skip these.
+ // TODO(beng): Need an InputMethodAura to properly handle character events.
+ // Right now, we just skip these.
if (event->is_char())
return false;
DCHECK(window_->IsVisible());
InputMethod* input_method = GetWidget()->GetInputMethod();
DCHECK(input_method);
+ // TODO(oshima): DispatchKeyEvent should return bool?
KeyEvent views_event(event);
input_method->DispatchKeyEvent(views_event);
return true;