Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1322)

Unified Diff: chrome/browser/gtk/browser_window_gtk.cc

Issue 173344: Improves key event handing code of BrowserWindowGtk.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 11 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/gtk/browser_window_gtk.h ('k') | chrome/browser/tab_contents/tab_contents_view_gtk.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/gtk/browser_window_gtk.cc
===================================================================
--- chrome/browser/gtk/browser_window_gtk.cc (revision 24218)
+++ chrome/browser/gtk/browser_window_gtk.cc (working copy)
@@ -437,12 +437,20 @@
return TRUE;
}
- return gtk_window_propagate_key_event(window, event);
+ // Propagate the key event to child widget first, so we don't override their
+ // accelerators.
+ if (!gtk_window_propagate_key_event(window, event)) {
+ if (!gtk_window_activate_key(window, event)) {
+ gtk_bindings_activate_event(GTK_OBJECT(window), event);
+ }
+ }
} else {
bool rv = gtk_window_propagate_key_event(window, event);
DCHECK(rv);
- return TRUE;
}
+
+ // Prevents the default handler from handling this event.
+ return TRUE;
}
GdkCursorType GdkWindowEdgeToGdkCursorType(GdkWindowEdge edge) {
@@ -533,11 +541,21 @@
}
}
-void BrowserWindowGtk::HandleAccelerator(guint keyval,
- GdkModifierType modifier) {
- if (!HandleCustomAccelerator(keyval, modifier, browser_.get())) {
- // Pass the accelerator on to GTK.
- gtk_accel_groups_activate(G_OBJECT(window_), keyval, modifier);
+void BrowserWindowGtk::HandleAccelerator(GdkEventKey* event) {
+ // Handles a key event as an accelerator in following sequence:
+ // 1. Our special key accelerators, such as ctrl-tab, etc.
+ // 2. Gtk mnemonics and accelerators.
+ // 3. Gtk binding set.
+ // This sequence matches the default key press handler of GtkWindow.
+ //
+ // It's not necessary to care about the keyboard layout issue, as
+ // gtk_window_activate_key() and gtk_bindings_activate_event() take care of it
+ // automatically.
+ if (!HandleCustomAccelerator(event->keyval, GdkModifierType(event->state),
+ browser_.get())) {
+ if (!gtk_window_activate_key(window_, event)) {
+ gtk_bindings_activate_event(GTK_OBJECT(window_), event);
+ }
}
}
« no previous file with comments | « chrome/browser/gtk/browser_window_gtk.h ('k') | chrome/browser/tab_contents/tab_contents_view_gtk.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698