Index: callbacks.c
===================================================================
RCS file: /cvs/gnome/gok/gok/callbacks.c,v
retrieving revision 1.40
diff -u -p -r1.40 callbacks.c
--- callbacks.c	22 Jul 2003 14:21:13 -0000	1.40
+++ callbacks.c	22 Jul 2003 16:33:33 -0000
@@ -104,12 +104,24 @@ gok_discard_focus_filter (GdkXEvent *xev
 			  gpointer  data)
 {
   XEvent *xev = (XEvent *)xevent;	
+  GList *list, *l;
+  gint n_mapped;
 
   if (xev->xany.type == ClientMessage &&
       (Atom) xev->xclient.data.l[0] == gdk_x11_atom_to_xatom (
 	      gdk_atom_intern ("WM_TAKE_FOCUS", False)))
     {
-      XSetInputFocus (xev->xany.display, PointerRoot, RevertToPointerRoot, CurrentTime);
+      list = gtk_window_list_toplevels ();
+      n_mapped = 0;
+      for (l = list; l; l = l->next)
+        {
+          if (GTK_WIDGET_MAPPED (GTK_WIDGET (l->data)))
+            n_mapped++;
+        }
+      if (n_mapped <= 1)
+        XSetInputFocus (xev->xany.display, PointerRoot, RevertToPointerRoot, CurrentTime);
+
+      g_list_free (list);
       return GDK_FILTER_REMOVE;
     }
   else
