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 {
const gfx::Rect& caret_rect);
void OnFocusIn();
void OnFocusOut();
bool is_focused() const { return is_focused_; }
#if !defined(TOOLKIT_VIEWS)
// Not defined for views because the views context menu doesn't
......
......@@ -216,7 +216,7 @@ class RenderWidgetHostViewGtkWidget {
host_view->GetRenderWidgetHost()->Blur();
// 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.
host_view->im_context_->OnFocusOut();
......@@ -231,11 +231,12 @@ class RenderWidgetHostViewGtkWidget {
static void OnGrabNotify(GtkWidget* widget, gboolean was_grabbed,
RenderWidgetHostViewGtk* host_view) {
if (was_grabbed) {
if (host_view->was_focused_before_grab_)
if (host_view->was_imcontext_focused_before_grab_)
host_view->im_context_->OnFocusIn();
} else {
host_view->was_focused_before_grab_ = host_view->HasFocus();
if (host_view->was_focused_before_grab_) {
host_view->was_imcontext_focused_before_grab_ =
host_view->im_context_->is_focused();
if (host_view->was_imcontext_focused_before_grab_) {
gdk_window_set_cursor(widget->window, NULL);
host_view->im_context_->OnFocusOut();
}
......@@ -509,7 +510,7 @@ RenderWidgetHostViewGtk::RenderWidgetHostViewGtk(RenderWidgetHost* widget_host)
overlay_animation_(this),
parent_(NULL),
is_popup_first_mouse_release_(true),
was_focused_before_grab_(false),
was_imcontext_focused_before_grab_(false),
do_x_grab_(false),
is_fullscreen_(false),
destroy_handler_id_(0),
......
......@@ -211,9 +211,10 @@ class RenderWidgetHostViewGtk : public RenderWidgetHostView,
// We ignore the first mouse release on popups so the popup will remain open.
bool is_popup_first_mouse_release_;
// 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_;
// Whether or not this widget's input context was focused before being
// shadowed by another widget. Used in OnGrabNotify() handler to track the
// focused state correctly.
bool was_imcontext_focused_before_grab_;
// 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
......
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