| 520 | |
| 521 | |
| 522 | void fconfig_setdefaultsfromdpy(Display *dpy) |
| 523 | { |
| 524 | CriticalSection::SafeLock l(fcmutex); |
| 525 | |
| 526 | fconfig_setcompressfromdpy(dpy, fconfig); |
| 527 | |
| 528 | if(fconfig.port < 0) |
| 529 | { |
| 530 | fconfig.port = RR_DEFAULTPORT; |
| 531 | Atom atom = None; unsigned long n = 0, bytesLeft = 0; |
| 532 | int actualFormat = 0; Atom actualType = None; |
| 533 | unsigned char *prop = NULL; |
| 534 | if((atom = XInternAtom(dpy, "_VGLCLIENT_PORT", True)) != None) |
| 535 | { |
| 536 | if(XGetWindowProperty(dpy, RootWindow(dpy, DefaultScreen(dpy)), atom, 0, |
| 537 | 1, False, XA_INTEGER, &actualType, &actualFormat, &n, &bytesLeft, |
| 538 | &prop) == Success && n >= 1 && actualFormat == 16 |
| 539 | && actualType == XA_INTEGER && prop) |
| 540 | fconfig.port = *(unsigned short *)prop; |
| 541 | if(prop) _XFree(prop); |
| 542 | } |
| 543 | } |
| 544 | |
| 545 | #ifdef USEXV |
| 546 | |
| 547 | int k, port, nformats, dummy1, dummy2, dummy3; |
| 548 | unsigned int i, j, nadaptors = 0; |
| 549 | XvAdaptorInfo *ai = NULL; |
| 550 | XvImageFormatValues *ifv = NULL; |
| 551 | |
| 552 | if(_XQueryExtension(dpy, "XVideo", &dummy1, &dummy2, &dummy3) |
| 553 | && XvQueryAdaptors(dpy, DefaultRootWindow(dpy), &nadaptors, |
| 554 | &ai) == Success && nadaptors >= 1 && ai) |
| 555 | { |
| 556 | port = -1; |
| 557 | for(i = 0; i < nadaptors; i++) |
| 558 | { |
| 559 | for(j = ai[i].base_id; j < ai[i].base_id + ai[i].num_ports; j++) |
| 560 | { |
| 561 | nformats = 0; |
| 562 | ifv = XvListImageFormats(dpy, j, &nformats); |
| 563 | if(ifv && nformats > 0) |
| 564 | { |
| 565 | for(k = 0; k < nformats; k++) |
| 566 | { |
| 567 | if(ifv[k].id == 0x30323449) |
| 568 | { |
| 569 | _XFree(ifv); port = j; |
| 570 | goto found; |
| 571 | } |
| 572 | } |
| 573 | } |
| 574 | _XFree(ifv); |
| 575 | } |
| 576 | } |
| 577 | found: |
| 578 | XvFreeAdaptorInfo(ai); ai = NULL; |
| 579 | if(port != -1) fconfig.transvalid[RRTRANS_XV] = 1; |
no test coverage detected