diff options
author | suzhe@chromium.org <suzhe@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-20 23:07:48 +0000 |
---|---|---|
committer | suzhe@chromium.org <suzhe@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-20 23:07:48 +0000 |
commit | ccbb7b6ec086e614efa111ecb5e51cb0ef1730ed (patch) | |
tree | 8b460140e85bd82af24f8b6a8ddbe334098cd2ae /views/widget/gtk_views_window.cc | |
parent | 9d3fd748881fc6b4000efea6471b90aead6b5eb1 (diff) | |
download | chromium_src-ccbb7b6ec086e614efa111ecb5e51cb0ef1730ed.zip chromium_src-ccbb7b6ec086e614efa111ecb5e51cb0ef1730ed.tar.gz chromium_src-ccbb7b6ec086e614efa111ecb5e51cb0ef1730ed.tar.bz2 |
[Linux Views]Handle focus traversing correctly.
This CL adds a wrapper window class on top of GtkWindow to intercept its
move_focus method, so that we can handle focus traversing by ourselves.
BUG=49204: Chrome/views toolbar "tab" accessibility broken.
TEST=See bug report.
Review URL: http://codereview.chromium.org/3013006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@53123 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views/widget/gtk_views_window.cc')
-rw-r--r-- | views/widget/gtk_views_window.cc | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/views/widget/gtk_views_window.cc b/views/widget/gtk_views_window.cc new file mode 100644 index 0000000..fb3657d --- /dev/null +++ b/views/widget/gtk_views_window.cc @@ -0,0 +1,40 @@ +// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "views/widget/gtk_views_window.h" +#include "views/focus/focus_manager.h" + +G_BEGIN_DECLS + +G_DEFINE_TYPE(GtkViewsWindow, gtk_views_window, GTK_TYPE_WINDOW) + +static void gtk_views_window_move_focus(GtkWindow *window, + GtkDirectionType dir) { + views::FocusManager* focus_manager = + views::FocusManager::GetFocusManagerForNativeWindow(window); + if (focus_manager) { + // We only support tab traversing by tab keys, so just ignore all other + // cases silently. + if (dir == GTK_DIR_TAB_BACKWARD || dir == GTK_DIR_TAB_FORWARD) + focus_manager->AdvanceFocus(dir == GTK_DIR_TAB_BACKWARD); + } else if (GTK_WINDOW_CLASS(gtk_views_window_parent_class)->move_focus) { + GTK_WINDOW_CLASS(gtk_views_window_parent_class)->move_focus(window, dir); + } +} + +static void gtk_views_window_class_init( + GtkViewsWindowClass* views_window_class) { + GtkWindowClass* window_class = + reinterpret_cast<GtkWindowClass*>(views_window_class); + window_class->move_focus = gtk_views_window_move_focus; +} + +static void gtk_views_window_init(GtkViewsWindow* window) { +} + +GtkWidget* gtk_views_window_new(GtkWindowType type) { + return GTK_WIDGET(g_object_new(GTK_TYPE_VIEWS_WINDOW, "type", type, NULL)); +} + +G_END_DECLS |