Query mouse events from other Windows/Screens

George Liu <[email protected]>
Newsgroups gmane.comp.xfree86.devel
Message-ID <[email protected]>
I would like to write an application that would collect mouse events
(Button Press/Release) among all windows/screens in the same desktop,
and display the event info on a dedicated window. I used the following
two methods but none worked.  Your help is appreciated.

Method 1:
   d = XOpenDisplay(display_name);
   s = XDefaultScreen(d);  
   root = RootWindow(d,s);
   XSelectInput(d, root, ButtonPressMask);
   while(1)
     {
        XNextEvent(d, &ev);
        switch(ev.type)
          {
           case ButtonPress:
               ...

In this method, program is hanging on waiting for XNextEvent. Since
SelectInput is on root window,  and no ButtonPress is detected on that
window. How can I get the events from the window a mouse is presenting?

Method 2:         
Use the function Select_Window( display) to select the current mouse
pointed window and leads grab all events on the entire screen, however,
the normal mouse function won't work till the program is done.

Thanks,
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.