VirtualBox

Changeset 89708 in vbox


Ignore:
Timestamp:
Jun 15, 2021 2:25:25 PM (3 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:3355. Implementing screen saver Linux implement functions.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/platform/x11
Files:
2 edited

Legend:

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

    r89705 r89708  
    3939RT_C_DECLS_END
    4040
     41#include <VBox/log.h>
    4142
    4243static int  gX11ScreenSaverTimeout;
     
    177178}
    178179
    179 void X11InhibitScrenSaver(const QStringList &serviceNameList)
    180 {
    181     Q_UNUSED(serviceNameList);
    182 }
     180void X11InhibitScrenSaver(const QStringList &serviceNameList, QMap<QString, uint> &outCookies)
     181{
     182    outCookies.clear();
     183    QDBusConnection bus = QDBusConnection::sessionBus();
     184
     185    foreach(QString service, serviceNameList)
     186    {
     187        QDBusInterface screenSaverInterface(service, "/ScreenSaver",
     188                                            QString(), bus);
     189        if (!screenSaverInterface.isValid())
     190        {
     191            QDBusError error = screenSaverInterface.lastError();
     192            LogRel(("QDBus error for service %s: %s\n",
     193                    service.toUtf8().constData(), error.message().toUtf8().constData()));
     194            continue;
     195        }
     196        QDBusReply<uint> reply = screenSaverInterface.call("Inhibit", "Oracle VirtualBox", "");
     197        if (reply.isValid())
     198            outCookies[service] = reply.value();
     199        else
     200        {
     201            QDBusError error = screenSaverInterface.lastError();
     202            LogRel(("QDBus inhibition call error for service %s: %s\n",
     203                    service.toUtf8().constData(), error.message().toUtf8().constData()));
     204        }
     205    }
     206}
     207
     208void X11UninhibitScrenSaver(const QMap<QString, uint> &cookies)
     209{
     210
     211    QDBusConnection bus = QDBusConnection::sessionBus();
     212
     213    for (QMap<QString, uint>::const_iterator iterator = cookies.begin(); iterator != cookies.end(); ++iterator)
     214    {
     215
     216        QDBusInterface screenSaverInterface(iterator.key(), "/ScreenSaver",
     217                                            QString(), bus);
     218        if (!screenSaverInterface.isValid())
     219        {
     220            QDBusError error = screenSaverInterface.lastError();
     221            LogRel(("QDBus error for service %s: %s\n",
     222                    iterator.key().toUtf8().constData(), error.message().toUtf8().constData()));
     223            continue;
     224        }
     225        QDBusReply<uint> reply = screenSaverInterface.call("UnInhibit", iterator.value());
     226        if (!reply.isValid())
     227        {
     228            QDBusError error = screenSaverInterface.lastError();
     229            LogRel(("QDBus uninhibition call error for service %s: %s\n",
     230                    iterator.key().toUtf8().constData(), error.message().toUtf8().constData()));
     231        }
     232    }
     233}
     234
    183235
    184236#ifdef VBOX_WS_X11
  • trunk/src/VBox/Frontends/VirtualBox/src/platform/x11/VBoxX11Helper.h

    r89704 r89708  
    5858
    5959/* Disables Screen Saver through QDBus. */
    60 SHARED_LIBRARY_STUFF  void X11InhibitScrenSaver(const QStringList &serviceNameList);
     60SHARED_LIBRARY_STUFF  void X11InhibitScrenSaver(const QStringList &serviceNameList, QMap<QString, uint> &outCookies);
     61
     62/* Enables Screen Saver through QDBus. */
     63SHARED_LIBRARY_STUFF  void X11UninhibitScrenSaver(const QMap<QString, uint> &cookies);
    6164
    6265#endif /* !FEQT_INCLUDED_SRC_platform_x11_VBoxX11Helper_h */
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