зеркало из https://github.com/mozilla/gecko-dev.git
bug 210373 make gtkmozembed on gtk2 use nsIWebBrowserFocus for focus handling,
to fix focus stealing bugs patch by Christian Persch <chpe@gnome.org> r=marco sr=roc a=asa
This commit is contained in:
Родитель
3153bf611c
Коммит
dd2a0eba58
|
@ -41,6 +41,7 @@
|
|||
#include "nsCRT.h"
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsIWebBrowserStream.h"
|
||||
#include "nsIWebBrowserFocus.h"
|
||||
|
||||
// for NS_APPSHELL_CID
|
||||
#include <nsWidgetsCID.h>
|
||||
|
@ -718,6 +719,7 @@ EmbedPrivate::ContentFinishedLoading(void)
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef MOZ_WIDGET_GTK
|
||||
// handle focus in and focus out events
|
||||
void
|
||||
EmbedPrivate::TopLevelFocusIn(void)
|
||||
|
@ -752,6 +754,7 @@ EmbedPrivate::TopLevelFocusOut(void)
|
|||
if (focusController)
|
||||
focusController->SetActive(PR_FALSE);
|
||||
}
|
||||
#endif /* MOZ_WIDGET_GTK */
|
||||
|
||||
void
|
||||
EmbedPrivate::ChildFocusIn(void)
|
||||
|
@ -759,6 +762,21 @@ EmbedPrivate::ChildFocusIn(void)
|
|||
if (mIsDestroyed)
|
||||
return;
|
||||
|
||||
#ifdef MOZ_WIDGET_GTK2
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIWebBrowser> webBrowser;
|
||||
rv = mWindow->GetWebBrowser(getter_AddRefs(webBrowser));
|
||||
if (NS_FAILED(rv))
|
||||
return;
|
||||
|
||||
nsCOMPtr<nsIWebBrowserFocus> webBrowserFocus(do_QueryInterface(webBrowser));
|
||||
if (!webBrowserFocus)
|
||||
return;
|
||||
|
||||
webBrowserFocus->Activate();
|
||||
#endif /* MOZ_WIDGET_GTK2 */
|
||||
|
||||
#ifdef MOZ_WIDGET_GTK
|
||||
nsCOMPtr<nsPIDOMWindow> piWin;
|
||||
GetPIDOMWindow(getter_AddRefs(piWin));
|
||||
|
||||
|
@ -766,6 +784,7 @@ EmbedPrivate::ChildFocusIn(void)
|
|||
return;
|
||||
|
||||
piWin->Activate();
|
||||
#endif /* MOZ_WIDGET_GTK */
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -774,6 +793,21 @@ EmbedPrivate::ChildFocusOut(void)
|
|||
if (mIsDestroyed)
|
||||
return;
|
||||
|
||||
#ifdef MOZ_WIDGET_GTK2
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIWebBrowser> webBrowser;
|
||||
rv = mWindow->GetWebBrowser(getter_AddRefs(webBrowser));
|
||||
if (NS_FAILED(rv))
|
||||
return;
|
||||
|
||||
nsCOMPtr<nsIWebBrowserFocus> webBrowserFocus(do_QueryInterface(webBrowser));
|
||||
if (!webBrowserFocus)
|
||||
return;
|
||||
|
||||
webBrowserFocus->Deactivate();
|
||||
#endif /* MOZ_WIDGET_GTK2 */
|
||||
|
||||
#ifdef MOZ_WIDGET_GTK
|
||||
nsCOMPtr<nsPIDOMWindow> piWin;
|
||||
GetPIDOMWindow(getter_AddRefs(piWin));
|
||||
|
||||
|
@ -787,7 +821,7 @@ EmbedPrivate::ChildFocusOut(void)
|
|||
nsIFocusController *focusController = piWin->GetRootFocusController();
|
||||
if (focusController)
|
||||
focusController->SetActive(PR_TRUE);
|
||||
|
||||
#endif /* MOZ_WIDGET_GTK */
|
||||
}
|
||||
|
||||
// Get the event listener for the chrome event handler.
|
||||
|
|
|
@ -111,10 +111,12 @@ class EmbedPrivate {
|
|||
// visibility is set.
|
||||
void ContentFinishedLoading(void);
|
||||
|
||||
#ifdef MOZ_WIDGET_GTK
|
||||
// these let the widget code know when the toplevel window gets and
|
||||
// looses focus.
|
||||
void TopLevelFocusIn (void);
|
||||
void TopLevelFocusOut(void);
|
||||
#endif
|
||||
|
||||
// these are when the widget itself gets focus in and focus out
|
||||
// events
|
||||
|
|
|
@ -240,20 +240,6 @@ handle_toplevel_focus_out(GtkMozArea *aArea,
|
|||
GtkMozEmbed *aEmbed);
|
||||
#endif /* MOZ_WIDGET_GTK */
|
||||
|
||||
#ifdef MOZ_WIDGET_GTK2
|
||||
// signal handlers for tracking the focus in and focus out events on
|
||||
// the toplevel window.
|
||||
|
||||
static gint
|
||||
handle_toplevel_focus_in(GtkWidget *aWidget,
|
||||
GdkEventFocus *aEvent,
|
||||
EmbedPrivate *aPrivate);
|
||||
static gint
|
||||
handle_toplevel_focus_out(GtkWidget *aWidget,
|
||||
GdkEventFocus *aEvent,
|
||||
EmbedPrivate *aPrivate);
|
||||
#endif /* MOZ_WIDGET_GTK2 */
|
||||
|
||||
// globals for this type of widget
|
||||
|
||||
static GtkBinClass *embed_parent_class;
|
||||
|
@ -618,21 +604,6 @@ gtk_moz_embed_realize(GtkWidget *widget)
|
|||
rv = embedPrivate->Realize(&alreadyRealized);
|
||||
g_return_if_fail(NS_SUCCEEDED(rv));
|
||||
|
||||
GtkWidget *child_widget = GTK_BIN(widget)->child;
|
||||
#ifdef MOZ_WIDGET_GTK2
|
||||
GtkWidget *toplevel = gtk_widget_get_toplevel(widget);
|
||||
gtk_signal_connect_while_alive(GTK_OBJECT(toplevel),
|
||||
"focus_in_event",
|
||||
GTK_SIGNAL_FUNC(handle_toplevel_focus_in),
|
||||
embedPrivate,
|
||||
GTK_OBJECT(child_widget));
|
||||
gtk_signal_connect_while_alive(GTK_OBJECT(toplevel),
|
||||
"focus_out_event",
|
||||
GTK_SIGNAL_FUNC(handle_toplevel_focus_out),
|
||||
embedPrivate,
|
||||
GTK_OBJECT(child_widget));
|
||||
#endif /* MOZ_WIDGET_GTK2 */
|
||||
|
||||
// if we're already realized we don't need to hook up to anything below
|
||||
if (alreadyRealized)
|
||||
return;
|
||||
|
@ -641,6 +612,7 @@ gtk_moz_embed_realize(GtkWidget *widget)
|
|||
embedPrivate->LoadCurrentURI();
|
||||
|
||||
// connect to the focus out event for the child
|
||||
GtkWidget *child_widget = GTK_BIN(widget)->child;
|
||||
gtk_signal_connect_while_alive(GTK_OBJECT(child_widget),
|
||||
"focus_out_event",
|
||||
GTK_SIGNAL_FUNC(handle_child_focus_out),
|
||||
|
@ -685,16 +657,6 @@ gtk_moz_embed_unrealize(GtkWidget *widget)
|
|||
embedPrivate->Unrealize();
|
||||
}
|
||||
|
||||
#ifdef MOZ_WIDGET_GTK2
|
||||
GtkWidget *toplevel = gtk_widget_get_toplevel(widget);
|
||||
gtk_signal_disconnect_by_func(GTK_OBJECT(toplevel),
|
||||
GTK_SIGNAL_FUNC(handle_toplevel_focus_in),
|
||||
embedPrivate);
|
||||
gtk_signal_disconnect_by_func(GTK_OBJECT(toplevel),
|
||||
GTK_SIGNAL_FUNC(handle_toplevel_focus_out),
|
||||
embedPrivate);
|
||||
#endif /* MOZ_WIDGET_GTK2 */
|
||||
|
||||
if (GTK_WIDGET_CLASS(embed_parent_class)->unrealize)
|
||||
(* GTK_WIDGET_CLASS(embed_parent_class)->unrealize)(widget);
|
||||
}
|
||||
|
@ -825,30 +787,6 @@ handle_toplevel_focus_out(GtkMozArea *aArea,
|
|||
}
|
||||
#endif /* MOZ_WIDGET_GTK */
|
||||
|
||||
#ifdef MOZ_WIDGET_GTK2
|
||||
/* static */
|
||||
gint
|
||||
handle_toplevel_focus_in(GtkWidget *aWidget,
|
||||
GdkEventFocus *aEvent,
|
||||
EmbedPrivate *aPrivate)
|
||||
{
|
||||
aPrivate->TopLevelFocusIn();
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* static */
|
||||
gint
|
||||
handle_toplevel_focus_out(GtkWidget *aWidget,
|
||||
GdkEventFocus *aEvent,
|
||||
EmbedPrivate *aPrivate)
|
||||
{
|
||||
aPrivate->TopLevelFocusOut();
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
#endif /* MOZ_WIDGET_GTK2 */
|
||||
|
||||
// Widget methods
|
||||
|
||||
void
|
||||
|
|
Загрузка…
Ссылка в новой задаче