VirtualBox

Changeset 91057 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Sep 1, 2021 11:57:17 AM (3 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:10067: Rename VBoxX11Helper to VBoxUtils-x11; Rework and cleanup VBoxUtils-x11 namespace.

Location:
trunk/src/VBox/Frontends/VirtualBox
Files:
7 edited
2 moved

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk

    r91009 r91057  
    15091509if1of ($(KBUILD_TARGET), freebsd linux netbsd openbsd solaris) # X11
    15101510 UICommon_SOURCES += \
    1511         src/platform/x11/VBoxX11Helper.cpp \
     1511        src/platform/x11/VBoxUtils-x11.cpp \
    15121512        src/platform/x11/XKeyboard-new.cpp
    15131513endif
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UICommon.cpp

    r91009 r91057  
    8585#ifdef VBOX_WS_X11
    8686# include "UIHostComboEditor.h"
    87 # include "VBoxX11Helper.h"
    8887#endif
    8988#ifdef VBOX_GUI_WITH_NETWORK_MANAGER
     
    355354#ifdef VBOX_WS_X11
    356355    /* Check whether we have compositing manager running: */
    357     m_fCompositingManagerRunning = X11IsCompositingManagerRunning();
     356    m_fCompositingManagerRunning = NativeWindowSubsystem::X11IsCompositingManagerRunning();
    358357
    359358    /* Acquire current Window Manager type: */
    360     m_enmWindowManagerType = X11WindowManagerType();
     359    m_enmWindowManagerType = NativeWindowSubsystem::X11WindowManagerType();
    361360#endif /* VBOX_WS_X11 */
    362361
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UICommon.h

    r91009 r91057  
    3232#include "UIMediumDefs.h"
    3333#ifdef VBOX_WS_X11
    34 # include "VBoxX11Helper.h"
     34# include "VBoxUtils-x11.h"
    3535#endif
    3636
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UICursor.cpp

    r91003 r91057  
    3939        (UICommon::qtRTMajorVersion() == 5 && UICommon::qtRTMinorVersion() < 11))
    4040    {
    41         if (X11CheckExtension("RENDER"))
     41        if (NativeWindowSubsystem::X11CheckExtension("RENDER"))
    4242            pWidget->setCursor(cursor);
    4343    }
     
    6565        (UICommon::qtRTMajorVersion() == 5 && UICommon::qtRTMinorVersion() < 11))
    6666    {
    67         if (X11CheckExtension("RENDER"))
     67        if (NativeWindowSubsystem::X11CheckExtension("RENDER"))
    6868            pWidget->setCursor(cursor);
    6969    }
     
    9191        (UICommon::qtRTMajorVersion() == 5 && UICommon::qtRTMinorVersion() < 11))
    9292    {
    93         if (X11CheckExtension("RENDER"))
     93        if (NativeWindowSubsystem::X11CheckExtension("RENDER"))
    9494            pWidget->unsetCursor();
    9595    }
     
    117117        (UICommon::qtRTMajorVersion() == 5 && UICommon::qtRTMinorVersion() < 11))
    118118    {
    119         if (X11CheckExtension("RENDER"))
     119        if (NativeWindowSubsystem::X11CheckExtension("RENDER"))
    120120            pWidget->unsetCursor();
    121121    }
  • trunk/src/VBox/Frontends/VirtualBox/src/platform/x11/VBoxUtils-x11.cpp

    r91056 r91057  
    11/* $Id$ */
    22/** @file
    3  * VBox Qt GUI - VBox X11 helper functions.
     3 * VBox Qt GUI - Declarations of utility classes and functions for handling X11 specific tasks.
    44 */
    55
    66/*
    7  * Copyright (C) 2008-2020 Oracle Corporation
     7 * Copyright (C) 2008-2021 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    1717
    1818/* Qt includes: */
    19 #include <QX11Info>
    2019#include <QtDBus/QDBusConnection>
     20#include <QtDBus/QDBusConnectionInterface>
     21#include <QtDBus/QDBusInterface>
    2122#include <QtDBus/QDBusReply>
    22 #include <QtDBus/QDBusInterface>
    23 #include <QtDBus/QDBusConnectionInterface>
    2423#include <QtXml/QDomDocument>
    2524#include <QtXml/QDomElement>
     25#include <QX11Info>
    2626
    2727/* GUI includes: */
    28 #include "VBoxX11Helper.h"
     28#include "VBoxUtils-x11.h"
    2929
    3030/* Other VBox includes: */
    3131#include <iprt/cdefs.h>
     32#include <VBox/log.h>
    3233
    3334// WORKAROUND:
     
    4041RT_C_DECLS_END
    4142
    42 #include <VBox/log.h>
    4343
    4444static int  gX11ScreenSaverTimeout;
     
    4646static BOOL gX11DpmsState;
    4747
    48 bool X11IsCompositingManagerRunning()
    49 {
    50     /* Get display: */
    51     Display *pDisplay = QX11Info::display();
     48bool NativeWindowSubsystem::X11IsCompositingManagerRunning()
     49{
    5250    /* For each screen it manage, compositing manager MUST acquire ownership
    5351     * of a selection named _NET_WM_CM_Sn, where n is the screen number. */
     52    Display *pDisplay = QX11Info::display();
    5453    Atom atom_property_name = XInternAtom(pDisplay, "_NET_WM_CM_S0", True);
    5554    return XGetSelectionOwner(pDisplay, atom_property_name);
    5655}
    5756
    58 X11WMType X11WindowManagerType()
    59 {
    60     /* Get display: */
    61     Display *pDisplay = QX11Info::display();
    62     /* Prepare variables to be reused: */
     57X11WMType NativeWindowSubsystem::X11WindowManagerType()
     58{
     59    /* Ask if root-window supports check for WM name: */
     60    Display *pDisplay = QX11Info::display();
    6361    Atom atom_property_name;
    6462    Atom atom_returned_type;
     
    6866    unsigned char *pcData = 0;
    6967    X11WMType wmType = X11WMType_Unknown;
    70 
    71     /* Ask if root-window supports check for WM name: */
    7268    atom_property_name = XInternAtom(pDisplay, "_NET_SUPPORTING_WM_CHECK", True);
    7369    if (XGetWindowProperty(pDisplay, QX11Info::appRootWindow(), atom_property_name,
     
    114110}
    115111
    116 void X11ScreenSaverSettingsInit()
    117 {
    118     int     dummy;
    119     Display *pDisplay = QX11Info::display();
     112void NativeWindowSubsystem::X11ScreenSaverSettingsInit()
     113{
     114    /* Init screen-save availability: */
     115    Display *pDisplay = QX11Info::display();
     116    int dummy;
    120117    gX11ScreenSaverDpmsAvailable = DPMSQueryExtension(pDisplay, &dummy, &dummy);
    121118}
    122119
    123 void X11ScreenSaverSettingsSave()
     120void NativeWindowSubsystem::X11ScreenSaverSettingsSave()
    124121{
    125122    /* Actually this is a big mess. By default the libSDL disables the screen saver
     
    132129     * save and restore the state prior and after each of these function calls. */
    133130
    134     int     dummy;
    135     CARD16  dummy2;
    136     Display *pDisplay = QX11Info::display();
    137 
     131    Display *pDisplay = QX11Info::display();
     132    int dummy;
     133    CARD16 dummy2;
    138134    XGetScreenSaver(pDisplay, &gX11ScreenSaverTimeout, &dummy, &dummy, &dummy);
    139135    if (gX11ScreenSaverDpmsAvailable)
     
    141137}
    142138
    143 void X11ScreenSaverSettingsRestore()
    144 {
    145     int     iTimeout, iInterval, iPreferBlank, iAllowExp;
    146     Display *pDisplay = QX11Info::display();
    147 
     139void NativeWindowSubsystem::X11ScreenSaverSettingsRestore()
     140{
     141    /* Restore screen-saver settings: */
     142    Display *pDisplay = QX11Info::display();
     143    int iTimeout, iInterval, iPreferBlank, iAllowExp;
    148144    XGetScreenSaver(pDisplay, &iTimeout, &iInterval, &iPreferBlank, &iAllowExp);
    149145    iTimeout = gX11ScreenSaverTimeout;
    150146    XSetScreenSaver(pDisplay, iTimeout, iInterval, iPreferBlank, iAllowExp);
    151 
    152147    if (gX11DpmsState && gX11ScreenSaverDpmsAvailable)
    153148        DPMSEnable(pDisplay);
    154149}
    155150
    156 bool X11CheckExtension(const char *extensionName)
    157 {
     151bool NativeWindowSubsystem::X11CheckExtension(const char *pExtensionName)
     152{
     153    /* Check extension: */
    158154    Display *pDisplay = QX11Info::display();
    159155    int major_opcode;
    160156    int first_event;
    161157    int first_error;
    162     return XQueryExtension(pDisplay, extensionName, &major_opcode, &first_event, &first_error);
    163 }
    164 
    165 static bool X11CheckDBusConnection(const QDBusConnection &connection)
    166 {
    167     if (!connection.isConnected()) {
     158    return XQueryExtension(pDisplay, pExtensionName, &major_opcode, &first_event, &first_error);
     159}
     160
     161bool NativeWindowSubsystem::X11CheckDBusConnection(const QDBusConnection &connection)
     162{
     163    if (!connection.isConnected())
     164    {
    168165        const QDBusError lastError = connection.lastError();
    169166        if (lastError.isValid())
     
    180177}
    181178
    182 static QStringList X11FindDBusScreenSaverServices(const QDBusConnection &connection)
     179QStringList NativeWindowSubsystem::X11FindDBusScreenSaverServices(const QDBusConnection &connection)
    183180{
    184181    QStringList serviceNames;
     
    205202}
    206203
    207 bool X11CheckDBusScreenSaverServices()
     204bool NativeWindowSubsystem::X11CheckDBusScreenSaverServices()
    208205{
    209206    QDBusConnection connection = QDBusConnection::sessionBus();
     
    229226}
    230227
    231 
    232 static void X11IntrospectInterfaceNode(const QDomElement &interface,
    233                                          const QString &strServiceName, QVector<X11ScreenSaverInhibitMethod*> &methods)
     228void NativeWindowSubsystem::X11IntrospectInterfaceNode(const QDomElement &interface,
     229                                                       const QString &strServiceName,
     230                                                       QVector<X11ScreenSaverInhibitMethod*> &methods)
    234231{
    235232    QDomElement child = interface.firstChildElement();
    236     while (!child.isNull()) {
    237 
     233    while (!child.isNull())
     234    {
    238235        if (child.tagName() == "method" && child.attribute("name") == "Inhibit")
    239236        {
     
    251248}
    252249
    253 static void X11IntrospectServices(const QDBusConnection &connection,
    254                                     const QString &strService, const QString &path, QVector<X11ScreenSaverInhibitMethod*> &methods)
    255 {
    256     QDBusMessage call = QDBusMessage::createMethodCall(strService, path.isEmpty() ? QLatin1String("/") : path,
     250void NativeWindowSubsystem::X11IntrospectServices(const QDBusConnection &connection,
     251                                                  const QString &strService,
     252                                                  const QString &strPath,
     253                                                  QVector<X11ScreenSaverInhibitMethod*> &methods)
     254{
     255    QDBusMessage call = QDBusMessage::createMethodCall(strService, strPath.isEmpty() ? QLatin1String("/") : strPath,
    257256                                                       QLatin1String("org.freedesktop.DBus.Introspectable"),
    258257                                                       QLatin1String("Introspect"));
     
    270269        if (child.tagName() == QLatin1String("node"))
    271270        {
    272             QString subPath = path + QLatin1Char('/') + child.attribute(QLatin1String("name"));
     271            QString subPath = strPath + QLatin1Char('/') + child.attribute(QLatin1String("name"));
    273272            X11IntrospectServices(connection, strService, subPath, methods);
    274273        }
     
    279278}
    280279
    281 QVector<X11ScreenSaverInhibitMethod*> X11FindDBusScrenSaverInhibitMethods()
     280QVector<X11ScreenSaverInhibitMethod*> NativeWindowSubsystem::X11FindDBusScrenSaverInhibitMethods()
    282281{
    283282    QVector<X11ScreenSaverInhibitMethod*> methods;
     
    293292}
    294293
    295 void X11InhibitUninhibitScrenSaver(bool fInhibit, QVector<X11ScreenSaverInhibitMethod*> &inOutIhibitMethods)
     294void NativeWindowSubsystem::X11InhibitUninhibitScrenSaver(bool fInhibit, QVector<X11ScreenSaverInhibitMethod*> &inOutIhibitMethods)
    296295{
    297296    QDBusConnection connection = QDBusConnection::sessionBus();
     
    332331    }
    333332}
    334 
    335 #ifdef VBOX_WS_X11
    336 #endif
  • trunk/src/VBox/Frontends/VirtualBox/src/platform/x11/VBoxUtils-x11.h

    r91056 r91057  
    11/* $Id$ */
    22/** @file
    3  * VBox Qt GUI - VBox X11 helper functions.
     3 * VBox Qt GUI - Declarations of utility classes and functions for handling X11 specific tasks.
    44 */
    55
    66/*
    7  * Copyright (C) 2006-2020 Oracle Corporation
     7 * Copyright (C) 2006-2021 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    1616 */
    1717
    18 #ifndef FEQT_INCLUDED_SRC_platform_x11_VBoxX11Helper_h
    19 #define FEQT_INCLUDED_SRC_platform_x11_VBoxX11Helper_h
     18#ifndef FEQT_INCLUDED_SRC_platform_x11_VBoxUtils_x11_h
     19#define FEQT_INCLUDED_SRC_platform_x11_VBoxUtils_x11_h
    2020#ifndef RT_WITHOUT_PRAGMA_ONCE
    2121# pragma once
     
    3131/* Forward declarations: */
    3232class QDBusConnection;
     33class QDomElement;
    3334
    3435/** X11: Known Window Manager types. */
     
    4445};
    4546
     47/** X11: Screen-saver inhibit methods. */
    4648struct SHARED_LIBRARY_STUFF X11ScreenSaverInhibitMethod
    4749{
    48     QString m_strServiceName;
    49     QString m_strInterface;
    50     QString m_strPath;
    51     uint    m_iCookie;
     50    QString  m_strServiceName;
     51    QString  m_strInterface;
     52    QString  m_strPath;
     53    uint     m_iCookie;
    5254};
    5355
    54 /** X11: Determines and returns whether the compositing manager is running. */
    55 SHARED_LIBRARY_STUFF bool X11IsCompositingManagerRunning();
     56/* Namespace for native window sub-system functions: */
     57namespace NativeWindowSubsystem
     58{
     59    /** X11: Determines and returns whether the compositing manager is running. */
     60    SHARED_LIBRARY_STUFF bool X11IsCompositingManagerRunning();
    5661
    57 /** X11: Determines and returns current Window Manager type. */
    58 SHARED_LIBRARY_STUFF X11WMType X11WindowManagerType();
     62    /** X11: Determines and returns current Window Manager type. */
     63    SHARED_LIBRARY_STUFF X11WMType X11WindowManagerType();
    5964
    60 /** X11: Inits the screen saver save/restore mechanism. */
    61 SHARED_LIBRARY_STUFF void X11ScreenSaverSettingsInit();
    62 /** X11: Saves screen saver settings. */
    63 SHARED_LIBRARY_STUFF void X11ScreenSaverSettingsSave();
    64 /** X11: Restores previously saved screen saver settings. */
    65 SHARED_LIBRARY_STUFF void X11ScreenSaverSettingsRestore();
    66 /** X11: Returns true if XLib extension with name @p extensionName is avaible, false otherwise. */
    67 SHARED_LIBRARY_STUFF bool X11CheckExtension(const char *extensionName);
     65    /** X11: Inits the screen saver save/restore mechanism. */
     66    SHARED_LIBRARY_STUFF void X11ScreenSaverSettingsInit();
     67    /** X11: Saves screen saver settings. */
     68    SHARED_LIBRARY_STUFF void X11ScreenSaverSettingsSave();
     69    /** X11: Restores previously saved screen saver settings. */
     70    SHARED_LIBRARY_STUFF void X11ScreenSaverSettingsRestore();
     71    /** X11: Returns true if XLib extension with name @p extensionName is avaible, false otherwise. */
     72    SHARED_LIBRARY_STUFF bool X11CheckExtension(const char *extensionName);
    6873
    69 /** Returns true if there are any DBus services whose name contains the substring 'screensaver'. */
    70 bool X11CheckDBusScreenSaverServices();
     74    /** X11: Returns whether DBus @a connection is alive. */
     75    bool X11CheckDBusConnection(const QDBusConnection &connection);
     76    /** X11: Finds a list of DBus @a connection screen-saver services. */
     77    QStringList X11FindDBusScreenSaverServices(const QDBusConnection &connection);
     78    /** X11: Returns whether there are any DBus services whose name contains the substring 'screensaver'. */
     79    bool X11CheckDBusScreenSaverServices();
     80    /** X11: Does something known only to original creator... */
     81    void X11IntrospectInterfaceNode(const QDomElement &interface,
     82                                    const QString &strServiceName,
     83                                    QVector<X11ScreenSaverInhibitMethod*> &methods);
     84    /** X11: Does something known only to original creator... */
     85    void X11IntrospectServices(const QDBusConnection &connection,
     86                               const QString &strService,
     87                               const QString &strPath,
     88                               QVector<X11ScreenSaverInhibitMethod*> &methods);
    7189
    72 /** Returns the list of Inhibit methods found by introspecting DBus services. */
    73 SHARED_LIBRARY_STUFF QVector<X11ScreenSaverInhibitMethod*> X11FindDBusScrenSaverInhibitMethods();
     90    /** X11: Returns the list of Inhibit methods found by introspecting DBus services. */
     91    SHARED_LIBRARY_STUFF QVector<X11ScreenSaverInhibitMethod*> X11FindDBusScrenSaverInhibitMethods();
    7492
    75 /** Disables/enables Screen Saver through QDBus. */
    76 SHARED_LIBRARY_STUFF void X11InhibitUninhibitScrenSaver(bool fInhibit, QVector<X11ScreenSaverInhibitMethod*> &inOutIhibitMethods);
     93    /** X11: Disables/enables Screen Saver through QDBus. */
     94    SHARED_LIBRARY_STUFF void X11InhibitUninhibitScrenSaver(bool fInhibit, QVector<X11ScreenSaverInhibitMethod*> &inOutIhibitMethods);
     95}
    7796
    78 #endif /* !FEQT_INCLUDED_SRC_platform_x11_VBoxX11Helper_h */
     97#endif /* !FEQT_INCLUDED_SRC_platform_x11_VBoxUtils_x11_h */
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.cpp

    r90893 r91057  
    610610#if defined(VBOX_WS_X11)
    611611    if (m_methods.isEmpty())
    612         m_methods = X11FindDBusScrenSaverInhibitMethods();
    613     X11InhibitUninhibitScrenSaver(fDisabled, m_methods);
     612        m_methods = NativeWindowSubsystem::X11FindDBusScrenSaverInhibitMethods();
     613    NativeWindowSubsystem::X11InhibitUninhibitScrenSaver(fDisabled, m_methods);
    614614#elif defined(VBOX_WS_WIN)
    615615    NativeWindowSubsystem::setScreenSaverActive(fDisabled);
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMouseHandler.cpp

    r91003 r91057  
    5454/* External includes: */
    5555#ifdef VBOX_WS_X11
    56 #include "VBoxX11Helper.h"
    57 # include <xcb/xcb.h>
     56#include "VBoxUtils-x11.h"
    5857#endif
    5958
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/global/UIGlobalSettingsDisplay.cpp

    r89910 r91057  
    2929#include "UIScaleFactorEditor.h"
    3030#ifdef VBOX_WS_X11
    31 # include "VBoxX11Helper.h"
     31# include "VBoxUtils-x11.h"
    3232#endif
    3333
     
    260260        m_pCheckBoxDisableHostScreenSaver = new QCheckBox(this);
    261261#elif defined(VBOX_WS_X11)
    262         if (X11CheckDBusScreenSaverServices())
     262        if (NativeWindowSubsystem::X11CheckDBusScreenSaverServices())
    263263            m_pCheckBoxDisableHostScreenSaver = new QCheckBox(this);
    264264#endif
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