VirtualBox

Changeset 94306 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Mar 18, 2022 12:15:30 PM (3 years ago)
Author:
vboxsync
Message:

Additions: X11: partly restore legacy X11 resize service removed in r136358, bugref:10199.

In this commit, lagacy X11 resize service 'VBoxClient --display' is restored. This service
will be started as a fallback if 'VBoxClient --vmsvga' service will fail to start. This commit
restores guest screen resize functionality for old X11 guests (currently only Linux) which have
libXrandr older than 1.4 installed in the system.

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  
    127127 VBoxClient_DEFS    += VBOX_WITH_VMSVGA
    128128 VBoxClient_SOURCES += \
     129        display.cpp \
    129130        display-svga-x11.cpp
    130131 VBoxClient_SOURCES.linux += \
  • trunk/src/VBox/Additions/x11/VBoxClient/VBoxClient.h

    r93551 r94306  
    118118extern VBCLSERVICE g_SvcDisplayDRM;
    119119extern VBCLSERVICE g_SvcDisplaySVGA;
     120extern VBCLSERVICE g_SvcDisplayLegacy;
    120121# ifdef RT_OS_LINUX
    121122extern VBCLSERVICE g_SvcDisplaySVGASession;
  • trunk/src/VBox/Additions/x11/VBoxClient/display-svga-x11.cpp

    r93115 r94306  
    211211    do { \
    212212        if (!pFunction) \
    213             VBClLogFatalError("Could not find symbol address (%s)\n", #pFunction);\
     213            VBClLogError("Could not find symbol address (%s)\n", #pFunction);\
    214214    } while (0)
    215215
     
    851851
    852852    *(void **)(&x11Context.pXRRGetScreenResources) = dlsym(x11Context.pRandLibraryHandle, "XRRGetScreenResources");
    853     checkFunctionPtrReturn(x11Context.pXRRGetScreenResources);
     853    checkFunctionPtr(x11Context.pXRRGetScreenResources);
    854854
    855855    *(void **)(&x11Context.pXRRSetCrtcConfig) = dlsym(x11Context.pRandLibraryHandle, "XRRSetCrtcConfig");
    856     checkFunctionPtrReturn(x11Context.pXRRSetCrtcConfig);
     856    checkFunctionPtr(x11Context.pXRRSetCrtcConfig);
    857857
    858858    *(void **)(&x11Context.pXRRFreeScreenResources) = dlsym(x11Context.pRandLibraryHandle, "XRRFreeScreenResources");
    859     checkFunctionPtrReturn(x11Context.pXRRFreeScreenResources);
     859    checkFunctionPtr(x11Context.pXRRFreeScreenResources);
    860860
    861861    *(void **)(&x11Context.pXRRFreeModeInfo) = dlsym(x11Context.pRandLibraryHandle, "XRRFreeModeInfo");
    862     checkFunctionPtrReturn(x11Context.pXRRFreeModeInfo);
     862    checkFunctionPtr(x11Context.pXRRFreeModeInfo);
    863863
    864864    *(void **)(&x11Context.pXRRFreeOutputInfo) = dlsym(x11Context.pRandLibraryHandle, "XRRFreeOutputInfo");
    865     checkFunctionPtrReturn(x11Context.pXRRFreeOutputInfo);
     865    checkFunctionPtr(x11Context.pXRRFreeOutputInfo);
    866866
    867867    *(void **)(&x11Context.pXRRSetScreenSize) = dlsym(x11Context.pRandLibraryHandle, "XRRSetScreenSize");
    868     checkFunctionPtrReturn(x11Context.pXRRSetScreenSize);
     868    checkFunctionPtr(x11Context.pXRRSetScreenSize);
    869869
    870870    *(void **)(&x11Context.pXRRUpdateConfiguration) = dlsym(x11Context.pRandLibraryHandle, "XRRUpdateConfiguration");
    871     checkFunctionPtrReturn(x11Context.pXRRUpdateConfiguration);
     871    checkFunctionPtr(x11Context.pXRRUpdateConfiguration);
    872872
    873873    *(void **)(&x11Context.pXRRAllocModeInfo) = dlsym(x11Context.pRandLibraryHandle, "XRRAllocModeInfo");
    874     checkFunctionPtrReturn(x11Context.pXRRAllocModeInfo);
     874    checkFunctionPtr(x11Context.pXRRAllocModeInfo);
    875875
    876876    *(void **)(&x11Context.pXRRCreateMode) = dlsym(x11Context.pRandLibraryHandle, "XRRCreateMode");
    877     checkFunctionPtrReturn(x11Context.pXRRCreateMode);
     877    checkFunctionPtr(x11Context.pXRRCreateMode);
    878878
    879879    *(void **)(&x11Context.pXRRGetOutputInfo) = dlsym(x11Context.pRandLibraryHandle, "XRRGetOutputInfo");
    880     checkFunctionPtrReturn(x11Context.pXRRGetOutputInfo);
     880    checkFunctionPtr(x11Context.pXRRGetOutputInfo);
    881881
    882882    *(void **)(&x11Context.pXRRGetCrtcInfo) = dlsym(x11Context.pRandLibraryHandle, "XRRGetCrtcInfo");
    883     checkFunctionPtrReturn(x11Context.pXRRGetCrtcInfo);
     883    checkFunctionPtr(x11Context.pXRRGetCrtcInfo);
    884884
    885885    *(void **)(&x11Context.pXRRFreeCrtcInfo) = dlsym(x11Context.pRandLibraryHandle, "XRRFreeCrtcInfo");
    886     checkFunctionPtrReturn(x11Context.pXRRFreeCrtcInfo);
     886    checkFunctionPtr(x11Context.pXRRFreeCrtcInfo);
    887887
    888888    *(void **)(&x11Context.pXRRAddOutputMode) = dlsym(x11Context.pRandLibraryHandle, "XRRAddOutputMode");
    889     checkFunctionPtrReturn(x11Context.pXRRAddOutputMode);
     889    checkFunctionPtr(x11Context.pXRRAddOutputMode);
    890890
    891891    *(void **)(&x11Context.pXRRSetOutputPrimary) = dlsym(x11Context.pRandLibraryHandle, "XRRSetOutputPrimary");
    892     checkFunctionPtrReturn(x11Context.pXRRSetOutputPrimary);
     892    checkFunctionPtr(x11Context.pXRRSetOutputPrimary);
    893893
    894894    return VINF_SUCCESS;
     
    974974        if (x11Context.hRandRMajor < 1 || x11Context.hRandRMinor <= 3)
    975975        {
    976             VBClLogFatalError("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);
    977977            XCloseDisplay(x11Context.pDisplay);
    978978            x11Context.pDisplay = NULL;
     979
     980            int rc = VbglR3DrmLegacyX11AgentStart();
     981            VBClLogInfo("Attempt to start legacy X11 resize agent, rc=%Rrc\n", rc);
     982
    979983            return;
    980984        }
  • trunk/src/VBox/Additions/x11/VBoxClient/display.cpp

    r83217 r94306  
    3636#include <poll.h>
    3737#include <time.h>
     38#include <dlfcn.h>
    3839
    3940/* TESTING: Dynamic resizing and mouse integration toggling should work
     
    4344 * resizing and cursor integration, switching back should re-enable them. */
    4445
    45 /** Display magic number, start of a UUID. */
    46 #define DISPLAYSTATE_MAGIC UINT32_C(0xf0029993)
    47 
    4846/** State information needed for the service.  The main VBoxClient code provides
    4947 *  the daemon logic needed by all services. */
    5048struct DISPLAYSTATE
    5149{
    52     /** The service interface. */
    53     struct VBCLSERVICE *pInterface;
    54     /** Magic number for sanity checks. */
    55     uint32_t magic;
    5650    /** Are we initialised yet? */
    5751    bool mfInit;
     
    6963     *  if so, have we waited for a reasonable time? */
    7064    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 *);
    7171};
     72
     73static struct DISPLAYSTATE g_DisplayState;
    7274
    7375static unsigned char *getRootProperty(struct DISPLAYSTATE *pState, const char *pszName,
     
    143145    XSelectInput(pDisplay, DefaultRootWindow(pDisplay), PropertyChangeMask | StructureNotifyMask);
    144146    if (pState->fHaveRandR12)
    145         XRRSelectInput(pDisplay, DefaultRootWindow(pDisplay), RRScreenChangeNotifyMask);
     147        pState->pXRRSelectInput(pDisplay, DefaultRootWindow(pDisplay), RRScreenChangeNotifyMask);
    146148    /* Semantics: when VBOXCLIENT_STARTED is set, pre-1.3 X.Org Server driver
    147149     * assumes that a client capable of handling mode hints will be present for the
     
    203205    int status;
    204206
     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
    205231    pState->pDisplay = XOpenDisplay(NULL);
    206232    if (!pState->pDisplay)
    207233        return VERR_NOT_FOUND;
    208     if (!XRRQueryExtension(pState->pDisplay, &pState->cRREventBase, &status))
     234    if (!pState->pXRRQueryExtension(pState->pDisplay, &pState->cRREventBase, &status))
    209235        return VERR_NOT_FOUND;
    210236    pState->fHaveRandR12 = false;
     
    222248}
    223249
    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 */
     253static DECLCALLBACK(int) init(void)
     254{
     255    struct DISPLAYSTATE *pSelf = &g_DisplayState;
    245256    int rc;
    246257
     
    255266}
    256267
    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 */
     271static DECLCALLBACK(int) run(bool volatile *)
     272{
     273    struct DISPLAYSTATE *pSelf = &g_DisplayState;
    261274
    262275    if (!pSelf->mfInit)
     
    266279}
    267280
    268 struct VBCLSERVICE vbclDisplayInterface =
    269 {
    270     getName,
    271     getPidFilePath,
    272     init,
    273     run,
    274     VBClServiceDefaultCleanup
     281VBCLSERVICE 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 */
    275293};
    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  
    5151#define VBOXCLIENT_OPT_VMSVGA               VBOXCLIENT_OPT_SERVICES + 4
    5252#define VBOXCLIENT_OPT_VMSVGA_SESSION       VBOXCLIENT_OPT_SERVICES + 5
     53#define VBOXCLIENT_OPT_DISPLAY              VBOXCLIENT_OPT_SERVICES + 6
    5354
    5455
     
    289290    RTPrintf("  --vmsvga-session     an alias for --vmsvga\n");
    290291#endif
     292    RTPrintf("  --display            starts VMSVGA dynamic resizing for legacy guests\n");
    291293#endif
    292294    RTPrintf("  -f, --foreground     run in the foreground (no daemonizing)\n");
     
    389391        { "--vmsvga",                       VBOXCLIENT_OPT_VMSVGA,                    RTGETOPT_REQ_NOTHING },
    390392        { "--vmsvga-session",               VBOXCLIENT_OPT_VMSVGA_SESSION,            RTGETOPT_REQ_NOTHING },
     393        { "--display",                      VBOXCLIENT_OPT_DISPLAY,                    RTGETOPT_REQ_NOTHING },
    391394#endif
    392395    };
     
    509512                g_Service.pDesc = &g_SvcDisplaySVGA;
    510513# 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;
    511522                break;
    512523            }
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette