summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-12 22:53:34 +0000
committerestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-12 22:53:34 +0000
commit1d9489eac7d6f0807524d3d5de12d210e9e29594 (patch)
treea51a3bf93136d418082f991f0b8e43d684e5497e
parent60bf6869e6e692e83d11dcc61007a1849d6bedde (diff)
downloadchromium_src-1d9489eac7d6f0807524d3d5de12d210e9e29594.zip
chromium_src-1d9489eac7d6f0807524d3d5de12d210e9e29594.tar.gz
chromium_src-1d9489eac7d6f0807524d3d5de12d210e9e29594.tar.bz2
Linux: fix a couple focus issues:
- Don't change focus in FindBarGtk::RestoreSavedFocus() unless the find bar has focus. - Hide widgets in SlideAnimatorGtk when they aren't showing so they can't get focus. - Add a check for null focus widget in TabContentsViewGtk::SaveFocus(). Review URL: http://codereview.chromium.org/115254 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@15910 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/gtk/find_bar_gtk.cc10
-rw-r--r--chrome/browser/gtk/slide_animator_gtk.cc8
-rw-r--r--chrome/browser/tab_contents/tab_contents_view_gtk.cc12
3 files changed, 21 insertions, 9 deletions
diff --git a/chrome/browser/gtk/find_bar_gtk.cc b/chrome/browser/gtk/find_bar_gtk.cc
index 6174791..3c27bdd 100644
--- a/chrome/browser/gtk/find_bar_gtk.cc
+++ b/chrome/browser/gtk/find_bar_gtk.cc
@@ -172,10 +172,10 @@ GtkWidget* FindBarGtk::slide_widget() {
}
void FindBarGtk::Show() {
+ slide_widget_->Open();
if (container_->window)
gdk_window_raise(container_->window);
gtk_widget_grab_focus(find_text_);
- slide_widget_->Open();
}
void FindBarGtk::Hide(bool animate) {
@@ -236,7 +236,13 @@ bool FindBarGtk::IsFindBarVisible() {
void FindBarGtk::RestoreSavedFocus() {
// TODO(estade): We should save focus and restore its previous location if we
- // don't find any matches in our search.
+ // don't find any matches in our search. For now just give focus to the tab
+ // contents.
+ // This function sometimes gets called when we don't have focus. We should do
+ // nothing in this case.
+ if (!GTK_WIDGET_HAS_FOCUS(find_text_))
+ return;
+
find_bar_controller_->tab_contents()->Focus();
}
diff --git a/chrome/browser/gtk/slide_animator_gtk.cc b/chrome/browser/gtk/slide_animator_gtk.cc
index 31d4d4c..3cf004c 100644
--- a/chrome/browser/gtk/slide_animator_gtk.cc
+++ b/chrome/browser/gtk/slide_animator_gtk.cc
@@ -91,6 +91,7 @@ void SlideAnimatorGtk::CloseWithoutAnimation() {
animation_->Reset(0.0);
animation_->Hide();
AnimationProgressed(animation_.get());
+ gtk_widget_hide(widget_.get());
}
bool SlideAnimatorGtk::IsShowing() {
@@ -108,8 +109,11 @@ void SlideAnimatorGtk::AnimationProgressed(const Animation* animation) {
}
void SlideAnimatorGtk::AnimationEnded(const Animation* animation) {
- if (!animation_->IsShowing() && delegate_)
- delegate_->Closed();
+ if (!animation_->IsShowing()) {
+ gtk_widget_hide(widget_.get());
+ if (delegate_)
+ delegate_->Closed();
+ }
}
// static
diff --git a/chrome/browser/tab_contents/tab_contents_view_gtk.cc b/chrome/browser/tab_contents/tab_contents_view_gtk.cc
index 4ef882b..67f4d73 100644
--- a/chrome/browser/tab_contents/tab_contents_view_gtk.cc
+++ b/chrome/browser/tab_contents/tab_contents_view_gtk.cc
@@ -203,11 +203,13 @@ void TabContentsViewGtk::StoreFocus() {
g_signal_handler_disconnect(stored_focus_widget_, destroy_handler_id_);
stored_focus_widget_ = window->focus_widget;
- // gtk_widget_destroyed() will set |stored_focus_widget_| to NULL when it is
- // invoked during handling of the "destroy" signal.
- destroy_handler_id_ = g_signal_connect(stored_focus_widget_, "destroy",
- G_CALLBACK(gtk_widget_destroyed),
- &stored_focus_widget_);
+ if (stored_focus_widget_) {
+ // gtk_widget_destroyed() will set |stored_focus_widget_| to NULL when it is
+ // invoked during handling of the "destroy" signal.
+ destroy_handler_id_ = g_signal_connect(stored_focus_widget_, "destroy",
+ G_CALLBACK(gtk_widget_destroyed),
+ &stored_focus_widget_);
+ }
}
void TabContentsViewGtk::RestoreFocus() {