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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/gtk/browser_window_gtk.h" 5 #include "chrome/browser/gtk/browser_window_gtk.h"
6 6
7 #include <gdk/gdkkeysyms.h> 7 #include <gdk/gdkkeysyms.h>
8 #include <X11/XF86keysym.h> 8 #include <X11/XF86keysym.h>
9 9
10 #include <string> 10 #include <string>
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after
430 // The current tab might not have a render view if it crashed. 430 // The current tab might not have a render view if it crashed.
431 if (!current_tab_contents || !current_tab_contents->GetContentNativeView() || 431 if (!current_tab_contents || !current_tab_contents->GetContentNativeView() ||
432 !gtk_widget_is_focus(current_tab_contents->GetContentNativeView())) { 432 !gtk_widget_is_focus(current_tab_contents->GetContentNativeView())) {
433 if (HandleCustomAccelerator(event->keyval, 433 if (HandleCustomAccelerator(event->keyval,
434 GdkModifierType(event->state), browser) || 434 GdkModifierType(event->state), browser) ||
435 PreHandleAccelerator(event->keyval, 435 PreHandleAccelerator(event->keyval,
436 GdkModifierType(event->state), browser)) { 436 GdkModifierType(event->state), browser)) {
437 return TRUE; 437 return TRUE;
438 } 438 }
439 439
440 return gtk_window_propagate_key_event(window, event); 440 // Propagate the key event to child widget first, so we don't override their
441 // accelerators.
442 if (!gtk_window_propagate_key_event(window, event)) {
443 if (!gtk_window_activate_key(window, event)) {
444 gtk_bindings_activate_event(GTK_OBJECT(window), event);
445 }
446 }
441 } else { 447 } else {
442 bool rv = gtk_window_propagate_key_event(window, event); 448 bool rv = gtk_window_propagate_key_event(window, event);
443 DCHECK(rv); 449 DCHECK(rv);
444 return TRUE;
445 } 450 }
451
452 // Prevents the default handler from handling this event.
453 return TRUE;
446 } 454 }
447 455
448 GdkCursorType GdkWindowEdgeToGdkCursorType(GdkWindowEdge edge) { 456 GdkCursorType GdkWindowEdgeToGdkCursorType(GdkWindowEdge edge) {
449 switch (edge) { 457 switch (edge) {
450 case GDK_WINDOW_EDGE_NORTH_WEST: 458 case GDK_WINDOW_EDGE_NORTH_WEST:
451 return GDK_TOP_LEFT_CORNER; 459 return GDK_TOP_LEFT_CORNER;
452 case GDK_WINDOW_EDGE_NORTH: 460 case GDK_WINDOW_EDGE_NORTH:
453 return GDK_TOP_SIDE; 461 return GDK_TOP_SIDE;
454 case GDK_WINDOW_EDGE_NORTH_EAST: 462 case GDK_WINDOW_EDGE_NORTH_EAST:
455 return GDK_TOP_RIGHT_CORNER; 463 return GDK_TOP_RIGHT_CORNER;
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
526 534
527 BrowserWindowGtk::~BrowserWindowGtk() { 535 BrowserWindowGtk::~BrowserWindowGtk() {
528 browser_->tabstrip_model()->RemoveObserver(this); 536 browser_->tabstrip_model()->RemoveObserver(this);
529 537
530 if (frame_cursor_) { 538 if (frame_cursor_) {
531 gdk_cursor_unref(frame_cursor_); 539 gdk_cursor_unref(frame_cursor_);
532 frame_cursor_ = NULL; 540 frame_cursor_ = NULL;
533 } 541 }
534 } 542 }
535 543
536 void BrowserWindowGtk::HandleAccelerator(guint keyval, 544 void BrowserWindowGtk::HandleAccelerator(GdkEventKey* event) {
537 GdkModifierType modifier) { 545 // Handles a key event as an accelerator in following sequence:
538 if (!HandleCustomAccelerator(keyval, modifier, browser_.get())) { 546 // 1. Our special key accelerators, such as ctrl-tab, etc.
539 // Pass the accelerator on to GTK. 547 // 2. Gtk mnemonics and accelerators.
540 gtk_accel_groups_activate(G_OBJECT(window_), keyval, modifier); 548 // 3. Gtk binding set.
549 // This sequence matches the default key press handler of GtkWindow.
550 //
551 // It's not necessary to care about the keyboard layout issue, as
552 // gtk_window_activate_key() and gtk_bindings_activate_event() take care of it
553 // automatically.
554 if (!HandleCustomAccelerator(event->keyval, GdkModifierType(event->state),
555 browser_.get())) {
556 if (!gtk_window_activate_key(window_, event)) {
557 gtk_bindings_activate_event(GTK_OBJECT(window_), event);
558 }
541 } 559 }
542 } 560 }
543 561
544 gboolean BrowserWindowGtk::OnCustomFrameExpose(GtkWidget* widget, 562 gboolean BrowserWindowGtk::OnCustomFrameExpose(GtkWidget* widget,
545 GdkEventExpose* event, 563 GdkEventExpose* event,
546 BrowserWindowGtk* window) { 564 BrowserWindowGtk* window) {
547 ThemeProvider* theme_provider = 565 ThemeProvider* theme_provider =
548 window->browser()->profile()->GetThemeProvider(); 566 window->browser()->profile()->GetThemeProvider();
549 567
550 // Draw the default background. 568 // Draw the default background.
(...skipping 1492 matching lines...) Expand 10 before | Expand all | Expand 10 after
2043 // special-case the ones where the custom frame should be used. These names 2061 // special-case the ones where the custom frame should be used. These names
2044 // are taken from the WMs' source code. 2062 // are taken from the WMs' source code.
2045 return (wm_name == "Blackbox" || 2063 return (wm_name == "Blackbox" ||
2046 wm_name == "compiz" || 2064 wm_name == "compiz" ||
2047 wm_name == "e16" || // Enlightenment DR16 2065 wm_name == "e16" || // Enlightenment DR16
2048 wm_name == "KWin" || 2066 wm_name == "KWin" ||
2049 wm_name == "Metacity" || 2067 wm_name == "Metacity" ||
2050 wm_name == "Openbox" || 2068 wm_name == "Openbox" ||
2051 wm_name == "Xfwm4"); 2069 wm_name == "Xfwm4");
2052 } 2070 }
OLDNEW
« 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