OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include <gtk/gtk.h> |
| 6 |
| 7 #include "ui/views/events/event.h" |
| 8 #include "ui/views/focus/focus_manager.h" |
| 9 #include "views/widget/gtk_views_window.h" |
| 10 #include "views/widget/widget.h" |
| 11 |
| 12 G_BEGIN_DECLS |
| 13 |
| 14 G_DEFINE_TYPE(GtkViewsWindow, gtk_views_window, GTK_TYPE_WINDOW) |
| 15 |
| 16 static void gtk_views_window_move_focus(GtkWindow* window, |
| 17 GtkDirectionType dir) { |
| 18 views::Widget* widget = views::Widget::GetWidgetForNativeWindow(window); |
| 19 views::FocusManager* focus_manager = |
| 20 widget ? widget->GetFocusManager() : NULL; |
| 21 if (focus_manager) { |
| 22 GdkEvent* key = gtk_get_current_event(); |
| 23 if (key && key->type == GDK_KEY_PRESS) { |
| 24 views::KeyEvent key_event(key); |
| 25 focus_manager->OnKeyEvent(key_event); |
| 26 } |
| 27 } else if (GTK_WINDOW_CLASS(gtk_views_window_parent_class)->move_focus) { |
| 28 GTK_WINDOW_CLASS(gtk_views_window_parent_class)->move_focus(window, dir); |
| 29 } |
| 30 } |
| 31 |
| 32 static void gtk_views_window_class_init( |
| 33 GtkViewsWindowClass* views_window_class) { |
| 34 GtkWindowClass* window_class = |
| 35 reinterpret_cast<GtkWindowClass*>(views_window_class); |
| 36 window_class->move_focus = gtk_views_window_move_focus; |
| 37 } |
| 38 |
| 39 static void gtk_views_window_init(GtkViewsWindow* window) { |
| 40 } |
| 41 |
| 42 GtkWidget* gtk_views_window_new(GtkWindowType type) { |
| 43 return GTK_WIDGET(g_object_new(GTK_TYPE_VIEWS_WINDOW, "type", type, NULL)); |
| 44 } |
| 45 |
| 46 G_END_DECLS |
OLD | NEW |