Changeset 83217 in vbox
- Timestamp:
- Mar 6, 2020 9:35:40 AM (5 years ago)
- svn:sync-xref-src-repo-rev:
- 136357
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/x11/VBoxClient/display-svga-x11.cpp
r83210 r83217 38 38 */ 39 39 #include <stdio.h> 40 #include <dlfcn.h> 40 41 #include "VBoxClient.h" 41 42 … … 54 55 55 56 #define OLD_JUNK 57 58 //#define DL_OPEN_RANDR 56 59 57 60 /** Maximum number of supported screens. DRM and X11 both limit this to 32. */ … … 114 117 int hOutputCount; 115 118 Window rootWindow; 119 void *pRandLibraryHandle; 120 void (*pXRRSelectInput) (Display *, Window, int); 121 Bool (*pXRRQueryExtension) (Display *, int *, int *); 122 Status (*pXRRQueryVersion) (Display *, int *, int*); 116 123 }; 117 124 … … 358 365 if (RT_FAILURE(startX11MonitorThread())) 359 366 return false; 367 #ifdef DL_OPEN_RANDR 368 if (x11Context.pXRRSelectInput) 369 x11Context.pXRRSelectInput(x11Context.pDisplay, x11Context.rootWindow, x11Context.hEventMask); 370 #else 360 371 XRRSelectInput(x11Context.pDisplay, x11Context.rootWindow, x11Context.hEventMask); 372 #endif 361 373 return true; 362 374 } … … 370 382 } 371 383 stopX11MonitorThread(); 384 if (x11Context.pRandLibraryHandle) 385 { 386 dlclose(x11Context.pRandLibraryHandle); 387 x11Context.pRandLibraryHandle = NULL; 388 } 389 #ifdef DL_OPEN_RANDR 390 if (x11Context.pXRRSelectInput) 391 x11Context.pXRRSelectInput(x11Context.pDisplay, x11Context.rootWindow, 0); 392 #else 372 393 XRRSelectInput(x11Context.pDisplay, x11Context.rootWindow, 0); 394 #endif 373 395 XCloseDisplay(x11Context.pDisplay); 374 396 } 397 398 #ifdef DL_OPEN_RANDR 399 static int openLibRandR() 400 { 401 x11Context.pRandLibraryHandle = dlopen("/usr/lib/x86_64-linux-gnu/libXrandr.so", RTLD_LAZY /*| RTLD_LOCAL */); 402 403 if (!x11Context.pRandLibraryHandle) 404 { 405 VBClLogFatalError("Could not locate libXranr for dlopen\n"); 406 return VERR_NOT_FOUND; 407 } 408 409 x11Context.pXRRSelectInput = (void (*)(Display*, Window, int)) 410 dlsym(x11Context.pRandLibraryHandle, "XRRSelectInput"); 411 if (!x11Context.pXRRSelectInput) 412 { 413 VBClLogFatalError("Could not find address for the symbol XRRSelectInput\n"); 414 dlclose(x11Context.pRandLibraryHandle); 415 x11Context.pRandLibraryHandle = NULL; 416 return VERR_NOT_FOUND; 417 } 418 x11Context.pXRRQueryExtension = (Bool (*)(Display *, int *, int *)) 419 dlsym(x11Context.pRandLibraryHandle, "XRRQueryExtension"); 420 if (!x11Context.pXRRQueryExtension) 421 { 422 VBClLogFatalError("Could not find address for the symbol XRRQueryExtension\n"); 423 dlclose(x11Context.pRandLibraryHandle); 424 x11Context.pRandLibraryHandle = NULL; 425 return VERR_NOT_FOUND; 426 } 427 x11Context.pXRRQueryVersion = (Status (*)(Display *, int *, int*)) 428 dlsym(x11Context.pRandLibraryHandle, "XRRQueryVersion"); 429 if (!x11Context.pXRRQueryVersion) 430 { 431 VBClLogFatalError("Could not find address for the symbol XRRQueryVersion\n"); 432 dlclose(x11Context.pRandLibraryHandle); 433 x11Context.pRandLibraryHandle = NULL; 434 return VERR_NOT_FOUND; 435 } 436 return VINF_SUCCESS; 437 } 438 #endif 375 439 376 440 static void x11Connect() … … 389 453 return; 390 454 } 391 if (!XRRQueryExtension(x11Context.pDisplay, &x11Context.hRandREventBase, &x11Context.hRandRErrorBase)) 392 { 393 XCloseDisplay(x11Context.pDisplay); 394 x11Context.pDisplay = NULL; 395 return; 396 } 397 if (!XRRQueryVersion(x11Context.pDisplay, &x11Context.hRandRMajor, &x11Context.hRandRMinor)) 398 { 399 XCloseDisplay(x11Context.pDisplay); 400 x11Context.pDisplay = NULL; 401 return; 455 bool fSuccess = false; 456 #ifdef DL_OPEN_RANDR 457 if (x11Context.pXRRQueryExtension) 458 fSuccess = x11Context.pXRRQueryExtension(x11Context.pDisplay, &x11Context.hRandREventBase, &x11Context.hRandRErrorBase); 459 #else 460 fSuccess = XRRQueryExtension(x11Context.pDisplay, &x11Context.hRandREventBase, &x11Context.hRandRErrorBase); 461 #endif 462 if (fSuccess) 463 { 464 fSuccess = false; 465 #ifdef DL_OPEN_RANDR 466 if (x11Context.pXRRQueryVersion) 467 fSuccess = x11Context.pXRRQueryVersion(x11Context.pDisplay, &x11Context.hRandRMajor, &x11Context.hRandRMinor); 468 #else 469 fSuccess = XRRQueryVersion(x11Context.pDisplay, &x11Context.hRandRMajor, &x11Context.hRandRMinor); 470 #endif 471 if (!fSuccess) 472 { 473 XCloseDisplay(x11Context.pDisplay); 474 x11Context.pDisplay = NULL; 475 return; 476 } 402 477 } 403 478 x11Context.hEventMask = 0; … … 411 486 x11Context.rootWindow = DefaultRootWindow(x11Context.pDisplay); 412 487 x11Context.hOutputCount = determineOutputCount(); 488 x11Context.pXRRSelectInput = NULL; 489 x11Context.pRandLibraryHandle = NULL; 490 x11Context.pXRRQueryExtension = NULL; 491 x11Context.pXRRQueryVersion = NULL; 492 #ifdef DL_OPEN_RANDR 493 if (openLibRandR() != VINF_SUCCESS) 494 { 495 XCloseDisplay(x11Context.pDisplay); 496 x11Context.pDisplay = NULL; 497 return; 498 } 499 #endif 413 500 } 414 501
Note:
See TracChangeset
for help on using the changeset viewer.