VirtualBox

Ignore:
Timestamp:
Oct 16, 2024 10:03:28 AM (6 months ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
165162
Message:

FE/Qt: bugref:10407. Default to Wayland QPA even if XWayland is around.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UICommon.cpp

    r105548 r106349  
    153153    , m_enmWindowManagerType(X11WMType_Unknown)
    154154    , m_fCompositingManagerRunning(false)
    155     , m_enmDisplayServerType(VBGHDISPLAYSERVERTYPE_NONE)
    156155#endif
    157156    , m_fDarkMode(false)
     
    208207#endif
    209208
    210 #ifdef VBOX_WS_NIX
    211     /* Detect display server type: */
    212     m_enmDisplayServerType = VBGHDisplayServerTypeDetect();
    213 #endif
    214 
    215209    /* Create converter: */
    216210    UIConverter::create();
     
    278272#ifdef VBOX_WS_NIX
    279273    /* Check whether we have compositing manager running: */
    280     m_fCompositingManagerRunning = NativeWindowSubsystem::isCompositingManagerRunning(X11ServerAvailable());
     274    m_fCompositingManagerRunning = NativeWindowSubsystem::isCompositingManagerRunning();
    281275
    282276    /* Acquire current Window Manager type: */
    283     m_enmWindowManagerType = NativeWindowSubsystem::windowManagerType(X11ServerAvailable());
     277    m_enmWindowManagerType = NativeWindowSubsystem::windowManagerType();
    284278#endif /* VBOX_WS_NIX */
    285279
     
    810804#endif /* VBOX_WS_MAC */
    811805
    812 #ifdef VBOX_WS_NIX
    813 bool UICommon::X11ServerAvailable() const
    814 {
    815     return VBGHDisplayServerTypeIsXAvailable(m_enmDisplayServerType);
    816 }
    817 
    818 VBGHDISPLAYSERVERTYPE UICommon::displayServerType() const
    819 {
    820     return m_enmDisplayServerType;
    821 }
    822 #endif
    823 
    824806QString UICommon::hostOperatingSystem() const
    825807{
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UICommon.h

    r105548 r106349  
    122122        bool isCompositingManagerRunning() const { return m_fCompositingManagerRunning; }
    123123        /** Returns true if the detected display server type is either xorg or xwayland. */
    124         bool X11ServerAvailable() const;
    125         /** Returns display server type. */
    126         VBGHDISPLAYSERVERTYPE displayServerType() const;
    127124#endif
    128125        /** Returns the name of the host OS by using IHost::getOperatingSystem. */
     
    382379        /** X11: Holds whether the Window Manager we are running at is composition one. */
    383380        bool                  m_fCompositingManagerRunning;
    384         /** Unixes: Holds the display server type. */
    385         VBGHDISPLAYSERVERTYPE m_enmDisplayServerType;
    386381#endif
    387382
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIDesktopWidgetWatchdog.cpp

    r106061 r106349  
    771771#ifdef VBOX_WS_NIX
    772772# define QWINDOWSIZE_MAX ((1<<24)-1)
    773     if (pWidget->isWindow() && pWidget->isVisible() && uiCommon().X11ServerAvailable())
     773    if (pWidget->isWindow() && pWidget->isVisible() && NativeWindowSubsystem::displayServerType() == VBGHDISPLAYSERVERTYPE_X11)
    774774    {
    775775        // WORKAROUND:
     
    843843#elif defined(VBOX_WS_NIX)
    844844
    845     fResult &= NativeWindowSubsystem::activateWindow(uiCommon().X11ServerAvailable(), wId, fSwitchDesktop);
     845    fResult &= NativeWindowSubsystem::activateWindow(wId, fSwitchDesktop);
    846846
    847847#else
  • trunk/src/VBox/Frontends/VirtualBox/src/main.cpp

    r106061 r106349  
    418418            break;
    419419        }
    420         if (VBGHDisplayServerTypeIsXAvailable(enmDisplayServerType))
    421             /* Force using Qt platform plugin 'xcb', we have X11 specific code: */
     420        /* Default to wayland QPA in Wayland even if XWayland is available: */
     421        if (enmDisplayServerType == VBGHDISPLAYSERVERTYPE_XWAYLAND)
     422            RTEnvSet("QT_QPA_PLATFORM", "wayland");
     423        else
    422424            RTEnvSet("QT_QPA_PLATFORM", "xcb");
    423         else
    424             /* Assume pure Wayland (without a X server):*/
    425             RTEnvSet("QT_QPA_PLATFORM", "wayland");
    426425#endif /* VBOX_WS_NIX */
    427426
     
    519518         * Yes, we aware of note that alien widgets faster to draw but the only widget we need to be fast
    520519         * is viewport of VM which was always native since we are using his id for 3D service needs. */
     520        /* We have realized that making all windows native messes up widget updates in several cases like
     521           ssh forwarding, wayland qpa etc. Thus we experiment with not doing it any longer. */
     522#if 0
    521523        a.setAttribute(Qt::AA_NativeWindows);
     524#endif
    522525
    523526# ifdef Q_OS_SOLARIS
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualBoxManager.cpp

    r106061 r106349  
    23732373{
    23742374#ifdef VBOX_WS_NIX
    2375     NativeWindowSubsystem::setWMClass(uiCommon().X11ServerAvailable(), this, "VirtualBox Manager", "VirtualBox Manager");
     2375    NativeWindowSubsystem::setWMClass(this, "VirtualBox Manager", "VirtualBox Manager");
    23762376#endif
    23772377
  • trunk/src/VBox/Frontends/VirtualBox/src/platform/nix/VBoxUtils-nix.cpp

    r106061 r106349  
    5858#include <dlfcn.h>
    5959
    60 bool NativeWindowSubsystem::isCompositingManagerRunning(bool fIsXServerAvailable)
    61 {
    62     if (fIsXServerAvailable)
     60VBGHDISPLAYSERVERTYPE NativeWindowSubsystem::displayServerType()
     61{
     62    if (!qApp)
     63        return VBGHDISPLAYSERVERTYPE_NONE;
     64    QNativeInterface::QX11Application *pX11App = qApp->nativeInterface<QNativeInterface::QX11Application>();
     65    if (pX11App)
     66        return VBGHDISPLAYSERVERTYPE_X11;
     67    QNativeInterface::QWaylandApplication *pWaylandApp = qApp->nativeInterface<QNativeInterface::QWaylandApplication>();
     68    if (pWaylandApp)
     69        return VBGHDISPLAYSERVERTYPE_PURE_WAYLAND;
     70    return VBGHDISPLAYSERVERTYPE_NONE;
     71}
     72
     73bool NativeWindowSubsystem::isCompositingManagerRunning()
     74{
     75    if (displayServerType() == VBGHDISPLAYSERVERTYPE_X11)
    6376        return X11IsCompositingManagerRunning();
    64     return WaylandIsCompositingManagerRunning();
    65 }
     77    else if (displayServerType() == VBGHDISPLAYSERVERTYPE_PURE_WAYLAND)
     78        return WaylandIsCompositingManagerRunning();
     79    return false;
     80}
     81
    6682bool NativeWindowSubsystem::X11IsCompositingManagerRunning()
    6783{
     
    7591bool NativeWindowSubsystem::WaylandIsCompositingManagerRunning()
    7692{
    77     /// @todo implement
    78     return true;
    79 }
    80 
    81 X11WMType NativeWindowSubsystem::windowManagerType(bool fIsXServerAvailable)
    82 {
    83     if (fIsXServerAvailable)
     93    QNativeInterface::QWaylandApplication *pWaylandApp = qApp->nativeInterface<QNativeInterface::QWaylandApplication>();
     94    if (pWaylandApp)
     95    {
     96        if (pWaylandApp->compositor())
     97            return true;
     98    }
     99    return false;
     100}
     101
     102X11WMType NativeWindowSubsystem::windowManagerType()
     103{
     104    if (displayServerType() == VBGHDISPLAYSERVERTYPE_X11)
    84105        return X11WindowManagerType();
    85     return WaylandWindowManagerType();
     106    else if (displayServerType() == VBGHDISPLAYSERVERTYPE_PURE_WAYLAND)
     107        return WaylandWindowManagerType();
     108    return X11WMType_Unknown;
    86109}
    87110
     
    410433}
    411434
    412 bool NativeWindowSubsystem::activateWindow(bool fIsXServerAvailable, WId wId, bool fSwitchDesktop)
    413 {
    414     if (fIsXServerAvailable)
     435bool NativeWindowSubsystem::activateWindow(WId wId, bool fSwitchDesktop)
     436{
     437    if (displayServerType() == VBGHDISPLAYSERVERTYPE_X11)
    415438        return X11ActivateWindow(wId, fSwitchDesktop);
    416     return WaylandActivateWindow(wId, fSwitchDesktop);
     439    else if (displayServerType() == VBGHDISPLAYSERVERTYPE_PURE_WAYLAND)
     440        return WaylandActivateWindow(wId, fSwitchDesktop);
     441    return false;
    417442}
    418443
     
    655680}
    656681
    657 void NativeWindowSubsystem::setWMClass(bool fIsXServerAvailable, QWidget *pWidget, const QString &strNameString, const QString &strClassString)
    658 {
    659     if (fIsXServerAvailable)
     682void NativeWindowSubsystem::setWMClass(QWidget *pWidget, const QString &strNameString, const QString &strClassString)
     683{
     684    if (displayServerType() == VBGHDISPLAYSERVERTYPE_X11)
    660685        X11SetWMClass(pWidget, strNameString, strClassString);
    661     else
     686    else if (displayServerType() == VBGHDISPLAYSERVERTYPE_PURE_WAYLAND)
    662687        WaylandSetWMClass(pWidget, strNameString, strClassString);
    663688}
     
    695720}
    696721
    697 void NativeWindowSubsystem::setXwaylandMayGrabKeyboardFlag(bool fIsXServerAvailable, QWidget *pWidget)
    698 {
    699     if (fIsXServerAvailable)
     722void NativeWindowSubsystem::setXwaylandMayGrabKeyboardFlag(QWidget *pWidget)
     723{
     724    if (displayServerType() == VBGHDISPLAYSERVERTYPE_X11)
    700725        XXSendClientMessage(NativeWindowSubsystem::X11GetDisplay(), pWidget->window()->winId(),
    701726                            "_XWAYLAND_MAY_GRAB_KEYBOARD", 1);
  • trunk/src/VBox/Frontends/VirtualBox/src/platform/nix/VBoxUtils-nix.h

    r106061 r106349  
    9595namespace NativeWindowSubsystem
    9696{
     97    /** Determines display sever type by looking at QGuiApplication::nativeInterface() return  type: */
     98    SHARED_LIBRARY_STUFF VBGHDISPLAYSERVERTYPE displayServerType();
    9799    /** Wrapper function for X11IsCompositingManagerRunning and WaylandIsCompositingManagerRunning. */
    98     bool isCompositingManagerRunning(bool fIsXServerAvailable);
     100    bool isCompositingManagerRunning();
    99101    /** X11: Determines and returns whether the compositing manager is running. */
    100102    bool X11IsCompositingManagerRunning();
     
    103105
    104106    /** Wrapper for window manager type functions. */
    105     X11WMType windowManagerType(bool fIsXServerAvailable);
     107    X11WMType windowManagerType();
    106108    /** X11: Determines and returns current Window Manager type. */
    107109    X11WMType X11WindowManagerType();
     
    124126
    125127    /** Wrapper function for X11ActivateWindow or WaylandActivateWindow. */
    126     bool activateWindow(bool fIsXServerAvailable, WId wId, bool fSwitchDesktop);
     128    bool activateWindow(WId wId, bool fSwitchDesktop);
    127129    /** Activates window with certain @a wId, @a fSwitchDesktop if requested. */
    128130    bool X11ActivateWindow(WId wId, bool fSwitchDesktop);
     
    141143
    142144    /** Wrapper function for WMClass setters. */
    143     SHARED_LIBRARY_STUFF void setWMClass(bool fIsXServerAvailable, QWidget *pWidget, const QString &strNameString, const QString &strClassString);
     145    SHARED_LIBRARY_STUFF void setWMClass(QWidget *pWidget, const QString &strNameString, const QString &strClassString);
    144146    /** X11: Assigns WM_CLASS property for passed @a pWidget. */
    145147    SHARED_LIBRARY_STUFF void X11SetWMClass(QWidget *pWidget, const QString &strNameString, const QString &strClassString);
     
    151153      *      so that e.g. alt+tab will get send to the VM instead of moving the
    152154      *      focus away from the VM. */
    153     SHARED_LIBRARY_STUFF void setXwaylandMayGrabKeyboardFlag(bool fIsXServerAvailable, QWidget *pWidget);
     155    SHARED_LIBRARY_STUFF void setXwaylandMayGrabKeyboardFlag(QWidget *pWidget);
    154156
    155157    /** X11: Gets the X11 display pointer. */
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIFrameBuffer.cpp

    r106061 r106349  
    456456
    457457#ifdef VBOX_WS_NIX
    458     if (uiCommon().X11ServerAvailable())
     458    if (NativeWindowSubsystem::displayServerType() == VBGHDISPLAYSERVERTYPE_X11)
    459459        /* Resync Qt and X11 Server (see xTracker #7547). */
    460460        XSync(NativeWindowSubsystem::X11GetDisplay(), false);
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIKeyboardHandler.cpp

    r106061 r106349  
    267267
    268268#elif defined(VBOX_WS_NIX)
    269         if (uiCommon().X11ServerAvailable())
     269        if (NativeWindowSubsystem::displayServerType() == VBGHDISPLAYSERVERTYPE_X11)
    270270        {
    271271            /* On X11, we are using XCB stuff to grab the keyboard.
     
    370370
    371371#elif defined(VBOX_WS_NIX)
    372         if (uiCommon().X11ServerAvailable())
     372        if (NativeWindowSubsystem::displayServerType() == VBGHDISPLAYSERVERTYPE_X11)
    373373        {
    374374            /* On X11, we are using XCB stuff to grab the keyboard.
     
    819819
    820820# elif defined(VBOX_WS_NIX)
    821     if (uiCommon().X11ServerAvailable())
     821    if (NativeWindowSubsystem::displayServerType() == VBGHDISPLAYSERVERTYPE_X11)
    822822    {
    823823        /* Cast to XCB event: */
     
    10381038    /* Global settings: */
    10391039#ifdef VBOX_WS_NIX
    1040     if (uiCommon().X11ServerAvailable())
     1040    if (NativeWindowSubsystem::displayServerType() == VBGHDISPLAYSERVERTYPE_X11)
    10411041    {
    10421042        /* Initialize the X keyboard subsystem: */
     
    17861786
    17871787#elif defined(VBOX_WS_NIX)
    1788     if (uiCommon().X11ServerAvailable())
     1788    if (NativeWindowSubsystem::displayServerType() == VBGHDISPLAYSERVERTYPE_X11)
    17891789    {
    17901790        Q_UNUSED(pHotKey);
     
    18631863
    18641864#elif defined(VBOX_WS_NIX)
    1865     if (uiCommon().X11ServerAvailable())
     1865    if (NativeWindowSubsystem::displayServerType() == VBGHDISPLAYSERVERTYPE_X11)
    18661866    {
    18671867        Window   wDummy1, wDummy2;
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.cpp

    r106061 r106349  
    511511        case KMachineState_TeleportingIn:
    512512        {
    513             if (uiCommon().X11ServerAvailable())
     513            if (NativeWindowSubsystem::displayServerType() == VBGHDISPLAYSERVERTYPE_X11)
    514514            {
    515515                /* The keyboard handler may wish to do some release logging on startup.
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.cpp

    r106061 r106349  
    615615
    616616# elif defined(VBOX_WS_NIX)
    617 
    618     if (uiCommon().X11ServerAvailable())
     617    if (NativeWindowSubsystem::displayServerType() == VBGHDISPLAYSERVERTYPE_X11)
    619618    {
    620619        /* Make sure it's generic XCB event: */
     
    20222021void UIMachineView::keyPressEvent(QKeyEvent *pEvent)
    20232022{
    2024     if (uiCommon().displayServerType() == VBGHDISPLAYSERVERTYPE_PURE_WAYLAND)
     2023    if (NativeWindowSubsystem::displayServerType() == VBGHDISPLAYSERVERTYPE_PURE_WAYLAND)
    20252024        uimachine()->putScancode(pEvent->nativeScanCode() - 8);
    20262025    QAbstractScrollArea::keyPressEvent(pEvent);
     
    20292028void UIMachineView::keyReleaseEvent(QKeyEvent *pEvent)
    20302029{
    2031     if (uiCommon().displayServerType() == VBGHDISPLAYSERVERTYPE_PURE_WAYLAND)
     2030    if (NativeWindowSubsystem::displayServerType() == VBGHDISPLAYSERVERTYPE_PURE_WAYLAND)
    20322031        uimachine()->putScancode((pEvent->nativeScanCode() - 8) | 0x80);
    20332032    QAbstractScrollArea::keyReleaseEvent(pEvent);
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineWindow.cpp

    r106061 r106349  
    154154        strWindowName = QString("VirtualBox Machine UUID: %1").arg(uiCommon().managedVMUuid().toString());
    155155    /* Assign WM_CLASS property: */
    156     NativeWindowSubsystem::setWMClass(uiCommon().X11ServerAvailable(), this, strWindowName, strWindowClass);
     156    NativeWindowSubsystem::setWMClass(this, strWindowName, strWindowClass);
    157157    /* Tell the WM we are well behaved wrt Xwayland keyboard-grabs: */
    158     NativeWindowSubsystem::setXwaylandMayGrabKeyboardFlag(uiCommon().X11ServerAvailable(), this);
     158    NativeWindowSubsystem::setXwaylandMayGrabKeyboardFlag(this);
    159159#endif
    160160}
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMouseHandler.cpp

    r106061 r106349  
    323323
    324324# elif defined(VBOX_WS_NIX)
    325 
    326     if (uiCommon().X11ServerAvailable())
     325    if (NativeWindowSubsystem::displayServerType() == VBGHDISPLAYSERVERTYPE_X11)
    327326    {
    328327        /* Cast to XCB event: */
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/editors/UIHostComboEditor.cpp

    r106061 r106349  
    570570#elif defined(VBOX_WS_NIX)
    571571    /* Initialize the X keyboard subsystem: */
    572     if (uiCommon().X11ServerAvailable())
     572    if (NativeWindowSubsystem::displayServerType() == VBGHDISPLAYSERVERTYPE_X11)
    573573        initMappedX11Keyboard(NativeWindowSubsystem::X11GetDisplay(), gEDataManager->remappedScanCodes());
    574574#endif /* VBOX_WS_NIX */
     
    740740
    741741# elif defined(VBOX_WS_NIX)
    742     if (uiCommon().X11ServerAvailable())
     742    if (NativeWindowSubsystem::displayServerType() == VBGHDISPLAYSERVERTYPE_X11)
    743743    {
    744744        /* Make sure it's generic XCB event: */
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