[Subject Prev][Subject Next][Thread Prev][Thread Next][Subject Index][Thread Index]

X Window query



Hello! I am developing a software to monitor the X Window applications in Linux, using C and Xlib. I am able to find out which
applications (windows) are open and even get some of the events that occur in those applications. My problem is that when I close any window while the system is being monitored, a message like this appears at the terminal.

X Error of failed request:  BadWindow (invalid Window parameter)
  Major opcode of failed request:  20 (X_GetProperty)
  Resource id in failed request:  0x20002bb
  Serial number of failed request:  33677
  Current serial number in output stream:  33677  

Immediately, the monitoring stops and the command prompt appears. I use the XFetchName and XQueryTree functions for finding out the open windows. How can I suppress the above error message and *continue monitoring*? 

More still, how can I find out if a window has been closed? It does not work if I use a flag to mark a closed window. (I set this flag in the event handler for DestroyNotify).

if (node->dflag == 2)
{
  printf("Destroyed window\n");
  return;
}
else
{
/* monitoring part */
}

where node is a structure variable storing details about this window.

The problem is compounded because the program is recursive to find out all the windows spawned by each window. I think the program terminates even before the check is performed the next time through the code. 

Please help.
- Karthika


_____________________________________________________
Chat with your friends as soon as they come online. Get Rediff Bol at
http://bol.rediff.com