2

I need to get events from the X window system without pausing the execution of my program. Currently, I use XNextEvent(dpy, &xev) to get the events, but is there way to get events and run my own code simultaneously?

1 Answers1

2
while (XPending(dpy))
{
    XNextEvent(dpy, &e);
    switch (e.type) 
    {
        case Expose:
            break;
        // Manage events...
        default:
            break;
    }
}

XPending(Display *display) : Return the number of events in the Queue for the associated display.

You can remplace XNextEvent(dpy, &e); by one of this functions, for get events only for specified Window / Mask or the two at same time :

  1. XCheckTypedEvent();
  2. XCheckTypedWindowEvent();
  3. XcheckWindowEvent();

These 3functions are non-blocking. For exemple, if you want to fecth event for a specified Window only, you can do :

while (XcheckWindowEvent(dpy, window, your_event_mask, &e))
{
    switch (e.type) 
    {
        case Expose:
            break;
        // Manage events...
        default:
            break;
    }
}

PS : Sorry for my bad english

Thomas Leclercq
  • 425
  • 3
  • 10
  • Thank you. Do you know any function like these that do also apply to fullscreen applications? –  Dec 10 '13 at 19:47
  • These functions works well in Windows with FullScreen mode. Maybe you ask how to get a FullScreen window? – Thomas Leclercq Dec 11 '13 at 10:21