steamcompmgr: use poll() to wait for X11 events
References: https://github.com/Plagman/gamescope/issues/201
This commit is contained in:
parent
08f41f2046
commit
f51a05b2dc
1 changed files with 25 additions and 0 deletions
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue