4
/*Linux users will need to add -ldl to the Makefile to compile
11
int handle_error (Display *d, XErrorEvent *error)
13
fprintf (stderr, "X Error\n");
17
int select_all_substructure_notify (Window id)
19
Window root_return, parent_return;
20
Window *children = NULL;
21
unsigned int nchildren;
24
int ret = XQueryTree (dis, id, &root_return, &parent_return, &children, &nchildren), i = 0;
26
fprintf (stderr, "%i selecting for StructureNotifyMask or FocusChangeMask on 0x%x\n", ret, id);
28
XSelectInput (dis, id, SubstructureNotifyMask | StructureNotifyMask | FocusChangeMask);
38
for (i = i; i < nchildren; i++)
39
select_all_substructure_notify (children[i]);
43
dis = XOpenDisplay(NULL);
45
XSetErrorHandler (&handle_error);
47
select_all_substructure_notify (RootWindow (dis, DefaultScreen (dis)));
50
XNextEvent(dis, &report);
51
switch (report.type) {
53
if (report.xfocus.mode == NotifyGrab)
54
fprintf (stdout, "NotifyGrab FocusIn from 0x%x\n", report.xfocus.window);
57
if (report.xfocus.mode == NotifyUngrab)
58
fprintf (stdout, "NotifyUngrab FocusOut from 0x%x\n", report.xfocus.window);
61
select_all_substructure_notify (report.xcreatewindow.window);