diff options
author | hbono@chromium.org <hbono@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-01 04:41:53 +0000 |
---|---|---|
committer | hbono@chromium.org <hbono@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-01 04:41:53 +0000 |
commit | feab536198e21e8f4777c3c8035a6ca6479f6912 (patch) | |
tree | 75d5f0578e2b101c3fb50568842711b87197e9c0 /chrome/browser | |
parent | be61bb5c487f1020756c31a39fbe23535e4d425b (diff) | |
download | chromium_src-feab536198e21e8f4777c3c8035a6ca6479f6912.zip chromium_src-feab536198e21e8f4777c3c8035a6ca6479f6912.tar.gz chromium_src-feab536198e21e8f4777c3c8035a6ca6479f6912.tar.bz2 |
A quick fix for Issue 15531 and 10953
This issue is caused by my another mistake that I forgot setting the modifier-key state in creating a Char event in RenderWidgetHostViewGtkWidget::ForwardCharEvent().
Since the GtkIMContext signal-handlers don't use GdkEventKey objects and cannot get the modififer-key state, this change save the state in RenderWidgetHostViewGtkWidget::KeyPressReleaseEvent() before dispatching a key event to the GtkIMContext object.
Also, this change adds gtk_im_context_focus_in() and gtk_im_context_focus_out() calls to fix compatibility problems with ibus.
BUG=10953 "IME support"
BUG=15531 "regression: shift-space doesn't scroll the page backwards"
TEST=Open a test page in <http://crbug.com/15531>, press shift+space keys, and observe ev.shiftKey is true.
Review URL: http://codereview.chromium.org/151010
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@19707 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r-- | chrome/browser/renderer_host/render_widget_host_view_gtk.cc | 33 | ||||
-rw-r--r-- | chrome/browser/renderer_host/render_widget_host_view_gtk.h | 5 |
2 files changed, 30 insertions, 8 deletions
diff --git a/chrome/browser/renderer_host/render_widget_host_view_gtk.cc b/chrome/browser/renderer_host/render_widget_host_view_gtk.cc index 12185cf..1da195f 100644 --- a/chrome/browser/renderer_host/render_widget_host_view_gtk.cc +++ b/chrome/browser/renderer_host/render_widget_host_view_gtk.cc @@ -121,6 +121,11 @@ class RenderWidgetHostViewGtkWidget { host_view->GetRenderWidgetHost()->ForwardKeyboardEvent(wke); } + // Save the current modifier-key state before dispatching this event to the + // GtkIMContext object so its event handlers can use this state to create + // Char events. + host_view->im_modifier_state_ = event->state; + // Dispatch this event to the GtkIMContext object. // It sends a "commit" signal when it has a character to be inserted // even when we use a US keyboard so that we can send a Char event @@ -182,6 +187,15 @@ class RenderWidgetHostViewGtkWidget { host_view->ShowCurrentCursor(); host_view->GetRenderWidgetHost()->Focus(); + + // Notify the GtkIMContext object of this focus-in event and + // attach this GtkIMContext object to this window. + // We should call gtk_im_context_set_client_window() only when this window + // gain (or release) the window focus because an immodule may reset its + // internal status when processing this function. + gtk_im_context_focus_in(host_view->im_context_); + gtk_im_context_set_client_window(host_view->im_context_, + host_view->native_view()->window); return FALSE; } @@ -194,6 +208,11 @@ class RenderWidgetHostViewGtkWidget { // focus. if (!host_view->is_showing_context_menu_) host_view->GetRenderWidgetHost()->Blur(); + + // Notify the GtkIMContext object of this focus-in event and + // detach this GtkIMContext object from this window. + gtk_im_context_focus_out(host_view->im_context_); + gtk_im_context_set_client_window(host_view->im_context_, NULL); return FALSE; } @@ -319,6 +338,7 @@ class RenderWidgetHostViewGtkWidget { return; NativeWebKeyboardEvent char_event(im_character, + host_view->im_modifier_state_, base::Time::Now().ToDoubleT()); host_view->GetRenderWidgetHost()->ForwardKeyboardEvent(char_event); } @@ -342,7 +362,8 @@ RenderWidgetHostViewGtk::RenderWidgetHostViewGtk(RenderWidgetHost* widget_host) parent_(NULL), is_popup_first_mouse_release_(true), im_context_(NULL), - im_is_composing_cjk_text_(false) { + im_is_composing_cjk_text_(false), + im_modifier_state_(0) { host_->set_view(this); } @@ -514,19 +535,15 @@ void RenderWidgetHostViewGtk::IMEUpdateStatus(int control, return; if (control == IME_DISABLE) { - // TODO(hbono): this code just resets the GtkIMContext object and - // detaches it from this window. Should we prevent sending key events to - // the GtkIMContext object (or unref it) when we disable IMEs? + // TODO(hbono): this code just resets the GtkIMContext object. + // Should we prevent sending key events to the GtkIMContext object + // (or unref it) when we disable IMEs? gtk_im_context_reset(im_context_); - gtk_im_context_set_client_window(im_context_, NULL); gtk_im_context_set_cursor_location(im_context_, NULL); } else { // TODO(hbono): we should finish (not reset) an ongoing composition // when |control| is IME_COMPLETE_COMPOSITION. - // Attach the GtkIMContext object to this window. - gtk_im_context_set_client_window(im_context_, view_.get()->window); - // Updates the position of the IME candidate window. // The position sent from the renderer is a relative one, so we need to // attach the GtkIMContext object to this window before changing the 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 e727e08..3df3006 100644 --- a/chrome/browser/renderer_host/render_widget_host_view_gtk.h +++ b/chrome/browser/renderer_host/render_widget_host_view_gtk.h @@ -132,6 +132,11 @@ class RenderWidgetHostViewGtk : public RenderWidgetHostView { // 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_; }; #endif // CHROME_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_GTK_H_ |