Index: gtkmozembed2.cpp =================================================================== RCS file: /cvsroot/mozilla/embedding/browser/gtk/src/gtkmozembed2.cpp,v retrieving revision 1.42 diff -p -u -u -p -r1.42 gtkmozembed2.cpp --- gtkmozembed2.cpp 6 Feb 2005 17:57:49 -0000 1.42 +++ gtkmozembed2.cpp 26 Mar 2005 14:57:45 -0000 @@ -738,9 +738,9 @@ gtk_moz_embed_map(GtkWidget *widget) GTK_WIDGET_SET_FLAGS(widget, GTK_MAPPED); embedPrivate->Show(); + embedPrivate->ActivateFocusController(); gdk_window_show(widget->window); - } static void @@ -759,6 +759,7 @@ gtk_moz_embed_unmap(GtkWidget *widget) gdk_window_hide(widget->window); + embedPrivate->DeactivateFocusController(); embedPrivate->Hide(); } Index: EmbedPrivate.h =================================================================== RCS file: /cvsroot/mozilla/embedding/browser/gtk/src/EmbedPrivate.h,v retrieving revision 1.25 diff -p -u -u -p -r1.25 EmbedPrivate.h --- EmbedPrivate.h 20 Jan 2005 10:26:44 -0000 1.25 +++ EmbedPrivate.h 26 Mar 2005 14:57:45 -0000 @@ -119,6 +119,10 @@ class EmbedPrivate { void TopLevelFocusIn (void); void TopLevelFocusOut(void); + // these are to activate and deactivate the focus controller + void ActivateFocusController (void); + void DeactivateFocusController (void); + // these are when the widget itself gets focus in and focus out // events void ChildFocusIn (void); @@ -179,6 +183,8 @@ class EmbedPrivate { GtkWidget *mMozWindowWidget; // has someone called Destroy() on us? PRBool mIsDestroyed; + // does our toplevel have the focus? + PRBool mTopLevelHasFocus; private: Index: EmbedPrivate.cpp =================================================================== RCS file: /cvsroot/mozilla/embedding/browser/gtk/src/EmbedPrivate.cpp,v retrieving revision 1.52 diff -p -u -u -p -r1.52 EmbedPrivate.cpp --- EmbedPrivate.cpp 20 Jan 2005 10:26:44 -0000 1.52 +++ EmbedPrivate.cpp 26 Mar 2005 14:57:45 -0000 @@ -735,7 +735,16 @@ EmbedPrivate::ContentFinishedLoading(voi void EmbedPrivate::TopLevelFocusIn(void) { - if (mIsDestroyed) + mTopLevelHasFocus = PR_TRUE; + + if (GTK_WIDGET_MAPPED(mOwningWidget)) + ActivateFocusController(); +} + +void +EmbedPrivate::ActivateFocusController(void) +{ + if (mIsDestroyed || !mTopLevelHasFocus) return; nsCOMPtr piWin; @@ -752,6 +761,15 @@ EmbedPrivate::TopLevelFocusIn(void) void EmbedPrivate::TopLevelFocusOut(void) { + mTopLevelHasFocus = PR_FALSE; + + if (GTK_WIDGET_MAPPED(mOwningWidget)) + DeactivateFocusController(); +} + +void +EmbedPrivate::DeactivateFocusController(void) +{ if (mIsDestroyed) return; @@ -795,12 +813,13 @@ EmbedPrivate::ChildFocusOut(void) piWin->Deactivate(); +#ifdef MOZ_WIDGET_GTK // but the window is still active until the toplevel gets a focus // out nsIFocusController *focusController = piWin->GetRootFocusController(); if (focusController) focusController->SetActive(PR_TRUE); - +#endif } // Get the event listener for the chrome event handler.