diff options
author | oshima@google.com <oshima@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-07 18:02:18 +0000 |
---|---|---|
committer | oshima@google.com <oshima@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-07 18:02:18 +0000 |
commit | 1010aa34547be12e63f922824fb9510d88686294 (patch) | |
tree | 47c0c390173a01573d19c87830ff546b08d67fbb | |
parent | 1bc869d5bb06728b63a3e9a603605e27ead5f985 (diff) | |
download | chromium_src-1010aa34547be12e63f922824fb9510d88686294.zip chromium_src-1010aa34547be12e63f922824fb9510d88686294.tar.gz chromium_src-1010aa34547be12e63f922824fb9510d88686294.tar.bz2 |
Don't store/restore focus when window is activated/deactivated on linux.
GTK can restore focus if the native widget has a focus, and views always remembers the focused_view, so there is no need to store/restore on linux for this case. Opening it (like wrench menu) was causing the issues in bugs because it changes window activation.
BUG=70032,chromium-os:8829
TEST=see bugs
TEST=
Review URL: http://codereview.chromium.org/6691052
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@80809 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/ui/views/find_bar_view.cc | 18 | ||||
-rw-r--r-- | views/focus/focus_manager_unittest.cc | 6 | ||||
-rw-r--r-- | views/widget/widget_gtk.cc | 5 |
3 files changed, 6 insertions, 23 deletions
diff --git a/chrome/browser/ui/views/find_bar_view.cc b/chrome/browser/ui/views/find_bar_view.cc index c45c0be..1f1d80c 100644 --- a/chrome/browser/ui/views/find_bar_view.cc +++ b/chrome/browser/ui/views/find_bar_view.cc @@ -29,7 +29,6 @@ #include "views/controls/button/image_button.h" #include "views/controls/label.h" #include "views/controls/textfield/textfield.h" -#include "views/focus/focus_manager.h" #include "views/widget/widget.h" // The amount of whitespace to have before the find button. @@ -235,23 +234,6 @@ void FindBarView::ClearMatchCount() { } void FindBarView::SetFocusAndSelection(bool select_all) { -#if defined(OS_CHROMEOS) - // TODO(altimofeev): this workaround is needed only when the FindBar was - // opened from the wrench menu (it also works in the accelerator case, but it - // is not really needed). - - // Restore focus to allow the find bar's external focus tracker to save the - // view that should be activated later (the tracker is created after the - // wrench menu has received the focus). - find_text_->GetFocusManager()->RestoreFocusedView(); - find_text_->RequestFocus(); - // Storing is needed here because the view that has focus before the wrench - // menu activation will get focus just after the wrench menu is closed. - // The FindBar has it's own focus tracker, so it will focus the correct view - // on close. - find_text_->GetFocusManager()->StoreFocusedView(); - // Request focus again since the call to StoreFocusedView unfocuses the view. -#endif find_text_->RequestFocus(); if (select_all && !find_text_->text().empty()) find_text_->SelectAll(); diff --git a/views/focus/focus_manager_unittest.cc b/views/focus/focus_manager_unittest.cc index 75d3b72..11662df 100644 --- a/views/focus/focus_manager_unittest.cc +++ b/views/focus/focus_manager_unittest.cc @@ -966,6 +966,11 @@ TEST_F(FocusManagerTest, FocusNativeControls) { EXPECT_EQ(tab_button, GetFocusManager()->GetFocusedView()); } + +// On linux, we don't store/restore focused view because gtk handles +// this (and pure views will be the same). +#if defined(OS_WIN) + // Test that when activating/deactivating the top window, the focus is stored/ // restored properly. TEST_F(FocusManagerTest, FocusStoreRestore) { @@ -1042,6 +1047,7 @@ TEST_F(FocusManagerTest, FocusStoreRestore) { EXPECT_TRUE(listener.focus_changes()[1] == ViewPair(null_view, view)); */ } +#endif TEST_F(FocusManagerTest, ContainsView) { View* view = new View(); diff --git a/views/widget/widget_gtk.cc b/views/widget/widget_gtk.cc index 15394c4..6a31bb8 100644 --- a/views/widget/widget_gtk.cc +++ b/views/widget/widget_gtk.cc @@ -1222,8 +1222,6 @@ gboolean WidgetGtk::OnFocusIn(GtkWidget* widget, GdkEventFocus* event) { if (!got_initial_focus_in_) { got_initial_focus_in_ = true; SetInitialFocus(); - } else { - GetFocusManager()->RestoreFocusedView(); } return false; } @@ -1239,9 +1237,6 @@ gboolean WidgetGtk::OnFocusOut(GtkWidget* widget, GdkEventFocus* event) { // Only top-level Widget should have an InputMethod instance. if (input_method_.get()) input_method_->OnBlur(); - - // The top-level window lost focus, store the focused view. - GetFocusManager()->StoreFocusedView(); return false; } |