MCPcopy Create free account
hub / github.com/VirtualGL/virtualgl / event_loop

Function event_loop

demos/glthreads.c:371–419  ·  view source on GitHub ↗

* The main process thread runs this loop. * Single display connection for all threads. */

Source from the content-addressed store, hash-verified

369 * Single display connection for all threads.
370 */
371static void
372event_loop(Display *dpy)
373{
374 XEvent event;
375 int i;
376
377 assert(!MultiDisplays);
378
379 while (!ExitFlag) {
380
381 while (1) {
382 int k;
383 LOCK(dpy);
384 k = XPending(dpy);
385 if (k) {
386 XNextEvent(dpy, &event);
387 UNLOCK(dpy);
388 break;
389 }
390 UNLOCK(dpy);
391 usleep(5000);
392 }
393
394 switch (event.type) {
395 case ConfigureNotify:
396 /* Find winthread for this event's window */
397 for (i = 0; i < NumWinThreads; i++) {
398 struct winthread *wt = &WinThreads[i];
399 if (event.xconfigure.window == wt->Win) {
400 resize(wt, event.xconfigure.width,
401 event.xconfigure.height);
402 break;
403 }
404 }
405 break;
406 case KeyPress:
407 for (i = 0; i < NumWinThreads; i++) {
408 struct winthread *wt = &WinThreads[i];
409 if (event.xkey.window == wt->Win) {
410 keypress(&event, wt);
411 break;
412 }
413 }
414 break;
415 default:
416 /*no-op*/ ;
417 }
418 }
419}
420
421
422/*

Callers 1

mainFunction · 0.70

Calls 3

XNextEventFunction · 0.85
resizeFunction · 0.70
keypressFunction · 0.70

Tested by

no test coverage detected