Changeset 94306 in vbox for trunk/src/VBox
- Timestamp:
- Mar 18, 2022 12:15:30 PM (3 years ago)
- Location:
- trunk/src/VBox/Additions/x11/VBoxClient
- Files:
-
- 4 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/x11/VBoxClient/Makefile.kmk
r93469 r94306 127 127 VBoxClient_DEFS += VBOX_WITH_VMSVGA 128 128 VBoxClient_SOURCES += \ 129 display.cpp \ 129 130 display-svga-x11.cpp 130 131 VBoxClient_SOURCES.linux += \ -
trunk/src/VBox/Additions/x11/VBoxClient/VBoxClient.h
r93551 r94306 118 118 extern VBCLSERVICE g_SvcDisplayDRM; 119 119 extern VBCLSERVICE g_SvcDisplaySVGA; 120 extern VBCLSERVICE g_SvcDisplayLegacy; 120 121 # ifdef RT_OS_LINUX 121 122 extern VBCLSERVICE g_SvcDisplaySVGASession; -
trunk/src/VBox/Additions/x11/VBoxClient/display-svga-x11.cpp
r93115 r94306 211 211 do { \ 212 212 if (!pFunction) \ 213 VBClLog FatalError("Could not find symbol address (%s)\n", #pFunction);\213 VBClLogError("Could not find symbol address (%s)\n", #pFunction);\ 214 214 } while (0) 215 215 … … 851 851 852 852 *(void **)(&x11Context.pXRRGetScreenResources) = dlsym(x11Context.pRandLibraryHandle, "XRRGetScreenResources"); 853 checkFunctionPtr Return(x11Context.pXRRGetScreenResources);853 checkFunctionPtr(x11Context.pXRRGetScreenResources); 854 854 855 855 *(void **)(&x11Context.pXRRSetCrtcConfig) = dlsym(x11Context.pRandLibraryHandle, "XRRSetCrtcConfig"); 856 checkFunctionPtr Return(x11Context.pXRRSetCrtcConfig);856 checkFunctionPtr(x11Context.pXRRSetCrtcConfig); 857 857 858 858 *(void **)(&x11Context.pXRRFreeScreenResources) = dlsym(x11Context.pRandLibraryHandle, "XRRFreeScreenResources"); 859 checkFunctionPtr Return(x11Context.pXRRFreeScreenResources);859 checkFunctionPtr(x11Context.pXRRFreeScreenResources); 860 860 861 861 *(void **)(&x11Context.pXRRFreeModeInfo) = dlsym(x11Context.pRandLibraryHandle, "XRRFreeModeInfo"); 862 checkFunctionPtr Return(x11Context.pXRRFreeModeInfo);862 checkFunctionPtr(x11Context.pXRRFreeModeInfo); 863 863 864 864 *(void **)(&x11Context.pXRRFreeOutputInfo) = dlsym(x11Context.pRandLibraryHandle, "XRRFreeOutputInfo"); 865 checkFunctionPtr Return(x11Context.pXRRFreeOutputInfo);865 checkFunctionPtr(x11Context.pXRRFreeOutputInfo); 866 866 867 867 *(void **)(&x11Context.pXRRSetScreenSize) = dlsym(x11Context.pRandLibraryHandle, "XRRSetScreenSize"); 868 checkFunctionPtr Return(x11Context.pXRRSetScreenSize);868 checkFunctionPtr(x11Context.pXRRSetScreenSize); 869 869 870 870 *(void **)(&x11Context.pXRRUpdateConfiguration) = dlsym(x11Context.pRandLibraryHandle, "XRRUpdateConfiguration"); 871 checkFunctionPtr Return(x11Context.pXRRUpdateConfiguration);871 checkFunctionPtr(x11Context.pXRRUpdateConfiguration); 872 872 873 873 *(void **)(&x11Context.pXRRAllocModeInfo) = dlsym(x11Context.pRandLibraryHandle, "XRRAllocModeInfo"); 874 checkFunctionPtr Return(x11Context.pXRRAllocModeInfo);874 checkFunctionPtr(x11Context.pXRRAllocModeInfo); 875 875 876 876 *(void **)(&x11Context.pXRRCreateMode) = dlsym(x11Context.pRandLibraryHandle, "XRRCreateMode"); 877 checkFunctionPtr Return(x11Context.pXRRCreateMode);877 checkFunctionPtr(x11Context.pXRRCreateMode); 878 878 879 879 *(void **)(&x11Context.pXRRGetOutputInfo) = dlsym(x11Context.pRandLibraryHandle, "XRRGetOutputInfo"); 880 checkFunctionPtr Return(x11Context.pXRRGetOutputInfo);880 checkFunctionPtr(x11Context.pXRRGetOutputInfo); 881 881 882 882 *(void **)(&x11Context.pXRRGetCrtcInfo) = dlsym(x11Context.pRandLibraryHandle, "XRRGetCrtcInfo"); 883 checkFunctionPtr Return(x11Context.pXRRGetCrtcInfo);883 checkFunctionPtr(x11Context.pXRRGetCrtcInfo); 884 884 885 885 *(void **)(&x11Context.pXRRFreeCrtcInfo) = dlsym(x11Context.pRandLibraryHandle, "XRRFreeCrtcInfo"); 886 checkFunctionPtr Return(x11Context.pXRRFreeCrtcInfo);886 checkFunctionPtr(x11Context.pXRRFreeCrtcInfo); 887 887 888 888 *(void **)(&x11Context.pXRRAddOutputMode) = dlsym(x11Context.pRandLibraryHandle, "XRRAddOutputMode"); 889 checkFunctionPtr Return(x11Context.pXRRAddOutputMode);889 checkFunctionPtr(x11Context.pXRRAddOutputMode); 890 890 891 891 *(void **)(&x11Context.pXRRSetOutputPrimary) = dlsym(x11Context.pRandLibraryHandle, "XRRSetOutputPrimary"); 892 checkFunctionPtr Return(x11Context.pXRRSetOutputPrimary);892 checkFunctionPtr(x11Context.pXRRSetOutputPrimary); 893 893 894 894 return VINF_SUCCESS; … … 974 974 if (x11Context.hRandRMajor < 1 || x11Context.hRandRMinor <= 3) 975 975 { 976 VBClLog FatalError("Resizing service requires libXrandr Version >= 1.4. Detected version is %d.%d\n", x11Context.hRandRMajor, x11Context.hRandRMinor);976 VBClLogError("Resizing service requires libXrandr Version >= 1.4. Detected version is %d.%d\n", x11Context.hRandRMajor, x11Context.hRandRMinor); 977 977 XCloseDisplay(x11Context.pDisplay); 978 978 x11Context.pDisplay = NULL; 979 980 int rc = VbglR3DrmLegacyX11AgentStart(); 981 VBClLogInfo("Attempt to start legacy X11 resize agent, rc=%Rrc\n", rc); 982 979 983 return; 980 984 } -
trunk/src/VBox/Additions/x11/VBoxClient/display.cpp
r83217 r94306 36 36 #include <poll.h> 37 37 #include <time.h> 38 #include <dlfcn.h> 38 39 39 40 /* TESTING: Dynamic resizing and mouse integration toggling should work … … 43 44 * resizing and cursor integration, switching back should re-enable them. */ 44 45 45 /** Display magic number, start of a UUID. */46 #define DISPLAYSTATE_MAGIC UINT32_C(0xf0029993)47 48 46 /** State information needed for the service. The main VBoxClient code provides 49 47 * the daemon logic needed by all services. */ 50 48 struct DISPLAYSTATE 51 49 { 52 /** The service interface. */53 struct VBCLSERVICE *pInterface;54 /** Magic number for sanity checks. */55 uint32_t magic;56 50 /** Are we initialised yet? */ 57 51 bool mfInit; … … 69 63 * if so, have we waited for a reasonable time? */ 70 64 time_t timeLastModeHint; 65 /** Handle to libXrandr. */ 66 void *pRandLibraryHandle; 67 /** Handle to pXRRSelectInput. */ 68 void (*pXRRSelectInput) (Display *, Window, int); 69 /** Handle to pXRRQueryExtension. */ 70 Bool (*pXRRQueryExtension) (Display *, int *, int *); 71 71 }; 72 73 static struct DISPLAYSTATE g_DisplayState; 72 74 73 75 static unsigned char *getRootProperty(struct DISPLAYSTATE *pState, const char *pszName, … … 143 145 XSelectInput(pDisplay, DefaultRootWindow(pDisplay), PropertyChangeMask | StructureNotifyMask); 144 146 if (pState->fHaveRandR12) 145 XRRSelectInput(pDisplay, DefaultRootWindow(pDisplay), RRScreenChangeNotifyMask);147 pState->pXRRSelectInput(pDisplay, DefaultRootWindow(pDisplay), RRScreenChangeNotifyMask); 146 148 /* Semantics: when VBOXCLIENT_STARTED is set, pre-1.3 X.Org Server driver 147 149 * assumes that a client capable of handling mode hints will be present for the … … 203 205 int status; 204 206 207 pState->pRandLibraryHandle = dlopen("libXrandr.so", RTLD_LAZY /*| RTLD_LOCAL */); 208 if (!pState->pRandLibraryHandle) 209 pState->pRandLibraryHandle = dlopen("libXrandr.so.2", RTLD_LAZY /*| RTLD_LOCAL */); 210 if (!pState->pRandLibraryHandle) 211 pState->pRandLibraryHandle = dlopen("libXrandr.so.2.2.0", RTLD_LAZY /*| RTLD_LOCAL */); 212 213 if (!RT_VALID_PTR(pState->pRandLibraryHandle)) 214 { 215 VBClLogFatalError("Could not locate libXrandr for dlopen\n"); 216 return VERR_NOT_FOUND; 217 } 218 219 *(void **)(&pState->pXRRSelectInput) = dlsym(pState->pRandLibraryHandle, "XRRSelectInput"); 220 *(void **)(&pState->pXRRQueryExtension) = dlsym(pState->pRandLibraryHandle, "XRRQueryExtension"); 221 222 if ( !RT_VALID_PTR(pState->pXRRSelectInput) 223 || !RT_VALID_PTR(pState->pXRRQueryExtension)) 224 { 225 VBClLogFatalError("Could not load required libXrandr symbols\n"); 226 dlclose(pState->pRandLibraryHandle); 227 pState->pRandLibraryHandle = NULL; 228 return VERR_NOT_FOUND; 229 } 230 205 231 pState->pDisplay = XOpenDisplay(NULL); 206 232 if (!pState->pDisplay) 207 233 return VERR_NOT_FOUND; 208 if (! XRRQueryExtension(pState->pDisplay, &pState->cRREventBase, &status))234 if (!pState->pXRRQueryExtension(pState->pDisplay, &pState->cRREventBase, &status)) 209 235 return VERR_NOT_FOUND; 210 236 pState->fHaveRandR12 = false; … … 222 248 } 223 249 224 static const char *getName() 225 { 226 return "Display"; 227 } 228 229 static const char *getPidFilePath() 230 { 231 return ".vboxclient-display.pid"; 232 } 233 234 static struct DISPLAYSTATE *getStateFromInterface(struct VBCLSERVICE **ppInterface) 235 { 236 struct DISPLAYSTATE *pSelf = (struct DISPLAYSTATE *)ppInterface; 237 if (pSelf->magic != DISPLAYSTATE_MAGIC) 238 VBClLogFatalError("Bad display service object!\n"); 239 return pSelf; 240 } 241 242 static int init(struct VBCLSERVICE **ppInterface) 243 { 244 struct DISPLAYSTATE *pSelf = getStateFromInterface(ppInterface); 250 /** 251 * @interface_method_impl{VBCLSERVICE,pfnInit} 252 */ 253 static DECLCALLBACK(int) init(void) 254 { 255 struct DISPLAYSTATE *pSelf = &g_DisplayState; 245 256 int rc; 246 257 … … 255 266 } 256 267 257 static int run(struct VBCLSERVICE **ppInterface, bool fDaemonised) 258 { 259 RT_NOREF1(fDaemonised); 260 struct DISPLAYSTATE *pSelf = getStateFromInterface(ppInterface); 268 /** 269 * @interface_method_impl{VBCLSERVICE,pfnWorker} 270 */ 271 static DECLCALLBACK(int) run(bool volatile *) 272 { 273 struct DISPLAYSTATE *pSelf = &g_DisplayState; 261 274 262 275 if (!pSelf->mfInit) … … 266 279 } 267 280 268 struct VBCLSERVICE vbclDisplayInterface = 269 { 270 getName, 271 getPidFilePath, 272 init, 273 run, 274 VBClServiceDefaultCleanup 281 VBCLSERVICE g_SvcDisplayLegacy = 282 { 283 "dp-legacy-x11", /* szName */ 284 "Legacy display assistant", /* pszDescription */ 285 ".vboxclient-display.pid", /* pszPidFilePath (no pid file lock) */ 286 NULL, /* pszUsage */ 287 NULL, /* pszOptions */ 288 NULL, /* pfnOption */ 289 init, /* pfnInit */ 290 run, /* pfnWorker */ 291 NULL, /* pfnStop */ 292 NULL, /* pfnTerm */ 275 293 }; 276 277 struct VBCLSERVICE **VBClGetDisplayService()278 {279 struct DISPLAYSTATE *pService = (struct DISPLAYSTATE *)RTMemAlloc(sizeof(*pService));280 281 if (!pService)282 VBClLogFatalError("Out of memory\n");283 pService->pInterface = &vbclDisplayInterface;284 pService->magic = DISPLAYSTATE_MAGIC;285 pService->mfInit = false;286 return &pService->pInterface;287 } -
trunk/src/VBox/Additions/x11/VBoxClient/main.cpp
r93551 r94306 51 51 #define VBOXCLIENT_OPT_VMSVGA VBOXCLIENT_OPT_SERVICES + 4 52 52 #define VBOXCLIENT_OPT_VMSVGA_SESSION VBOXCLIENT_OPT_SERVICES + 5 53 #define VBOXCLIENT_OPT_DISPLAY VBOXCLIENT_OPT_SERVICES + 6 53 54 54 55 … … 289 290 RTPrintf(" --vmsvga-session an alias for --vmsvga\n"); 290 291 #endif 292 RTPrintf(" --display starts VMSVGA dynamic resizing for legacy guests\n"); 291 293 #endif 292 294 RTPrintf(" -f, --foreground run in the foreground (no daemonizing)\n"); … … 389 391 { "--vmsvga", VBOXCLIENT_OPT_VMSVGA, RTGETOPT_REQ_NOTHING }, 390 392 { "--vmsvga-session", VBOXCLIENT_OPT_VMSVGA_SESSION, RTGETOPT_REQ_NOTHING }, 393 { "--display", VBOXCLIENT_OPT_DISPLAY, RTGETOPT_REQ_NOTHING }, 391 394 #endif 392 395 }; … … 509 512 g_Service.pDesc = &g_SvcDisplaySVGA; 510 513 # endif 514 break; 515 } 516 517 case VBOXCLIENT_OPT_DISPLAY: 518 { 519 if (g_Service.pDesc) 520 return vbclSyntaxOnlyOneService(); 521 g_Service.pDesc = &g_SvcDisplayLegacy; 511 522 break; 512 523 }
Note:
See TracChangeset
for help on using the changeset viewer.