* Separate display connection for each thread. */
| 492 | * Separate display connection for each thread. |
| 493 | */ |
| 494 | static void |
| 495 | event_loop_multi(void) |
| 496 | { |
| 497 | XEvent event; |
| 498 | int w = 0; |
| 499 | |
| 500 | assert(MultiDisplays); |
| 501 | |
| 502 | while (!ExitFlag) { |
| 503 | struct winthread *wt = &WinThreads[w]; |
| 504 | if (XPending(wt->Dpy)) { |
| 505 | XNextEvent(wt->Dpy, &event); |
| 506 | switch (event.type) { |
| 507 | case ConfigureNotify: |
| 508 | resize(wt, event.xconfigure.width, event.xconfigure.height); |
| 509 | pthread_mutex_unlock(&wt->Ready); |
| 510 | break; |
| 511 | case MotionNotify: |
| 512 | if (event.xmotion.state & Button1Mask || |
| 513 | event.xmotion.state & Button2Mask || |
| 514 | event.xmotion.state & Button3Mask || |
| 515 | event.xmotion.state & Button4Mask || |
| 516 | event.xmotion.state & Button5Mask) { |
| 517 | wt->AngleX += (float) (event.xmotion.x - |
| 518 | wt->MotionStartX) / |
| 519 | (float) wt->WinWidth * 180.; |
| 520 | wt->AngleY += (float) (event.xmotion.y - |
| 521 | wt->MotionStartY) / |
| 522 | (float) wt->WinHeight * 180.; |
| 523 | wt->MotionStartX = event.xmotion.x; |
| 524 | wt->MotionStartY = event.xmotion.y; |
| 525 | } |
| 526 | pthread_mutex_unlock(&wt->Ready); |
| 527 | break; |
| 528 | case ButtonPress: |
| 529 | wt->MotionStartX = event.xbutton.x; |
| 530 | wt->MotionStartY = event.xbutton.y; |
| 531 | break; |
| 532 | case ButtonRelease: |
| 533 | case Expose: |
| 534 | pthread_mutex_unlock(&wt->Ready); |
| 535 | break; |
| 536 | case KeyPress: |
| 537 | keypress(&event, wt); |
| 538 | break; |
| 539 | default: |
| 540 | ; /* nop */ |
| 541 | } |
| 542 | } |
| 543 | w = (w + 1) % NumWinThreads; |
| 544 | usleep(5000); |
| 545 | } |
| 546 | } |
| 547 | |
| 548 | |
| 549 |
no test coverage detected