VirtualBox

Changeset 65551 in vbox for trunk/src/VBox/Frontends


Ignore:
Timestamp:
Jan 31, 2017 4:30:52 PM (8 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:8636: Runtime UI: Mini-toolbar: Move the mini-toolbar to Qt::Window logic making it independent on parent window behavior which is exactly what we need, but we losing the z-order.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIMiniToolBar.cpp

    r65549 r65551  
    405405                             Qt::Alignment alignment,
    406406                             bool fAutoHide /* = true */)
    407     : QWidget(pParent, Qt::Tool | Qt::FramelessWindowHint)
     407    : QWidget(0, Qt::Window | Qt::FramelessWindowHint)
    408408    /* Variables: General stuff: */
    409409    , m_pParent(pParent)
     
    601601    switch (m_geometryType)
    602602    {
    603         case GeometryType_Available: show(); break;
    604         case GeometryType_Full:      showFullScreen(); break;
     603        case GeometryType_Available:
     604        {
     605            /* Show normal: */
     606            show();
     607            break;
     608        }
     609        case GeometryType_Full:
     610        {
     611            /* Show full-screen: */
     612            showFullScreen();
     613            break;
     614        }
    605615    }
    606616
     
    610620    switch (m_geometryType)
    611621    {
    612         case GeometryType_Available: show(); break;
    613         case GeometryType_Full:      showFullScreen(); break;
    614     }
    615     /* Adjust window: */
    616     sltAdjust();
     622        case GeometryType_Available:
     623        {
     624            /* Adjust window: */
     625            sltAdjust();
     626            /* Show maximized: */
     627            if (!isMaximized())
     628                showMaximized();
     629            break;
     630        }
     631        case GeometryType_Full:
     632        {
     633            /* Show full-screen: */
     634            showFullScreen();
     635            /* Adjust window: */
     636            sltAdjust();
     637            break;
     638        }
     639    }
    617640
    618641#else
     
    685708#elif defined(VBOX_WS_X11)
    686709
    687     /* Determine whether we should use the native full-screen mode: */
    688     const bool fUseNativeFullScreen = VBoxGlobal::supportsFullScreenMonitorsProtocolX11() &&
    689                                       !gEDataManager->legacyFullscreenModeRequested();
    690     if (fUseNativeFullScreen)
    691     {
    692         /* Tell recent window managers which host-screen this window should be mapped to: */
    693         VBoxGlobal::setFullScreenMonitorX11(this, iHostScreen);
    694     }
    695 
    696     /* Set appropriate window size: */
    697     const QSize newSize = workingArea.size();
    698     LogRel(("GUI: UIMiniToolBar::sltAdjust: Resize window to: %dx%d\n",
    699             newSize.width(), newSize.height()));
    700     resize(newSize);
    701 
    702     /* Move window onto required screen: */
    703     const QPoint newPosition = workingArea.topLeft();
    704     LogRel(("GUI: UIMiniToolBar::sltAdjust: Move window to: %dx%d\n",
    705             newPosition.x(), newPosition.y()));
    706     move(newPosition);
    707 
    708     /* Re-apply the full-screen state lost on above move(): */
    709     setWindowState(Qt::WindowFullScreen);
     710    switch (m_geometryType)
     711    {
     712        case GeometryType_Available:
     713        {
     714            /* Make sure we are located on corresponding host-screen: */
     715            if (   gpDesktop->screenCount() > 1
     716                && (x() != workingArea.x() || y() != workingArea.y()))
     717            {
     718                // WORKAROUND:
     719                // With Qt5 on KDE we can't just move the window onto desired host-screen if
     720                // window is maximized. So we have to show it normal first of all:
     721                if (isVisible() && isMaximized())
     722                    showNormal();
     723
     724                // WORKAROUND:
     725                // With Qt5 on X11 we can't just move the window onto desired host-screen if
     726                // window size is more than the available geometry (working area) of that
     727                // host-screen. So we are resizing it to a smaller size first of all:
     728                const QSize newSize = workingArea.size() * .9;
     729                LogRel(("GUI: UIMiniToolBar::sltAdjust: Resize window to smaller size: %dx%d\n",
     730                        newSize.width(), newSize.height()));
     731                resize(newSize);
     732
     733                /* Move window onto required screen: */
     734                const QPoint newPosition = workingArea.topLeft();
     735                LogRel(("GUI: UIMiniToolBar::sltAdjust: Move window to: %dx%d\n",
     736                        newPosition.x(), newPosition.y()));
     737                move(newPosition);
     738            }
     739
     740            break;
     741        }
     742        case GeometryType_Full:
     743        {
     744            /* Determine whether we should use the native full-screen mode: */
     745            const bool fUseNativeFullScreen = VBoxGlobal::supportsFullScreenMonitorsProtocolX11() &&
     746                                              !gEDataManager->legacyFullscreenModeRequested();
     747            if (fUseNativeFullScreen)
     748            {
     749                /* Tell recent window managers which host-screen this window should be mapped to: */
     750                VBoxGlobal::setFullScreenMonitorX11(this, iHostScreen);
     751            }
     752
     753            /* Set appropriate window size: */
     754            const QSize newSize = workingArea.size();
     755            LogRel(("GUI: UIMiniToolBar::sltAdjust: Resize window to: %dx%d\n",
     756                    newSize.width(), newSize.height()));
     757            resize(newSize);
     758
     759            /* Move window onto required screen: */
     760            const QPoint newPosition = workingArea.topLeft();
     761            LogRel(("GUI: UIMiniToolBar::sltAdjust: Move window to: %dx%d\n",
     762                    newPosition.x(), newPosition.y()));
     763            move(newPosition);
     764
     765            /* Re-apply the full-screen state lost on above move(): */
     766            setWindowState(Qt::WindowFullScreen);
     767
     768            break;
     769        }
     770    }
    710771
    711772#else
     
    9671028                    break;
    9681029
    969 #if   defined(VBOX_WS_MAC)
    970                 // Nothing
    971 #elif defined(VBOX_WS_WIN)
    972                 /* Asynchronously call for sltShow() to adjust and expose both: */
     1030                /* Asynchronously call for sltShow(): */
    9731031                LogRel2(("GUI: UIMiniToolBar::eventFilter: Parent move/resize event\n"));
    9741032                QMetaObject::invokeMethod(this, "sltShow", Qt::QueuedConnection);
    975 #elif defined(VBOX_WS_X11)
    976                 /* Asynchronously call for just sltAdjust() because it's enough: */
    977                 LogRel2(("GUI: UIMiniToolBar::eventFilter: Parent move/resize event\n"));
    978                 QMetaObject::invokeMethod(this, "sltAdjust", Qt::QueuedConnection);
    979 #else
    980 # warning "port me"
    981 #endif
    9821033                break;
    9831034            }
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