diff -ur xxkb-1.11/xxkb.c xxkb-1.11-lodin/xxkb.c --- xxkb-1.11/xxkb.c 2007-03-15 00:54:53 +0300 +++ xxkb-1.11-lodin/xxkb.c 2007-06-10 08:42:53 +0400 @@ -606,7 +606,32 @@ repar_evt->parent != root_win && BASE(repar_evt->parent) != BASE(temp_win) && repar_evt->override_redirect != True) { - AddWindow(temp_win, repar_evt->parent); + + Window rwin, parent, *children, *child, app; + int num; + + /* Iterate through the window list until we find + * the window the event was about. + * + * The code was mostly copied + * */ + + XQueryTree(dpy, root_win, &rwin, &parent, &children, &num); + child = children; + + while (num --> 0) { + app = None; + GetAppWindow(*child, &app); + + if (app == temp_win) { + AddWindow(temp_win, repar_evt->parent); + break; + } + child++; + }; + + if (children != None) + XFree(children); } break;