-static gint gtk_dialog_focus_callback( GtkWidget *widget, GtkDirectionType WXUNUSED(d), wxWindow *WXUNUSED(win) )
-{
- if (g_isIdle)
- wxapp_install_idle_handler();
+ /* We don't ask for button press events on the grab widget, so
+ * if an event is reported directly to the grab widget, it must
+ * be on a window outside the application (and thus we remove
+ * the popup window). Otherwise, we check if the widget is a child
+ * of the grab widget, and only remove the popup window if it
+ * is not. */
+ if (child != widget)
+ {
+ while (child)
+ {
+ if (child == widget)
+ return FALSE;
+ child = child->parent;
+ }
+ }
+
+ wxFocusEvent event( wxEVT_KILL_FOCUS, win->GetId() );
+ event.SetEventObject( win );
+
+ (void)win->GetEventHandler()->ProcessEvent( event );