- Timestamp:
- May 5, 2023 10:07:31 AM (17 months ago)
- File:
-
- 1 edited
-
trunk/src/VBox/GuestHost/DisplayServerType.cpp (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/GuestHost/DisplayServerType.cpp
r99620 r99627 82 82 83 83 /* Try to connect to the wayland display, assuming it succeeds only when a wayland compositor is active: */ 84 void *pWaylandDisplay = NULL;84 bool fHasWayland = false; 85 85 RTLDRMOD hWaylandClient = NIL_RTLDRMOD; 86 86 int rc = RTLdrLoadSystem("libwayland-client.so", /* fNoUnload = */ true, &hWaylandClient); … … 88 88 { 89 89 void * (*pWaylandDisplayConnect)(const char *); 90 void (*pWaylandDisplayDisconnect)(void *); 90 91 rc = RTLdrGetSymbol(hWaylandClient, "wl_display_connect", (void **)&pWaylandDisplayConnect); 91 if ( RT_SUCCESS(rc) 92 && pWaylandDisplayConnect) 93 pWaylandDisplay = pWaylandDisplayConnect(NULL); 92 if (RT_SUCCESS(rc)) 93 rc = RTLdrGetSymbol(hWaylandClient, "wl_display_disconnect", (void **)&pWaylandDisplayDisconnect); 94 if (RT_SUCCESS(rc)) 95 { 96 AssertPtrReturn(pWaylandDisplayConnect, VBGHDISPLAYSERVERTYPE_NONE); 97 AssertPtrReturn(pWaylandDisplayDisconnect, VBGHDISPLAYSERVERTYPE_NONE); 98 void *pDisplay = pWaylandDisplayConnect(NULL); 99 if (pDisplay) 100 { 101 fHasWayland = true; 102 pWaylandDisplayDisconnect(pDisplay); 103 } 104 } 94 105 RTLdrClose(hWaylandClient); 95 106 } 96 107 97 108 /* Also try to connect to the default X11 display to determine if Xserver is running: */ 98 void *pXDisplay = NULL;99 RTLDRMOD hX11 = NIL_RTLDRMOD;109 bool fHasX = false; 110 RTLDRMOD hX11 = NIL_RTLDRMOD; 100 111 rc = RTLdrLoadSystem("libX11.so", /* fNoUnload = */ true, &hX11); 101 112 if (RT_SUCCESS(rc)) 102 113 { 103 114 void * (*pfnOpenDisplay)(const char *); 115 int (*pfnCloseDisplay)(void *); 104 116 rc = RTLdrGetSymbol(hX11, "XOpenDisplay", (void **)&pfnOpenDisplay); 105 if ( RT_SUCCESS(rc) 106 && pfnOpenDisplay) 107 pXDisplay = pfnOpenDisplay(NULL); 117 if (RT_SUCCESS(rc)) 118 rc = RTLdrGetSymbol(hX11, "XCloseDisplay", (void **)&pfnCloseDisplay); 119 120 if (RT_SUCCESS(rc)) 121 { 122 AssertPtrReturn(pfnOpenDisplay, VBGHDISPLAYSERVERTYPE_NONE); 123 AssertPtrReturn(pfnCloseDisplay, VBGHDISPLAYSERVERTYPE_NONE); 124 void *pDisplay = pfnOpenDisplay(NULL); 125 if (pDisplay) 126 { 127 fHasX = true; 128 pfnCloseDisplay(pDisplay); 129 } 130 } 131 108 132 RTLdrClose(hX11); 109 133 } … … 111 135 /* If both wayland and X11 display can be connected then we should have XWayland: */ 112 136 VBGHDISPLAYSERVERTYPE retSessionType = VBGHDISPLAYSERVERTYPE_NONE; 113 if ( pWaylandDisplay && pXDisplay)137 if (fHasWayland && fHasX) 114 138 retSessionType = VBGHDISPLAYSERVERTYPE_XWAYLAND; 115 else if ( pWaylandDisplay && !pXDisplay)139 else if (fHasWayland) 116 140 retSessionType = VBGHDISPLAYSERVERTYPE_WAYLAND; 117 else if ( !pWaylandDisplay && pXDisplay)141 else if (fHasX) 118 142 retSessionType = VBGHDISPLAYSERVERTYPE_X11; 119 143
Note:
See TracChangeset
for help on using the changeset viewer.

