VirtualBox

Changeset 101673 in vbox


Ignore:
Timestamp:
Oct 31, 2023 9:57:18 AM (15 months ago)
Author:
vboxsync
Message:

GuestHost: DisplayServerType: Add runtime detection if Gtk library is present in the system, bugref:10194.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/GuestHost/DisplayServerType.h

    r100063 r101673  
    6969const char *VBGHDisplayServerTypeToStr(VBGHDISPLAYSERVERTYPE enmType);
    7070VBGHDISPLAYSERVERTYPE VBGHDisplayServerTypeDetect(void);
     71bool VBGHDisplayServerTypeIsGtkAvailable(void);
    7172bool VBGHDisplayServerTypeIsXAvailable(VBGHDISPLAYSERVERTYPE enmType);
    7273bool VBGHDisplayServerTypeIsWaylandAvailable(VBGHDISPLAYSERVERTYPE enmType);
  • trunk/src/VBox/GuestHost/DisplayServerType.cpp

    r100217 r101673  
    9595}
    9696
     97
     98#define GET_SYMBOL(a_Mod, a_Name, a_Fn) \
     99    if (RT_SUCCESS(rc)) \
     100        rc = RTLdrGetSymbol(a_Mod, a_Name, (void **)&a_Fn); \
     101    if (RT_FAILURE(rc)) \
     102        LogRel2(("Symbol '%s' unable to load, rc=%Rrc\n", a_Name, rc));
     103
    97104/**
    98105 * Tries to detect the desktop display server type the process is running in.
     
    123130        "libwayland-client.so.0" /* Needed for Ubuntu */
    124131    };
    125 
    126 #define GET_SYMBOL(a_Mod, a_Name, a_Fn) \
    127     if (RT_SUCCESS(rc)) \
    128         rc = RTLdrGetSymbol(a_Mod, a_Name, (void **)&a_Fn); \
    129     if (RT_FAILURE(rc)) \
    130         LogRel2(("Symbol '%s' unable to load, rc=%Rrc\n", a_Name, rc));
    131132
    132133    int rc = vbghDisplayServerTryLoadLib(aLibsWayland, RT_ELEMENTS(aLibsWayland), &hWaylandClient);
     
    188189    }
    189190
    190 #undef GET_SYMBOL
    191 
    192191    /* If both wayland and X11 display can be connected then we should have XWayland: */
    193192    VBGHDISPLAYSERVERTYPE retSessionType = VBGHDISPLAYSERVERTYPE_NONE;
     
    205204
    206205/**
     206 * Detect GTK library.
     207 *
     208 * @returns \c true if GTK library is available in the system.
     209 */
     210bool VBGHDisplayServerTypeIsGtkAvailable(void)
     211{
     212    int rc;
     213
     214    /* Array of libGtk.so versions to search for.
     215     * Descending precedence. */
     216    const char* aLibsGtk[] =
     217    {
     218        "libgtk-3.so",
     219        "libgtk-3.so.0"
     220    };
     221
     222    RTLDRMOD hGtk = NIL_RTLDRMOD;
     223    void * (*pfnGtkInit)(const char *) = NULL;
     224
     225    rc = vbghDisplayServerTryLoadLib(aLibsGtk, RT_ELEMENTS(aLibsGtk), &hGtk);
     226    if (RT_SUCCESS(rc))
     227    {
     228        GET_SYMBOL(hGtk, "gtk_init", pfnGtkInit);
     229        RTLdrClose(hGtk);
     230    }
     231
     232    return RT_SUCCESS(rc) && RT_VALID_PTR(pfnGtkInit);
     233}
     234
     235#undef GET_SYMBOL
     236
     237/**
    207238 * Returns true if @a enmType is indicating running X.
    208239 *
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