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?
Asked
Active
Viewed 1,317 times
2
-
Did you try calling this function in another (dedicated) thread? – egur Dec 10 '13 at 09:43
1 Answers
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 :
- XCheckTypedEvent();
- XCheckTypedWindowEvent();
- 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