diff options
author | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-13 23:44:14 +0000 |
---|---|---|
committer | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-13 23:44:14 +0000 |
commit | a7ac8bc84a93404c74d6442023e22bb56d4fc6c0 (patch) | |
tree | 18cb76daecfa8242f93a657bb52c43b3529d5a0f /chrome/browser/renderer_host/render_widget_host_view_gtk.cc | |
parent | 0a21fdef759a46d5aed2017013abf2113a919b23 (diff) | |
download | chromium_src-a7ac8bc84a93404c74d6442023e22bb56d4fc6c0.zip chromium_src-a7ac8bc84a93404c74d6442023e22bb56d4fc6c0.tar.gz chromium_src-a7ac8bc84a93404c74d6442023e22bb56d4fc6c0.tar.bz2 |
GTK: For the render view, count keyboard grab shadows the same as focus events.
This fixes an age old bug that dropdown menus still looked depressed after you select something from them and they collapse. It also fixes the more recent bug that you could have focus in the render view without any indication drawn by the renderer. I suspect there was a change to webkit that exacerbated this bug, because it seems like something we would have noticed earlier.
Verified in a debugger that showing/hiding a dropdown menu doesn't emit focus signals, but does emit grab notify signals. Also verified that the bug is no longer reproducible in a simple page with <select> and <input> elements.
BUG=16313
TEST=see desc.
Review URL: http://codereview.chromium.org/149506
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@20574 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/renderer_host/render_widget_host_view_gtk.cc')
-rw-r--r-- | chrome/browser/renderer_host/render_widget_host_view_gtk.cc | 18 |
1 files changed, 18 insertions, 0 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 e8ce708..2693be6 100644 --- a/chrome/browser/renderer_host/render_widget_host_view_gtk.cc +++ b/chrome/browser/renderer_host/render_widget_host_view_gtk.cc @@ -63,6 +63,8 @@ class RenderWidgetHostViewGtkWidget { G_CALLBACK(OnFocusIn), host_view); g_signal_connect(widget, "focus-out-event", G_CALLBACK(OnFocusOut), host_view); + g_signal_connect(widget, "grab-notify", + G_CALLBACK(OnGrabNotify), host_view); g_signal_connect(widget, "button-press-event", G_CALLBACK(ButtonPressReleaseEvent), host_view); g_signal_connect(widget, "button-release-event", @@ -154,6 +156,8 @@ class RenderWidgetHostViewGtkWidget { return TRUE; } + // WARNING: OnGrabNotify relies on the fact this function doesn't try to + // dereference |focus|. static gboolean OnFocusIn(GtkWidget* widget, GdkEventFocus* focus, RenderWidgetHostViewGtk* host_view) { int x, y; @@ -191,6 +195,8 @@ class RenderWidgetHostViewGtkWidget { return FALSE; } + // WARNING: OnGrabNotify relies on the fact this function doesn't try to + // dereference |focus|. static gboolean OnFocusOut(GtkWidget* widget, GdkEventFocus* focus, RenderWidgetHostViewGtk* host_view) { // Whenever we lose focus, set the cursor back to that of our parent window, @@ -208,6 +214,18 @@ class RenderWidgetHostViewGtkWidget { return FALSE; } + // Called when we are shadowed or unshadowed by a keyboard grab (which will + // occur for activatable popups, such as dropdown menus). Popup windows do not + // take focus, so we never get a focus out or focus in event when they are + // shown, and must rely on this signal instead. + static void OnGrabNotify(GtkWidget* widget, gboolean was_grabbed, + RenderWidgetHostViewGtk* host_view) { + if (was_grabbed) + OnFocusIn(widget, NULL, host_view); + else + OnFocusOut(widget, NULL, host_view); + } + static gboolean ButtonPressReleaseEvent( GtkWidget* widget, GdkEventButton* event, RenderWidgetHostViewGtk* host_view) { |