diff options
author | jcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-01 22:53:51 +0000 |
---|---|---|
committer | jcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-01 22:53:51 +0000 |
commit | dc5e89230025a8202e0314410a388ad91138020c (patch) | |
tree | 41630518a44295112141de14f595c50e11fb84de /views/controls/native_control_gtk.cc | |
parent | 668dd15b25cf7fd94fede92dd140b59c62009390 (diff) | |
download | chromium_src-dc5e89230025a8202e0314410a388ad91138020c.zip chromium_src-dc5e89230025a8202e0314410a388ad91138020c.tar.gz chromium_src-dc5e89230025a8202e0314410a388ad91138020c.tar.bz2 |
The FocusManager stores/restores focus when the top window becomes inactive/active.
BUG=None
TEST=Run the focus manager unit-tests.
Review URL: http://codereview.chromium.org/164448
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@25108 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views/controls/native_control_gtk.cc')
-rw-r--r-- | views/controls/native_control_gtk.cc | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/views/controls/native_control_gtk.cc b/views/controls/native_control_gtk.cc index e95278d..a13c870 100644 --- a/views/controls/native_control_gtk.cc +++ b/views/controls/native_control_gtk.cc @@ -7,6 +7,7 @@ #include <gtk/gtk.h> #include "base/logging.h" +#include "views/focus/focus_manager.h" namespace views { @@ -63,6 +64,23 @@ void NativeControlGtk::NativeControlCreated(GtkWidget* native_control) { // Update the newly created GtkWdigetwith any resident enabled state. gtk_widget_set_sensitive(native_view(), IsEnabled()); + + // Listen for focus change event to update the FocusManager focused view. + g_signal_connect(G_OBJECT(native_control), "focus-in-event", + G_CALLBACK(CallFocusIn), this); +} + +// static +void NativeControlGtk::CallFocusIn(GtkWidget* widget, + GdkEventFocus* event, + NativeControlGtk* control) { + FocusManager* focus_manager = + FocusManager::GetFocusManagerForNativeView(widget); + if (!focus_manager) { + NOTREACHED(); + return; + } + focus_manager->SetFocusedView(control->focus_view()); } } // namespace views |