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

Side by Side Diff: views/widget/gtk_views_window.cc

Issue 3046041: [Linux Views] Refactor accelerator handler related code. (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: Prevent ctrl+alt. Created 10 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
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 <gtk/gtk.h>
6 #include "views/event.h"
5 #include "views/widget/gtk_views_window.h" 7 #include "views/widget/gtk_views_window.h"
6 #include "views/focus/focus_manager.h" 8 #include "views/focus/focus_manager.h"
7 9
8 G_BEGIN_DECLS 10 G_BEGIN_DECLS
9 11
10 G_DEFINE_TYPE(GtkViewsWindow, gtk_views_window, GTK_TYPE_WINDOW) 12 G_DEFINE_TYPE(GtkViewsWindow, gtk_views_window, GTK_TYPE_WINDOW)
11 13
12 static void gtk_views_window_move_focus(GtkWindow *window, 14 static void gtk_views_window_move_focus(GtkWindow* window,
13 GtkDirectionType dir) { 15 GtkDirectionType dir) {
14 views::FocusManager* focus_manager = 16 views::FocusManager* focus_manager =
15 views::FocusManager::GetFocusManagerForNativeWindow(window); 17 views::FocusManager::GetFocusManagerForNativeWindow(window);
16 if (focus_manager) { 18 if (focus_manager) {
17 // We only support tab traversing by tab keys, so just ignore all other 19 GdkEvent* key = gtk_get_current_event();
18 // cases silently. 20 if (key && key->type == GDK_KEY_PRESS) {
19 if (dir == GTK_DIR_TAB_BACKWARD || dir == GTK_DIR_TAB_FORWARD) 21 views::KeyEvent key_event(reinterpret_cast<GdkEventKey*>(key));
20 focus_manager->AdvanceFocus(dir == GTK_DIR_TAB_BACKWARD); 22 focus_manager->OnKeyEvent(key_event);
23 }
21 } else if (GTK_WINDOW_CLASS(gtk_views_window_parent_class)->move_focus) { 24 } else if (GTK_WINDOW_CLASS(gtk_views_window_parent_class)->move_focus) {
22 GTK_WINDOW_CLASS(gtk_views_window_parent_class)->move_focus(window, dir); 25 GTK_WINDOW_CLASS(gtk_views_window_parent_class)->move_focus(window, dir);
23 } 26 }
24 } 27 }
25 28
26 static void gtk_views_window_class_init( 29 static void gtk_views_window_class_init(
27 GtkViewsWindowClass* views_window_class) { 30 GtkViewsWindowClass* views_window_class) {
28 GtkWindowClass* window_class = 31 GtkWindowClass* window_class =
29 reinterpret_cast<GtkWindowClass*>(views_window_class); 32 reinterpret_cast<GtkWindowClass*>(views_window_class);
30 window_class->move_focus = gtk_views_window_move_focus; 33 window_class->move_focus = gtk_views_window_move_focus;
31 } 34 }
32 35
33 static void gtk_views_window_init(GtkViewsWindow* window) { 36 static void gtk_views_window_init(GtkViewsWindow* window) {
34 } 37 }
35 38
36 GtkWidget* gtk_views_window_new(GtkWindowType type) { 39 GtkWidget* gtk_views_window_new(GtkWindowType type) {
37 return GTK_WIDGET(g_object_new(GTK_TYPE_VIEWS_WINDOW, "type", type, NULL)); 40 return GTK_WIDGET(g_object_new(GTK_TYPE_VIEWS_WINDOW, "type", type, NULL));
38 } 41 }
39 42
40 G_END_DECLS 43 G_END_DECLS
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698