Changeset 83934 in vbox
- Timestamp:
- Apr 22, 2020 7:12:40 PM (5 years ago)
- svn:sync-xref-src-repo-rev:
- 137483
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/x11/VBoxClient/display-svga-x11.cpp
r83933 r83934 39 39 * # The order of the outputs (monitors) is assumed to be the same in RANDROUTPUT array and 40 40 XRRScreenResources.outputs array. 41 * - This code does 2 related but separate things: 1- It resizes and enables/disables monitors upon host's 42 requests (see the infinite loop in run()). 2- it listens to RandR events (caused by this or any other X11 client) 43 on a different thread and notifies host about the new monitor positions. See sendMonitorPositions(...). This is 44 mainly work around since we have realized that vmsvga does not convey correct monitor positions thru FIFO. 41 45 */ 42 46 #include <stdio.h> … … 111 115 { 112 116 Display *pDisplay; 117 /* We use a separate connection for randr event listening for sharing a 118 single display object with resizing (main) and event listening threads ends up having a deadlock.*/ 119 Display *pDisplayRandRMonitoring; 113 120 Window rootWindow; 114 121 int iDefaultScreen; … … 499 506 XRRMonitorInfo *pMonitorInfo = NULL; 500 507 #ifdef WITH_DISTRO_XRAND_XINERAMA 501 pMonitorInfo = XRRGetMonitors(x11Context.pDisplay, DefaultRootWindow(x11Context.pDisplay), true, &iMonitorCount); 508 pMonitorInfo = XRRGetMonitors(x11Context.pDisplayRandRMonitoring, 509 DefaultRootWindow(x11Context.pDisplayRandRMonitoring), true, &iMonitorCount); 502 510 #else 503 511 if (x11Context.pXRRGetMonitors) 504 pMonitorInfo = x11Context.pXRRGetMonitors(x11Context.pDisplay, DefaultRootWindow(x11Context.pDisplay), true, &iMonitorCount); 512 pMonitorInfo = x11Context.pXRRGetMonitors(x11Context.pDisplayRandRMonitoring, 513 DefaultRootWindow(x11Context.pDisplayRandRMonitoring), true, &iMonitorCount); 505 514 #endif 506 515 if (!pMonitorInfo) … … 519 528 for (int i = 0; i < iMonitorCount; ++i) 520 529 { 521 int iMonitorID = getMonitorIdFromName(XGetAtomName(x11Context.pDisplay , pMonitorInfo[i].name)) - 1;530 int iMonitorID = getMonitorIdFromName(XGetAtomName(x11Context.pDisplayRandRMonitoring, pMonitorInfo[i].name)) - 1; 522 531 if (iMonitorID >= x11Context.hOutputCount || iMonitorID == -1) 523 532 continue; … … 543 552 { 544 553 XEvent event; 545 XNextEvent(x11Context.pDisplay , &event);554 XNextEvent(x11Context.pDisplayRandRMonitoring, &event); 546 555 int eventTypeOffset = event.type - x11Context.hRandREventBase; 547 556 switch (eventTypeOffset) … … 657 666 } 658 667 #ifdef WITH_DISTRO_XRAND_XINERAMA 659 XRRSelectInput(x11Context.pDisplay , x11Context.rootWindow, 0);668 XRRSelectInput(x11Context.pDisplayRandRMonitoring, x11Context.rootWindow, 0); 660 669 XRRFreeScreenResources(x11Context.pScreenResources); 661 670 #else 662 671 if (x11Context.pXRRSelectInput) 663 x11Context.pXRRSelectInput(x11Context.pDisplay , x11Context.rootWindow, 0);672 x11Context.pXRRSelectInput(x11Context.pDisplayRandRMonitoring, x11Context.rootWindow, 0); 664 673 if (x11Context.pXRRFreeScreenResources) 665 674 x11Context.pXRRFreeScreenResources(x11Context.pScreenResources); 666 675 #endif 667 676 XCloseDisplay(x11Context.pDisplay); 677 XCloseDisplay(x11Context.pDisplayRandRMonitoring); 668 678 } 669 679 … … 764 774 VBClLogFatalError("%s called with bad argument\n", __func__); 765 775 x11Context.pDisplay = XOpenDisplay(NULL); 776 x11Context.pDisplayRandRMonitoring = XOpenDisplay(NULL); 766 777 if (x11Context.pDisplay == NULL) 767 778 return; … … 770 781 { 771 782 XCloseDisplay(x11Context.pDisplay); 783 XCloseDisplay(x11Context.pDisplayRandRMonitoring); 772 784 x11Context.pDisplay = NULL; 785 x11Context.pDisplayRandRMonitoring = NULL; 773 786 return; 774 787 } … … 778 791 { 779 792 XCloseDisplay(x11Context.pDisplay); 793 XCloseDisplay(x11Context.pDisplayRandRMonitoring); 780 794 x11Context.pDisplay = NULL; 795 x11Context.pDisplayRandRMonitoring = NULL; 781 796 return; 782 797 } … … 813 828 /* Select the XEvent types we want to listen to. */ 814 829 #ifdef WITH_DISTRO_XRAND_XINERAMA 815 XRRSelectInput(x11Context.pDisplay , x11Context.rootWindow, x11Context.hEventMask);830 XRRSelectInput(x11Context.pDisplayRandRMonitoring, x11Context.rootWindow, x11Context.hEventMask); 816 831 #else 817 832 if (x11Context.pXRRSelectInput) 818 x11Context.pXRRSelectInput(x11Context.pDisplay , x11Context.rootWindow, x11Context.hEventMask);833 x11Context.pXRRSelectInput(x11Context.pDisplayRandRMonitoring, x11Context.rootWindow, x11Context.hEventMask); 819 834 #endif 820 835 x11Context.iDefaultScreen = DefaultScreen(x11Context.pDisplay);
Note:
See TracChangeset
for help on using the changeset viewer.