diff -Naur evrouter/src/evrouter.c evrouter_als/src/evrouter.c --- evrouter/src/evrouter.c 2004-09-08 00:57:39.000000000 +0200 +++ evrouter_als/src/evrouter.c 2006-07-05 16:57:03.000000000 +0200 @@ -104,16 +104,26 @@ static char * get_focus () { - Window focus; + Window focus, root, parent; + Window *children; XClassHint xch = {NULL, NULL}; int i; char * wname = NULL; static char * oldwname = "(null)"; + unsigned int num_children; XGetInputFocus (d, &focus, &i); if (focus != None) { XGetClassHint (d, focus, &xch); XFetchName (d, focus, &wname); + XQueryTree(d, focus, &root, &parent, &children, &num_children); + if ((!xch.res_class) && (parent) && (focus != root)) { + XFree(xch.res_class); + XFree(xch.res_name); + XFree(wname); + XGetClassHint(d, parent, &xch); + XFetchName (d, parent, &wname); + } } if (train_mode) { @@ -236,11 +246,13 @@ static void handle_event (evdev_t * dev, int devindex, struct input_event * ev) { - Window focus; + Window focus, root, parent; + Window *children; XClassHint xch = {NULL, NULL}; int i, k; char * wname = NULL; unsigned int mods; + unsigned int num_children; XErrorHandler old_handler; if ((ev->type != EV_KEY) && @@ -259,6 +271,14 @@ if (focus != None) { XGetClassHint (d, focus, &xch); XFetchName (d, focus, &wname); + XQueryTree(d, focus, &root, &parent, &children, &num_children); + if ((!xch.res_class) && (parent) && (focus != root)) { + XFree(xch.res_class); + XFree(xch.res_name); + XFree(wname); + XGetClassHint(d, parent, &xch); + XFetchName (d, parent, &wname); + } } XSetErrorHandler(old_handler);