summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
authorestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-20 20:35:40 +0000
committerestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-20 20:35:40 +0000
commit3be0198c07fd435236c9482fc6c5bc3c00ac8ba6 (patch)
tree90be3604be4ff06b68040bdbb01860f78cd43bcb /chrome/browser
parent656faeae6b2bacdab63b5d795e7901e05082845b (diff)
downloadchromium_src-3be0198c07fd435236c9482fc6c5bc3c00ac8ba6.zip
chromium_src-3be0198c07fd435236c9482fc6c5bc3c00ac8ba6.tar.gz
chromium_src-3be0198c07fd435236c9482fc6c5bc3c00ac8ba6.tar.bz2
Linux: Restore normal event handling for key events that are not to be sent to webkit.
We want to pass all key events to webkit. But other widgets shouldn't get key events till after they've been checked against our accelerators. This fixes the problem that pressing ctrl-page{up,down} in the location bar moves the cursor rather than changing tabs. Review URL: http://codereview.chromium.org/50069 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@12209 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/gtk/browser_window_gtk.cc27
1 files changed, 18 insertions, 9 deletions
diff --git a/chrome/browser/gtk/browser_window_gtk.cc b/chrome/browser/gtk/browser_window_gtk.cc
index 6ce674b..10154d7 100644
--- a/chrome/browser/gtk/browser_window_gtk.cc
+++ b/chrome/browser/gtk/browser_window_gtk.cc
@@ -90,6 +90,7 @@ const struct AcceleratorMapping {
{ GDK_l, IDC_FOCUS_LOCATION },
{ GDK_o, IDC_OPEN_FILE },
{ GDK_w, IDC_CLOSE_TAB },
+ { GDK_Page_Down, IDC_FOCUS_SEARCH },
};
int GetCommandFromKeyval(guint accel_key) {
@@ -101,14 +102,22 @@ int GetCommandFromKeyval(guint accel_key) {
return 0;
}
-// Usually accelerators are checked before propagating the key event, but in our
-// case we want to reverse the order of things to allow webkit to handle key
-// events like ctrl-l. If the window's children can handle the key event, this
-// will return TRUE and the signal won't be propagated further. If the window's
-// children cannot handle the key event then this will return FALSE and the
-// default GtkWindow key press handler will be invoked.
-gboolean OnKeyPress(GtkWindow* window, GdkEventKey* event, gpointer userdata) {
- return gtk_window_propagate_key_event(window, event);
+// Usually accelerators are checked before propagating the key event, but if the
+// focus is on the render area we want to reverse the order of things to allow
+// webkit to handle key events like ctrl-l.
+gboolean OnKeyPress(GtkWindow* window, GdkEventKey* event, Browser* browser) {
+ TabContents* current_tab_contents =
+ browser->tabstrip_model()->GetSelectedTabContents();
+ // If there is no current tab contents or it is not focused then let the
+ // default GtkWindow key handler run.
+ if (!current_tab_contents)
+ return FALSE;
+ if (!gtk_widget_is_focus(current_tab_contents->GetContentNativeView()))
+ return FALSE;
+
+ // If the content area is focused, let it handle the key event.
+ DCHECK(gtk_window_propagate_key_event(window, event));
+ return TRUE;
}
} // namespace
@@ -129,7 +138,7 @@ BrowserWindowGtk::BrowserWindowGtk(Browser* browser)
g_signal_connect(window_, "window-state-event",
G_CALLBACK(MainWindowStateChanged), this);
g_signal_connect(window_, "key-press-event",
- G_CALLBACK(OnKeyPress), NULL);
+ G_CALLBACK(OnKeyPress), browser_.get());
ConnectAccelerators();
bounds_ = GetInitialWindowBounds(window_);