OLD | NEW |
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> | 5 #include <gtk/gtk.h> |
6 #include "views/events/event.h" | 6 #include "views/events/event.h" |
7 #include "views/widget/gtk_views_window.h" | 7 #include "views/widget/gtk_views_window.h" |
8 #include "views/focus/focus_manager.h" | 8 #include "views/focus/focus_manager.h" |
9 | 9 |
10 G_BEGIN_DECLS | 10 G_BEGIN_DECLS |
11 | 11 |
12 G_DEFINE_TYPE(GtkViewsWindow, gtk_views_window, GTK_TYPE_WINDOW) | 12 G_DEFINE_TYPE(GtkViewsWindow, gtk_views_window, GTK_TYPE_WINDOW) |
13 | 13 |
14 static void gtk_views_window_move_focus(GtkWindow* window, | 14 static void gtk_views_window_move_focus(GtkWindow* window, |
15 GtkDirectionType dir) { | 15 GtkDirectionType dir) { |
16 views::FocusManager* focus_manager = | 16 views::FocusManager* focus_manager = |
17 views::FocusManager::GetFocusManagerForNativeWindow(window); | 17 views::FocusManager::GetFocusManagerForNativeWindow(window); |
18 if (focus_manager) { | 18 if (focus_manager) { |
19 GdkEvent* key = gtk_get_current_event(); | 19 GdkEvent* key = gtk_get_current_event(); |
20 if (key && key->type == GDK_KEY_PRESS) { | 20 if (key && key->type == GDK_KEY_PRESS) { |
21 views::KeyEvent key_event(reinterpret_cast<GdkEventKey*>(key)); | 21 views::KeyEvent key_event(key); |
22 focus_manager->OnKeyEvent(key_event); | 22 focus_manager->OnKeyEvent(key_event); |
23 } | 23 } |
24 } 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) { |
25 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); |
26 } | 26 } |
27 } | 27 } |
28 | 28 |
29 static void gtk_views_window_class_init( | 29 static void gtk_views_window_class_init( |
30 GtkViewsWindowClass* views_window_class) { | 30 GtkViewsWindowClass* views_window_class) { |
31 GtkWindowClass* window_class = | 31 GtkWindowClass* window_class = |
32 reinterpret_cast<GtkWindowClass*>(views_window_class); | 32 reinterpret_cast<GtkWindowClass*>(views_window_class); |
33 window_class->move_focus = gtk_views_window_move_focus; | 33 window_class->move_focus = gtk_views_window_move_focus; |
34 } | 34 } |
35 | 35 |
36 static void gtk_views_window_init(GtkViewsWindow* window) { | 36 static void gtk_views_window_init(GtkViewsWindow* window) { |
37 } | 37 } |
38 | 38 |
39 GtkWidget* gtk_views_window_new(GtkWindowType type) { | 39 GtkWidget* gtk_views_window_new(GtkWindowType type) { |
40 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)); |
41 } | 41 } |
42 | 42 |
43 G_END_DECLS | 43 G_END_DECLS |
OLD | NEW |