Window toplevel = get_real_toplevel(window);   GdkWindow *gdk_window = gdk_window_lookup(toplevel);   if (!gdk_window) {  gdk_window = gdk_window_foreign_new(toplevel);  gdk_window_set_events(gdk_window, GDK_FOCUS_CHANGE_MASK); }
attach_toplevel_listener(GtkMozArea *mozarea){  /* get the native window for this widget */  GtkWidget *widget = GTK_WIDGET(mozarea);  Window window = GDK_WINDOW_XWINDOW(widget->window);  Window toplevel = get_real_toplevel(window);  /* check to see if this is an already registered window with the     type system. */  GdkWindow *gdk_window = gdk_window_lookup(toplevel);  /* This isn't our window?  It is now, fool! */  if (!gdk_window) {    /* import it into the type system */    gdk_window = gdk_window_foreign_new(toplevel);    /* make sure that we are listening for the right events on it. */    gdk_window_set_events(gdk_window, GDK_FOCUS_CHANGE_MASK);  }  /* attach our passive filter.  when the window is destroyed it will     automatically be removed. */  gdk_window_add_filter(gdk_window, toplevel_window_filter, mozarea);  /* save it so that we can remove the filter later */  mozarea->toplevel_window = gdk_window;}