Disabling Focus Stealing in X applications
Various applications (my bugbear is instant messaging clients) steal focus at the most inopportune moments - usually while typing in some password or other - and no level of configuration or coaxing by window managers will make them stop.
The common wisdom around the place seems to be that the most reliable way around this is to set up a shared library which subverts calls to XSetInputFocus via a LD_PRELOAD directive. There's quite a few folks who have written about this - I found this article quite informative: http://neworder.box.sk/newsread.php?newsid=13857
To block XSetInputFocus a typical example source file would be:
#include <X11/Xlib.h> #include <stdio.h> int XSetInputFocus(Display *d, Window w, int i, Time t) { fprintf(stderr, "Blocked XSetInputFocus\n"); return 0; }
Compile this code with:
$ gcc -shared -fPIC disable_grab.c -o disable_grab.so
And then use it:
$ LD_PRELOAD=/path/to/disable_grab.so <application>
Unfortunately this isn't working for me at the moment - I suspect that my application is grabbing focus some other way so some further investigation is require.