summaryrefslogtreecommitdiffstats
path: root/chrome/browser/renderer_host/render_widget_host_view_gtk.h
diff options
context:
space:
mode:
authorestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-21 19:51:24 +0000
committerestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-21 19:51:24 +0000
commitc159467e0fe94e676213d98c3428c6b611b7d4f4 (patch)
tree5e8bd985a052c4d2119ff96219c855883cb2e294 /chrome/browser/renderer_host/render_widget_host_view_gtk.h
parent99050a88a4fe4f4acaa7b98e94cea7f0a84b4f18 (diff)
downloadchromium_src-c159467e0fe94e676213d98c3428c6b611b7d4f4.zip
chromium_src-c159467e0fe94e676213d98c3428c6b611b7d4f4.tar.gz
chromium_src-c159467e0fe94e676213d98c3428c6b611b7d4f4.tar.bz2
This change list improves IME support on Linux. Many corner cases that were not
handled in original code are addressed, for example the input method in password box case. The most important change in this CL is the change to key event processing flow. In old code, a key event will first be sent to webkit then dispatched to IME for filtering. With this CL, a key event will first be dispatched to IME for filtering, then how to send the event to webkit is decided by the filtering result. This CL tries to emulate the keyboard input behavior on Windows as much as possible. For example, if a keydown event is filtered by IME, then its virtual key code will be changed to VK_PROCESSKEY(0xE5) to prevent webkit from processing it again. This behavior can workaround bug 16281. To test this CL, you may cut and save following html code into a file and open it in chrome. ------------------8<----cut here----->8--------------------- <html><head> <meta http-equiv="content-type" content="text/html; charset=utf-8"> <script> function keyEventHandler(event) { var props = [ "type", "charCode", "keyCode", "altKey", "ctrlKey", "shiftKey", "metaKey" ]; var info = document.getElementById('info'); var s = ''; for (var i in props) { s += props[i] + ':' + event[props[i]] + ' '; } info.value += s + '\n'; } function textEventHandler(event) { info.value += "type:" + event['type'] + " data:" + event['data'] + '\n'; } function passwordChangeEventHandler(event) { var input2 = document.getElementById('input2'); info.value += "password:" + input2.value + '\n'; } function onLoad() { var input = document.getElementById('input'); input.addEventListener('keydown', keyEventHandler, false); input.addEventListener('keyup', keyEventHandler, false); input.addEventListener('keypress', keyEventHandler, false); input.addEventListener('textInput', textEventHandler, false); var input2 = document.getElementById('input2'); input2.addEventListener('change', passwordChangeEventHandler, false); } </script> </head><body onload="onLoad()"> <input id="input" size="20"> <input id="input2" type="password" size="20"> <p> <textarea id="info" rows="40" cols="150"></textarea> </p></body></html> ------------------8<----cut here----->8--------------------- This CL was confirmed to fix following issues: BUG=16281 "arrow keys and backspace/delete keys move/delete two characters at a time when xim immodule is used" BUG=16282 "Disable IMEs in a password input" BUG=16596 "fcitx (chinese input method) not working in ubuntu 9.04" BUG=16659 "Crash near RenderWidgetHostViewGtk::IMEUpdateStatus" BUG=16699 "Can't move cursor to omnibox and use input method if cursor is currently in a text input box in web page." BUG=16796 "Input method issue: When inputting text in a text box, if there is a composition string then pressing Backspace or Delete will cause the composition string be cleared and the text box refuses to accept any further input. All tests assume above html code is used. TEST=Start scim with "scim -d" and start chrome with GTK_IM_MODULE=xim and XMODIFIERS=@im=SCIM. Type something in input box, eg. "hello", then press backspace, to see if only one character is deleted. TEST=Move cursor to password input box, press ctrl-space to see if input method is not activated. Switch keyboard layout to Canadian-French then type a'[{' key and an 'a' key, then press enter, to see if a Latin character "U+00E2" is inputted in password box. TEST=Install fcitx with "sudo apt-get install fcitx" (assume you are using Ubuntu/Debian). Open a terminal, export XMODIFIERS=@im=fcitx and GTK_IM_MODULE=xim then run fcitx, then start chrome. Move cursor into an input box, press ctrl-space and input something, eg. "nihao" then press space. Check if some Chinese characters are inputted. TEST=Start chrome with GTK_IM_MODULE=scim. Move cursor into a text input box then move into a password box, chrome should not crash. TEST=Move cursor into a text input box, then click omnibox, and see if the text input box has lost focus. Press ctrl-space to activate input method, then type something, and see of the input goes into omnibox. TEST=Move cursor into a text input box and enable a Chinese Pinyin input method, then type something, eg. "dajiahao", make sure a composition string is displayed in the text input box, then press backspace and see if there is still a composition string and backspace is handled by input method. patch by James Su <james.su [at] gmail> original review URL: <http://codereview.chromium.org/149755> Review URL: http://codereview.chromium.org/155869 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@21203 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/renderer_host/render_widget_host_view_gtk.h')
-rw-r--r--chrome/browser/renderer_host/render_widget_host_view_gtk.h35
1 files changed, 9 insertions, 26 deletions
diff --git a/chrome/browser/renderer_host/render_widget_host_view_gtk.h b/chrome/browser/renderer_host/render_widget_host_view_gtk.h
index d4a40ef..eccea4a 100644
--- a/chrome/browser/renderer_host/render_widget_host_view_gtk.h
+++ b/chrome/browser/renderer_host/render_widget_host_view_gtk.h
@@ -9,6 +9,7 @@
#include <vector>
#include "base/gfx/native_widget_types.h"
+#include "base/scoped_ptr.h"
#include "chrome/browser/renderer_host/render_widget_host_view.h"
#include "chrome/common/owned_widget_gtk.h"
#include "chrome/common/render_messages.h"
@@ -16,6 +17,8 @@
#include "webkit/glue/webcursor.h"
class RenderWidgetHost;
+// A conveience wrapper class for GtkIMContext;
+class RenderWidgetHostViewGtkIMContext;
typedef struct _GtkClipboard GtkClipboard;
typedef struct _GtkSelectionData GtkSelectionData;
@@ -116,32 +119,12 @@ class RenderWidgetHostViewGtk : public RenderWidgetHostView {
// stay open.
bool is_popup_first_mouse_release_;
- // The GtkIMContext object.
- // In terms of the DOM event specification Appendix A
- // <http://www.w3.org/TR/DOM-Level-3-Events/keyset.html>,
- // GTK uses a GtkIMContext object for the following two purposes:
- // 1. Composing Latin characters (A.1.2), and;
- // 2. Composing CJK characters with an IME (A.1.3).
- // Many JavaScript pages assume composed Latin characters are dispatched to
- // their onkeypress() handlers but not dispatched CJK characters composed
- // with an IME. To emulate this behavior, we should monitor the status of
- // this GtkIMContext object and prevent sending Char events when a
- // GtkIMContext object sends a "commit" signal with the CJK characters
- // composed by an IME.
- GtkIMContext* im_context_;
-
- // Whether or not the above GtkIMContext is composing a CJK text with an IME.
- // The GtkIMContext object sends a "preedit_start" before it starts composing
- // a CJK text and a "preedit_end" signal after it finishes composing it.
- // On the other hand, the GtkIMContext object doesn't send them when
- // composing Latin texts. So, we monitor the above signals to check whether
- // or not the GtkIMContext object is composing a CJK text.
- bool im_is_composing_cjk_text_;
-
- // Represents the current modifier-key state.
- // This state is used when GtkIMContext signal handlers create Char events
- // because they don't use the GdkEventKey objects and cannot get the state.
- int im_modifier_state_;
+ // Whether or not this widget was focused before shadowed by another widget.
+ // Used in OnGrabNotify() handler to track the focused state correctly.
+ bool was_focused_before_grab_;
+
+ // A conveience wrapper object for GtkIMContext;
+ scoped_ptr<RenderWidgetHostViewGtkIMContext> im_context_;
// Helper class that lets us allocate plugin containers and move them.
GtkPluginContainerManager plugin_container_manager_;