Changeset 21760 in vbox
- Timestamp:
- Jul 22, 2009 9:50:37 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/main.cpp
r21598 r21760 45 45 #include <QLocale> 46 46 #include <QTranslator> 47 48 #include <X11/Xlib.h> 47 49 48 50 #include <iprt/err.h> … … 325 327 { 326 328 #ifdef Q_WS_X11 327 /* There are some buggy/strange driver/compiz combinations which lead 328 * to transparent backgrounds on ARGB visuals. Try to fix it by not 329 * allowing an ARGB visual with the help of the Xlib. After that we 330 * restore the original environment, so that others like the OpenGL 331 * service will proper work. */ 332 char *pchOldVar = NULL; 333 bool fHackARGB = !RTEnvExist ("VBOX_NO_ARGB_VISUALS_HACK"); 334 if (fHackARGB) 329 /* Qt has a complex algorithm for selecting the right visual which 330 * doesn't always seem to work. So we naively choose a visual - the 331 * default one - ourselves and pass that to Qt. This means that we 332 * also have to open the display ourselves. 333 * We check the Qt parameter list and handle Qt's -display argument 334 * ourselves, since we open the display connection. We also check the 335 * to see if the user has passed Qt's -visual parameter, and if so we 336 * assume that the user wants Qt to handle visual selection after all, 337 * and don't supply a visual. */ 338 char *pszDisplay = NULL; 339 bool useDefaultVisual = true; 340 for (int i = 0; i < argc; ++i) 335 341 { 336 const char *pchVar = RTEnvGet ("XLIB_SKIP_ARGB_VISUALS"); 337 if (pchVar) 338 pchOldVar = RTStrDup (pchVar); 339 RTEnvSet ("XLIB_SKIP_ARGB_VISUALS", "1"); 342 if (!::strcmp(argv[i], "-display") && (i + 1 < argc)) 343 /* What if it isn't? Rely on QApplication to complain? */ 344 { 345 pszDisplay = argv[i + 1]; 346 ++i; 347 } 348 else if (!::strcmp(argv[i], "-visual")) 349 useDefaultVisual = false; 340 350 } 351 Display *pDisplay = XOpenDisplay(pszDisplay); 352 if (!pDisplay) 353 { 354 RTPrintf(pszDisplay ? "Failed to open the X11 display \"%s\"!\n" 355 : "Failed to open the X11 display!\n", 356 pszDisplay); 357 return 0; 358 } 359 Visual *pVisual = useDefaultVisual 360 ? DefaultVisual(pDisplay, DefaultScreen(pDisplay)) 361 : NULL; 341 362 /* Now create the application object */ 342 QIApplication a (argc, argv); 343 /* Restore previous environment */ 344 if (fHackARGB) 345 { 346 if (pchOldVar) 347 { 348 RTEnvSet ("XLIB_SKIP_ARGB_VISUALS", pchOldVar); 349 RTStrFree (pchOldVar); 350 } 351 else 352 RTEnvUnset ("XLIB_SKIP_ARGB_VISUALS"); 353 } 363 QIApplication a (pDisplay, argc, argv, (Qt::HANDLE) pVisual); 354 364 #else /* Q_WS_X11 */ 355 365 QIApplication a (argc, argv);
Note:
See TracChangeset
for help on using the changeset viewer.