event problem

石仔 406643764 at qq.com
Sat Oct 28 16:29:21 UTC 2017


hi all.
This is my ~/.xinitrc :
              exec xterm

I start x with 'startx' command,  and then run 'testx'. This is  source :
/* gcc testx.c -o testx -lX11 */
  1 #include <stdio.h>
  2 #include <X11/Xlib.h>
  3 int main(int argc, char *argv[])
  4 {
  5 
  6     Display *display=XOpenDisplay(NULL);
  7     Window root, parent, *child=NULL, root_win=RootWindow(display, DefaultScreen(display));
  8     unsigned int n;
  9     XWindowAttributes attr;
 10     if(XQueryTree(display, root_win, &root, &parent, &child, &n))
 11         for(size_t i=0; i<n; i++)
 12             if(XGetWindowAttributes(display, child[i], &attr)
 13                 && attr.map_state == IsViewable
 14                 && XSelectInput(display, child[i], ButtonPressMask))
 15                     printf("set %x\n", child[i]);
 16     XEvent event;
 17     while(1)
 18     {
 19         XNextEvent(display, &event);
 20         if(event.type == ButtonPress)
 21         printf("type=%d, w=%x\n", event.type, event.xbutton.window);
 22     }
 23 }

I can not get ButtonPress when i press button. But I can get EnterNotify if i replace ButtonPressMask with EnterWindowMask. why ?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.x.org/archives/xorg-devel/attachments/20171029/df06e17d/attachment.html>


More information about the xorg-devel mailing list