VirtualBox

Ignore:
Timestamp:
Mar 19, 2014 7:47:53 AM (11 years ago)
Author:
vboxsync
Message:

FE/Qt: Runtime UI: Fullscreen/Seamless modes: Prevent mini-toolbar from stealing focus from machine-view.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/fullscreen/UIMachineWindowFullscreen.cpp

    r50681 r50816  
    164164}
    165165#endif /* Q_WS_MAC */
     166
     167void UIMachineWindowFullscreen::sltRevokeFocus()
     168{
     169    /* Revoke stolen focus: */
     170    m_pMachineView->setFocus();
     171}
    166172
    167173void UIMachineWindowFullscreen::prepareMenu()
     
    248254    connect(m_pMiniToolBar, SIGNAL(sigCloseAction()),
    249255            gActionPool->action(UIActionIndexRuntime_Simple_Close), SLOT(trigger()));
     256    connect(m_pMiniToolBar, SIGNAL(sigNotifyAboutFocusStolen()), this, SLOT(sltRevokeFocus()));
    250257}
    251258
     
    345352    placeOnScreen();
    346353
    347 #ifdef Q_WS_WIN
    348     /* On Windows we should activate main window first,
    349      * because entering fullscreen there doesn't means window will be auto-activated,
    350      * so no window-activation event will be received and no keyboard-hook created otherwise... */
    351     if (m_uScreenId == 0)
    352         setWindowState(windowState() | Qt::WindowActive);
    353 #endif /* Q_WS_WIN */
    354 
    355354#ifdef Q_WS_MAC
    356355    /* ML and next using native stuff, so we can call for simple show(): */
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/fullscreen/UIMachineWindowFullscreen.h

    r50681 r50816  
    7070#endif /* RT_OS_DARWIN */
    7171
     72    /** Revokes keyboard-focus. */
     73    void sltRevokeFocus();
     74
    7275private:
    7376
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/seamless/UIMachineWindowSeamless.cpp

    r50631 r50816  
    6969        QTimer::singleShot(0, m_pMainMenu, SLOT(sltHighlightFirstAction()));
    7070    }
     71}
     72
     73void UIMachineWindowSeamless::sltRevokeFocus()
     74{
     75    /* Revoke stolen focus: */
     76    m_pMachineView->setFocus();
    7177}
    7278
     
    152158    connect(m_pMiniToolBar, SIGNAL(sigCloseAction()),
    153159            gActionPool->action(UIActionIndexRuntime_Simple_Close), SLOT(trigger()));
     160    connect(m_pMiniToolBar, SIGNAL(sigNotifyAboutFocusStolen()), this, SLOT(sltRevokeFocus()));
    154161}
    155162#endif /* !Q_WS_MAC */
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/seamless/UIMachineWindowSeamless.h

    r50535 r50816  
    4545    /* Popup main menu: */
    4646    void sltPopupMainMenu();
     47
     48    /** Revokes keyboard-focus. */
     49    void sltRevokeFocus();
    4750
    4851private:
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIMiniToolBar.cpp

    r49758 r50816  
    193193    /* Simulate toolbar auto-hiding: */
    194194    simulateToolbarAutoHiding();
    195 
    196     /* Due to [probably] Qt bug QMdiSubWindow still
    197      * can receive focus even if focus policy is Qt::NoFocus,
    198      * We should return the focus to our parent: */
    199     parentWidget()->setFocus();
    200195}
    201196
     
    260255    m_pToolbar = new UIMiniToolBar;
    261256    {
     257        /* Make sure we have no focus: */
     258        m_pToolbar->setFocusPolicy(Qt::NoFocus);
    262259        /* Propagate known options to child: */
    263260        m_pToolbar->setAutoHide(m_fAutoHide);
     
    279276        m_pEmbeddedToolbar = m_pMdiArea->addSubWindow(m_pToolbar, Qt::Window | Qt::FramelessWindowHint);
    280277        /* Make sure we have no focus: */
    281         m_pToolbar->setFocusPolicy(Qt::NoFocus);
    282278        m_pEmbeddedToolbar->setFocusPolicy(Qt::NoFocus);
     279        m_pEmbeddedToolbar->installEventFilter(this);
    283280    }
    284281
     
    340337    if (m_fAutoHide)
    341338        m_pHoverLeaveTimer->start();
     339}
     340
     341bool UIRuntimeMiniToolBar::eventFilter(QObject *pWatched, QEvent *pEvent)
     342{
     343    /* Due to Qt bug QMdiArea can
     344     * 1. steal focus from current application focus-widget
     345     * 3. and even request focus stealing if QMdiArea hidden yet.
     346     * We have to notify listeners about such facts.. */
     347    if (pWatched && m_pEmbeddedToolbar && pWatched == m_pEmbeddedToolbar &&
     348        pEvent->type() == QEvent::FocusIn)
     349        emit sigNotifyAboutFocusStolen();
     350    /* Call to base-class: */
     351    return QWidget::eventFilter(pWatched, pEvent);
    342352}
    343353
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIMiniToolBar.h

    r49758 r50816  
    6464    void sigHoverLeave();
    6565
     66    /** Notifies listeners about we stole focus. */
     67    void sigNotifyAboutFocusStolen();
     68
    6669public:
    6770
     
    109112    void enterEvent(QEvent *pEvent);
    110113    void leaveEvent(QEvent *pEvent);
     114
     115    /** Filters @a pEvent if <i>this</i> object has been
     116      * installed as an event-filter for the @a pWatched. */
     117    bool eventFilter(QObject *pWatched, QEvent *pEvent);
    111118
    112119    /* Helper: Hover stuff: */
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