steamcompmgr: use poll() to wait for X11 events

References: https://github.com/Plagman/gamescope/issues/201
This commit is contained in:
Simon Ser 2021-06-09 17:22:53 +02:00
parent 08f41f2046
commit f51a05b2dc

View file

@ -3284,11 +3284,36 @@ steamcompmgr_main (int argc, char **argv)
std::thread imageWaitThread( imageWaitThreadMain );
imageWaitThread.detach();
struct pollfd x11_pollfd = {
.fd = XConnectionNumber(dpy),
.events = POLLIN,
};
for (;;)
{
focusDirty = False;
bool vblank = false;
if ( poll( &x11_pollfd, 1, -1 ) < 0)
{
if ( errno == EAGAIN )
continue;
perror( "poll failed" );
break;
}
if ( x11_pollfd.revents & POLLHUP )
{
fprintf( stderr, "Lost connection to the X11 server\n" );
break;
}
if ( !( x11_pollfd.revents & POLLIN ) )
{
continue;
}
do {
XNextEvent (dpy, &ev);
if ((ev.type & 0x7f) != KeymapNotify)