[tests] Improve startup of Xwayland server
Instead of performing dispatchEvents for a hard coded number of expected events from Xwayland, we use select on the pipe to figure out whether Xwayland has started writing the display number. As long as select does not indicate that the pipe is ready we need to dispatch further events.
This commit is contained in:
parent
2b133eccfd
commit
97756ff872
1 changed files with 8 additions and 3 deletions
|
@ -99,10 +99,15 @@ int main(int argc, char **argv)
|
|||
exit(1);
|
||||
}
|
||||
|
||||
// need four roundtrips to dispatch events
|
||||
for (int i = 0; i < 5; i++) {
|
||||
fd_set rfds;
|
||||
struct timeval tv;
|
||||
tv.tv_sec = 0;
|
||||
tv.tv_usec = 0;
|
||||
do {
|
||||
display.dispatchEvents(1000);
|
||||
}
|
||||
FD_ZERO(&rfds);
|
||||
FD_SET(pipe, &rfds);
|
||||
} while (select(pipe + 1, &rfds, NULL, NULL, &tv) == 0);
|
||||
|
||||
// now Xwayland is ready and we can read the pipe to get the display
|
||||
readDisplayFromPipe(pipe);
|
||||
|
|
Loading…
Reference in a new issue