diff options
-rw-r--r-- | chrome/browser/autocomplete/autocomplete_edit_view_gtk.cc | 19 | ||||
-rw-r--r-- | chrome/browser/gtk/browser_window_gtk.cc | 36 |
2 files changed, 33 insertions, 22 deletions
diff --git a/chrome/browser/autocomplete/autocomplete_edit_view_gtk.cc b/chrome/browser/autocomplete/autocomplete_edit_view_gtk.cc index b1d0791..566c8d2 100644 --- a/chrome/browser/autocomplete/autocomplete_edit_view_gtk.cc +++ b/chrome/browser/autocomplete/autocomplete_edit_view_gtk.cc @@ -13,7 +13,6 @@ #include "chrome/browser/autocomplete/autocomplete_edit.h" #include "chrome/browser/autocomplete/autocomplete_popup_model.h" #include "chrome/browser/autocomplete/autocomplete_popup_view_gtk.h" -#include "chrome/browser/gtk/browser_window_gtk.h" #include "chrome/browser/gtk/location_bar_view_gtk.h" #include "chrome/browser/tab_contents/tab_contents.h" #include "chrome/browser/toolbar_model.h" @@ -353,24 +352,6 @@ void AutocompleteEditViewGtk::HandleEndUserAction() { gboolean AutocompleteEditViewGtk::HandleKeyPress(GtkWidget* widget, GdkEventKey* event) { - GdkModifierType modifier = GdkModifierType( - event->state & gtk_accelerator_get_default_mod_mask()); - - // We want to let the browser handle ctrl-pgup and ctrl-pgdn. - if ((event->keyval == GDK_Page_Up || event->keyval == GDK_Page_Down) && - modifier == GDK_CONTROL_MASK) { - GtkWidget* window = gtk_widget_get_toplevel(widget); - if (!window) { - NOTREACHED(); - } else { - BrowserWindowGtk* browser_window = static_cast<BrowserWindowGtk*>( - g_object_get_data(G_OBJECT(window), "browser_window_gtk")); - browser_window->HandleAccelerator(event->keyval, - static_cast<GdkModifierType>(event->state)); - return TRUE; - } - } - // This is very similar to the special casing of the return key in the // GtkTextView key_press default handler. TODO(deanm): We do however omit // some IME related code, this might become a problem if an IME wants to diff --git a/chrome/browser/gtk/browser_window_gtk.cc b/chrome/browser/gtk/browser_window_gtk.cc index b7a56e5..9f07858 100644 --- a/chrome/browser/gtk/browser_window_gtk.cc +++ b/chrome/browser/gtk/browser_window_gtk.cc @@ -197,6 +197,34 @@ gboolean HandleCustomAccelerator(guint keyval, GdkModifierType modifier, return FALSE; } +// Handle accelerators that we don't want the native widget to be able to +// override. +gboolean PreHandleAccelerator(guint keyval, GdkModifierType modifier, + Browser* browser) { + // Filter modifier to only include accelerator modifiers. + modifier = static_cast<GdkModifierType>( + modifier & gtk_accelerator_get_default_mod_mask()); + switch (keyval) { + case GDK_Page_Down: + if (GDK_CONTROL_MASK == modifier) { + browser->ExecuteCommand(IDC_SELECT_NEXT_TAB); + return TRUE; + } + break; + + case GDK_Page_Up: + if (GDK_CONTROL_MASK == modifier) { + browser->ExecuteCommand(IDC_SELECT_PREVIOUS_TAB); + return TRUE; + } + break; + + default: + break; + } + return FALSE; +} + // Let the focused widget have first crack at the key event so we don't // override their accelerators. gboolean OnKeyPress(GtkWindow* window, GdkEventKey* event, Browser* browser) { @@ -207,10 +235,12 @@ gboolean OnKeyPress(GtkWindow* window, GdkEventKey* event, Browser* browser) { // The current tab might not have a render view if it crashed. if (!current_tab_contents || !current_tab_contents->GetContentNativeView() || !gtk_widget_is_focus(current_tab_contents->GetContentNativeView())) { - gboolean handled = HandleCustomAccelerator(event->keyval, - GdkModifierType(event->state), browser); - if (handled) + if (HandleCustomAccelerator(event->keyval, + GdkModifierType(event->state), browser) || + PreHandleAccelerator(event->keyval, + GdkModifierType(event->state), browser)) { return TRUE; + } } if (!gtk_window_propagate_key_event(window, event)) { |