VirtualBox

Changeset 50824 in vbox for trunk/src


Ignore:
Timestamp:
Mar 19, 2014 1:01:27 PM (11 years ago)
Author:
vboxsync
Message:

FE/Qt: Runtime UI: Mouse-handling: Do not try to activate hovered machine-window instantly, it's causing races and conflicts with Apple HIG. Version 2.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/runtime
Files:
2 edited

Legend:

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

    r50823 r50824  
    2222#include <QMouseEvent>
    2323#include <QTouchEvent>
     24#include <QTimer>
    2425
    2526/* GUI includes: */
     
    426427}
    427428
     429void UIMouseHandler::sltMaybeActivateHoveredWindow()
     430{
     431    /* Are we still have hovered window to activate? */
     432    if (m_pHoveredWindow && !m_pHoveredWindow->isActiveWindow())
     433    {
     434        /* Activate it: */
     435        m_pHoveredWindow->activateWindow();
     436#ifdef Q_WS_X11
     437        /* On X11 its not enough to just activate window if you
     438         * want to raise it also, so we will make it separately: */
     439        m_pHoveredWindow->raise();
     440#endif /* Q_WS_X11 */
     441    }
     442}
     443
    428444/* Mouse-handler constructor: */
    429445UIMouseHandler::UIMouseHandler(UIMachineLogic *pMachineLogic)
     
    597613                        QApplication::activeWindow() != pWatchedWidget->window())
    598614                    {
    599                         /* Activating hovered machine window: */
    600                         pWatchedWidget->window()->activateWindow();
    601 #ifdef Q_WS_X11
    602                         /* On X11 its not enough to just activate window if you
    603                          * want to raise it also, so we will make it separately: */
    604                         pWatchedWidget->window()->raise();
    605 #endif /* Q_WS_X11 */
     615                        /* Put request for hovered window activation in 300msec: */
     616                        m_pHoveredWindow = pWatchedWidget->window();
     617                        QTimer::singleShot(300, this, SLOT(sltMaybeActivateHoveredWindow()));
     618                    }
     619                    else
     620                    {
     621                        /* Revoke request for hovered window activation: */
     622                        m_pHoveredWindow = 0;
    606623                    }
    607624
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMouseHandler.h

    r47478 r50824  
    2525#include <QMap>
    2626#include <QRect>
     27#include <QPointer>
    2728
    2829/* GUI includes: */
     
    8687    virtual void sltMousePointerShapeChanged();
    8788
     89    /** Activate hovered window if any. */
     90    void sltMaybeActivateHoveredWindow();
     91
    8892protected:
    8993
     
    126130    QMap<ulong, QWidget*> m_viewports;
    127131
     132    /** Hovered window to be activated. */
     133    QPointer<QWidget> m_pHoveredWindow;
     134
    128135    /* Other mouse variables: */
    129136    QPoint m_lastMousePos;
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