Commit fc197211 authored by kinaba@chromium.org's avatar kinaba@chromium.org

Use input method's context for tracking focus states in OnGrabNotify.

Current implementation of RenderWidgetViewHostGtk::OnGrabNotify()
records the focus state obtained by gtk_widget_is_focus() when
other window get a grab, and set the stored state to the
input context on ungrab notification.

This CL changes to store the focus state of input context rather
than gtk_widget_is_focus(), and resolves the inconsistency issue.

BUG=chromium-os:15773
TEST=http://crosbug.com/15773#c20

Review URL: http://codereview.chromium.org/7548008

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@95573 0039d316-1c4b-4281-b951-d872f2087c98
parent cbd4ff78
...@@ -53,6 +53,7 @@ class GtkIMContextWrapper { ...@@ -53,6 +53,7 @@ class GtkIMContextWrapper {
const gfx::Rect& caret_rect); const gfx::Rect& caret_rect);
void OnFocusIn(); void OnFocusIn();
void OnFocusOut(); void OnFocusOut();
bool is_focused() const { return is_focused_; }
#if !defined(TOOLKIT_VIEWS) #if !defined(TOOLKIT_VIEWS)
// Not defined for views because the views context menu doesn't // Not defined for views because the views context menu doesn't
......
...@@ -216,7 +216,7 @@ class RenderWidgetHostViewGtkWidget { ...@@ -216,7 +216,7 @@ class RenderWidgetHostViewGtkWidget {
host_view->GetRenderWidgetHost()->Blur(); host_view->GetRenderWidgetHost()->Blur();
// Prevents us from stealing input context focus in OnGrabNotify() handler. // Prevents us from stealing input context focus in OnGrabNotify() handler.
host_view->was_focused_before_grab_ = false; host_view->was_imcontext_focused_before_grab_ = false;
// Disable the GtkIMContext object. // Disable the GtkIMContext object.
host_view->im_context_->OnFocusOut(); host_view->im_context_->OnFocusOut();
...@@ -231,11 +231,12 @@ class RenderWidgetHostViewGtkWidget { ...@@ -231,11 +231,12 @@ class RenderWidgetHostViewGtkWidget {
static void OnGrabNotify(GtkWidget* widget, gboolean was_grabbed, static void OnGrabNotify(GtkWidget* widget, gboolean was_grabbed,
RenderWidgetHostViewGtk* host_view) { RenderWidgetHostViewGtk* host_view) {
if (was_grabbed) { if (was_grabbed) {
if (host_view->was_focused_before_grab_) if (host_view->was_imcontext_focused_before_grab_)
host_view->im_context_->OnFocusIn(); host_view->im_context_->OnFocusIn();
} else { } else {
host_view->was_focused_before_grab_ = host_view->HasFocus(); host_view->was_imcontext_focused_before_grab_ =
if (host_view->was_focused_before_grab_) { host_view->im_context_->is_focused();
if (host_view->was_imcontext_focused_before_grab_) {
gdk_window_set_cursor(widget->window, NULL); gdk_window_set_cursor(widget->window, NULL);
host_view->im_context_->OnFocusOut(); host_view->im_context_->OnFocusOut();
} }
...@@ -509,7 +510,7 @@ RenderWidgetHostViewGtk::RenderWidgetHostViewGtk(RenderWidgetHost* widget_host) ...@@ -509,7 +510,7 @@ RenderWidgetHostViewGtk::RenderWidgetHostViewGtk(RenderWidgetHost* widget_host)
overlay_animation_(this), overlay_animation_(this),
parent_(NULL), parent_(NULL),
is_popup_first_mouse_release_(true), is_popup_first_mouse_release_(true),
was_focused_before_grab_(false), was_imcontext_focused_before_grab_(false),
do_x_grab_(false), do_x_grab_(false),
is_fullscreen_(false), is_fullscreen_(false),
destroy_handler_id_(0), destroy_handler_id_(0),
......
...@@ -211,9 +211,10 @@ class RenderWidgetHostViewGtk : public RenderWidgetHostView, ...@@ -211,9 +211,10 @@ class RenderWidgetHostViewGtk : public RenderWidgetHostView,
// We ignore the first mouse release on popups so the popup will remain open. // We ignore the first mouse release on popups so the popup will remain open.
bool is_popup_first_mouse_release_; bool is_popup_first_mouse_release_;
// Whether or not this widget was focused before shadowed by another widget. // Whether or not this widget's input context was focused before being
// Used in OnGrabNotify() handler to track the focused state correctly. // shadowed by another widget. Used in OnGrabNotify() handler to track the
bool was_focused_before_grab_; // focused state correctly.
bool was_imcontext_focused_before_grab_;
// True if we are responsible for creating an X grab. This will only be used // True if we are responsible for creating an X grab. This will only be used
// for <select> dropdowns. It should be true for most such cases, but false // for <select> dropdowns. It should be true for most such cases, but false
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment