summaryrefslogtreecommitdiffstats
path: root/views/ime
diff options
context:
space:
mode:
authorbacker@chromium.org <backer@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-08-26 18:14:45 +0000
committerbacker@chromium.org <backer@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-08-26 18:14:45 +0000
commita4f857f0cafb41c3d7c3fd50c6b39c99e629b48a (patch)
tree521a058f131d900136105ce2ce3c368991de5ad1 /views/ime
parent3a1381d637b14d103c581990451f92877107893e (diff)
downloadchromium_src-a4f857f0cafb41c3d7c3fd50c6b39c99e629b48a.zip
chromium_src-a4f857f0cafb41c3d7c3fd50c6b39c99e629b48a.tar.gz
chromium_src-a4f857f0cafb41c3d7c3fd50c6b39c99e629b48a.tar.bz2
Wayland support for views. views_desktop on Wayland.
This CL depends on: * http://codereview.chromium.org/7457023 * http://codereview.chromium.org/7467007 * http://codereview.chromium.org/7473010 Wayland requires newer libraries than Ubuntu currently provides. I've created a list of required dependencies: https://sites.google.com/a/google.com/chrome_on_wayland/home/wayland-build-dependencies BUG= TEST=Built Chrome to verify that Wayland dependencies and changes don't interfere with the usual build. Review URL: http://codereview.chromium.org/7464027 Patch from Daniel Nicoara <dnicoara@chromium.org>. git-svn-id: svn://svn.chromium.org/chrome/trunk/src@98453 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views/ime')
-rw-r--r--views/ime/input_method_wayland.cc76
-rw-r--r--views/ime/input_method_wayland.h36
2 files changed, 112 insertions, 0 deletions
diff --git a/views/ime/input_method_wayland.cc b/views/ime/input_method_wayland.cc
new file mode 100644
index 0000000..20d3ff2
--- /dev/null
+++ b/views/ime/input_method_wayland.cc
@@ -0,0 +1,76 @@
+// 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 "views/ime/input_method_wayland.h"
+
+#include "views/widget/widget.h"
+
+namespace views {
+
+InputMethodWayland::InputMethodWayland(
+ internal::InputMethodDelegate *delegate) {
+ set_delegate(delegate);
+}
+
+void InputMethodWayland::DispatchKeyEvent(const KeyEvent& key) {
+ if (!GetTextInputClient()) {
+ DispatchKeyEventPostIME(key);
+ return;
+ }
+
+ if (key.type() == ui::ET_KEY_PRESSED) {
+ ProcessKeyPressEvent(key);
+ } else if (key.type() == ui::ET_KEY_RELEASED) {
+ DispatchKeyEventPostIME(key);
+ }
+}
+
+void InputMethodWayland::OnTextInputTypeChanged(View* view) {
+ NOTIMPLEMENTED();
+}
+
+void InputMethodWayland::OnCaretBoundsChanged(View* view) {
+ NOTIMPLEMENTED();
+}
+
+void InputMethodWayland::CancelComposition(View* view) {
+ NOTIMPLEMENTED();
+}
+
+std::string InputMethodWayland::GetInputLocale() {
+ return std::string("");
+}
+
+base::i18n::TextDirection InputMethodWayland::GetInputTextDirection() {
+ return base::i18n::UNKNOWN_DIRECTION;
+}
+
+bool InputMethodWayland::IsActive() {
+ return true;
+}
+
+//////////////////////////////////////////////////////////////////////////////
+// InputMethodWayland private
+
+void InputMethodWayland::ProcessKeyPressEvent(const KeyEvent& key) {
+ const View* old_focused_view = focused_view();
+ DispatchKeyEventPostIME(key);
+
+ // We shouldn't dispatch the character anymore if the key event caused focus
+ // change.
+ if (old_focused_view != focused_view())
+ return;
+
+ // If a key event was not filtered by |context_| or |context_simple_|, then
+ // it means the key event didn't generate any result text. For some cases,
+ // the key event may still generate a valid character, eg. a control-key
+ // event (ctrl-a, return, tab, etc.). We need to send the character to the
+ // focused text input client by calling TextInputClient::InsertChar().
+ char16 ch = key.GetCharacter();
+ TextInputClient* client = GetTextInputClient();
+ if (ch && client)
+ client->InsertChar(ch, key.flags());
+}
+
+} // namespace views
diff --git a/views/ime/input_method_wayland.h b/views/ime/input_method_wayland.h
new file mode 100644
index 0000000..60dac30
--- /dev/null
+++ b/views/ime/input_method_wayland.h
@@ -0,0 +1,36 @@
+// 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.
+
+#ifndef VIEWS_IME_INPUT_METHOD_WAYLAND_H_
+#define VIEWS_IME_INPUT_METHOD_WAYLAND_H_
+#pragma once
+
+#include <string>
+
+#include "views/ime/input_method_base.h"
+
+namespace views {
+
+class InputMethodWayland : public InputMethodBase {
+ public:
+ explicit InputMethodWayland(internal::InputMethodDelegate *delegate);
+
+ virtual void DispatchKeyEvent(const KeyEvent& key) OVERRIDE;
+ virtual void OnTextInputTypeChanged(View* view) OVERRIDE;
+ virtual void OnCaretBoundsChanged(View* view) OVERRIDE;
+ virtual void CancelComposition(View* view) OVERRIDE;
+ virtual std::string GetInputLocale() OVERRIDE;
+ virtual base::i18n::TextDirection GetInputTextDirection() OVERRIDE;
+ virtual bool IsActive() OVERRIDE;
+
+ private:
+
+ void ProcessKeyPressEvent(const KeyEvent& key);
+
+ DISALLOW_COPY_AND_ASSIGN(InputMethodWayland);
+};
+
+} // namespace views
+
+#endif // VIEWS_IME_INPUT_METHOD_WAYLAND_H_