VirtualBox

Changeset 89910 in vbox


Ignore:
Timestamp:
Jun 25, 2021 10:18:08 AM (4 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
145368
Message:

FE/Qt: bugref:3355. On Linux check if there are any screensaver related DBus services before enabling the option

Location:
trunk/src/VBox/Frontends/VirtualBox/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/platform/x11/VBoxX11Helper.cpp

    r89908 r89910  
    163163}
    164164
    165 QStringList X11FindDBusScreenSaverServices(const QDBusConnection &connection)
     165static bool X11CheckDBusConnection(const QDBusConnection &connection)
     166{
     167    if (!connection.isConnected()) {
     168        const QDBusError lastError = connection.lastError();
     169        if (lastError.isValid())
     170        {
     171            LogRel(("QDBus error. Could not connect to D-Bus server: %s: %s\n",
     172                    lastError.name().toUtf8().constData(),
     173                    lastError.message().toUtf8().constData()));
     174        }
     175        else
     176            LogRel(("QDBus error. Could not connect to D-Bus server: Unable to load dbus libraries\n"));
     177        return false;
     178    }
     179    return true;
     180}
     181
     182static QStringList X11FindDBusScreenSaverServices(const QDBusConnection &connection)
    166183{
    167184    QStringList serviceNames;
     
    187204    return serviceNames;
    188205}
     206
     207bool X11CheckDBusScreenSaverServices()
     208{
     209    QDBusConnection connection = QDBusConnection::sessionBus();
     210    if (!X11CheckDBusConnection(connection))
     211        return false;
     212
     213    QDBusReply<QStringList> replyr = connection.interface()->registeredServiceNames();
     214    if (!replyr.isValid())
     215    {
     216        const QDBusError replyError = replyr.error();
     217        LogRel(("QDBus error. Could not query registered service names %s %s",
     218                replyError.name().toUtf8().constData(), replyError.message().toUtf8().constData()));
     219        return false;
     220    }
     221    for (int i = 0; i < replyr.value().size(); ++i)
     222    {
     223        const QString strServiceName = replyr.value()[i];
     224        if (strServiceName.contains("screensaver", Qt::CaseInsensitive))
     225            return true;
     226    }
     227    LogRel(("QDBus error. No screen saver service found among registered DBus services."));
     228    return false;
     229}
     230
    189231
    190232static void X11IntrospectInterfaceNode(const QDomElement &interface,
     
    237279}
    238280
    239 static bool X11CheckDBusConnection(const QDBusConnection &connection)
    240 {
    241     if (!connection.isConnected()) {
    242         const QDBusError lastError = connection.lastError();
    243         if (lastError.isValid())
    244         {
    245             LogRel(("QDBus error. Could not connect to D-Bus server: %s: %s\n",
    246                     lastError.name().toUtf8().constData(),
    247                     lastError.message().toUtf8().constData()));
    248         }
    249         else
    250             LogRel(("QDBus error. Could not connect to D-Bus server: Unable to load dbus libraries\n"));
    251         return false;
    252     }
    253     return true;
    254 }
    255 
    256281QVector<X11ScreenSaverInhibitMethod*> X11FindDBusScrenSaverInhibitMethods()
    257282{
  • trunk/src/VBox/Frontends/VirtualBox/src/platform/x11/VBoxX11Helper.h

    r89908 r89910  
    6767SHARED_LIBRARY_STUFF bool X11CheckExtension(const char *extensionName);
    6868
    69 /** Returns the list of DBus services whose name contains the substring 'screensaver'. */
    70 QStringList X11FindDBusScreenSaverServices(const QDBusConnection &connection);
     69/** Returns true if there are any DBus services whose name contains the substring 'screensaver'. */
     70bool X11CheckDBusScreenSaverServices();
    7171
    7272/** Returns the list of Inhibit methods found by introspecting DBus services. */
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/global/UIGlobalSettingsDisplay.cpp

    r89909 r89910  
    2828#include "UIMessageCenter.h"
    2929#include "UIScaleFactorEditor.h"
     30#ifdef VBOX_WS_X11
     31# include "VBoxX11Helper.h"
     32#endif
    3033
    3134
     
    8184    , m_pLabelMachineWindows(0)
    8285    , m_pCheckBoxActivateOnMouseHover(0)
    83 #if defined(VBOX_WS_WIN) || defined(VBOX_WS_X11)
    8486    , m_pCheckBoxDisableHostScreenSaver(0)
    85 #endif
    8687{
    8788    prepare();
     
    122123    m_pEditorMaximumGuestScreenSize->setValue(oldData.m_guiMaximumGuestScreenSizeValue);
    123124    m_pCheckBoxActivateOnMouseHover->setChecked(oldData.m_fActivateHoveredMachineWindow);
    124 #if defined(VBOX_WS_WIN) || defined(VBOX_WS_X11)
    125     m_pCheckBoxDisableHostScreenSaver->setChecked(oldData.m_fDisableHostScreenSaver);
    126 #endif
     125    if (m_pCheckBoxDisableHostScreenSaver)
     126        m_pCheckBoxDisableHostScreenSaver->setChecked(oldData.m_fDisableHostScreenSaver);
    127127    m_pEditorScaleFactor->setScaleFactors(oldData.m_scaleFactors);
    128128    m_pEditorScaleFactor->setMonitorCount(gpDesktop->screenCount());
     
    137137    newData.m_guiMaximumGuestScreenSizeValue = m_pEditorMaximumGuestScreenSize->value();
    138138    newData.m_fActivateHoveredMachineWindow = m_pCheckBoxActivateOnMouseHover->isChecked();
    139 #if defined(VBOX_WS_WIN) || defined(VBOX_WS_X11)
    140     newData.m_fDisableHostScreenSaver = m_pCheckBoxDisableHostScreenSaver->isChecked();
    141 #endif
     139    if (m_pCheckBoxDisableHostScreenSaver)
     140        newData.m_fDisableHostScreenSaver = m_pCheckBoxDisableHostScreenSaver->isChecked();
    142141    newData.m_scaleFactors = m_pEditorScaleFactor->scaleFactors();
    143142    m_pCache->cacheCurrentData(newData);
     
    166165    m_pCheckBoxActivateOnMouseHover->setWhatsThis(tr("When checked, machine windows will be raised when the mouse pointer moves over them."));
    167166    m_pCheckBoxActivateOnMouseHover->setText(tr("&Raise Window Under Mouse"));
    168 #if defined(VBOX_WS_WIN) || defined(VBOX_WS_X11)
    169     m_pCheckBoxDisableHostScreenSaver->setWhatsThis(tr("When checked, screen saver of the host OS is disabled."));
    170     m_pCheckBoxDisableHostScreenSaver->setText(tr("&Disable Host Screen Saver"));
    171 #endif
     167    if (m_pCheckBoxDisableHostScreenSaver)
     168    {
     169        m_pCheckBoxDisableHostScreenSaver->setWhatsThis(tr("When checked, screen saver of the host OS is disabled."));
     170        m_pCheckBoxDisableHostScreenSaver->setText(tr("&Disable Host Screen Saver"));
     171    }
    172172}
    173173
     
    256256            pLayoutMain->addWidget(m_pCheckBoxActivateOnMouseHover, 5, 1);
    257257
    258 #if defined(VBOX_WS_WIN) || defined(VBOX_WS_X11)
    259258        /* Prepare 'disable host screen saver' check-box: */
     259#if defined(VBOX_WS_WIN)
    260260        m_pCheckBoxDisableHostScreenSaver = new QCheckBox(this);
     261#elif defined(VBOX_WS_X11)
     262        if (X11CheckDBusScreenSaverServices())
     263            m_pCheckBoxDisableHostScreenSaver = new QCheckBox(this);
     264#endif
    261265        if (m_pCheckBoxDisableHostScreenSaver)
    262266            pLayoutMain->addWidget(m_pCheckBoxDisableHostScreenSaver, 6, 1);
    263 #endif
     267
    264268    }
    265269}
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/global/UIGlobalSettingsDisplay.h

    r89908 r89910  
    9797        /** Holds the 'activate on mouse hover' check-box instance. */
    9898        QCheckBox                      *m_pCheckBoxActivateOnMouseHover;
    99 #if defined(VBOX_WS_WIN) || defined(VBOX_WS_X11)
    10099        /** Holds the 'disable host screen saver' check-box instance. */
    101100        QCheckBox                      *m_pCheckBoxDisableHostScreenSaver;
    102 #endif
    103101    /** @} */
    104102};
Note: See TracChangeset for help on using the changeset viewer.

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