VirtualBox

Changeset 92848 in vbox


Ignore:
Timestamp:
Dec 9, 2021 1:48:59 PM (3 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
148777
Message:

FE/Qt: bugref:10166: UIMiniToolBar: Reworking old machine-window focus stealing workaround to be more careful; You can't just manipulate window activation state while popups shown and remain sane.

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

Legend:

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

    r91066 r92848  
    585585}
    586586
     587void UIMiniToolBar::sltCheckWindowActivationSanity()
     588{
     589    /* Do nothing if other window is already active: */
     590    if (QGuiApplication::focusWindow() != windowHandle())
     591        return;
     592
     593    /* We can't touch window activation if have modal or popup
     594     * window opened, otherwise internal Qt state get flawed: */
     595    if (   QApplication::activeModalWidget()
     596        || QApplication::activePopupWidget())
     597    {
     598        /* But we should recheck the state in let's say 300ms: */
     599        QTimer::singleShot(300, this, SLOT(sltCheckWindowActivationSanity()));
     600        return;
     601    }
     602
     603    /* Notify listener about we have stole window activation: */
     604    emit sigNotifyAboutWindowActivationStolen();
     605}
     606
    587607void UIMiniToolBar::sltHide()
    588608{
     
    9991019    {
    10001020#if   defined(VBOX_WS_WIN)
    1001         emit sigNotifyAboutWindowActivationStolen();
     1021        /* Just call the method asynchronously, after possible popups opened: */
     1022        QTimer::singleShot(0, this, SLOT(sltCheckWindowActivationSanity()));
    10021023#elif defined(VBOX_WS_X11)
    10031024        switch (uiCommon().typeOfWindowManager())
     
    10111032                // In fact, Qt is not become aware of actual window activation later,
    10121033                // so we are going to return window activation in let's say 100ms.
    1013                 QTimer::singleShot(100, this, SLOT(sltNotifyAboutWindowActivationStolen()));
     1034                QTimer::singleShot(100, this, SLOT(sltCheckWindowActivationSanity()));
    10141035                break;
    10151036            }
    10161037            default:
    10171038            {
    1018                 emit sigNotifyAboutWindowActivationStolen();
     1039                /* Just call the method asynchronously, after possible popups opened: */
     1040                QTimer::singleShot(0, this, SLOT(sltCheckWindowActivationSanity()));
    10191041                break;
    10201042            }
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIMiniToolBar.h

    r88635 r92848  
    120120    void sltHoverLeave();
    121121
    122     /** Notifies listeners about we stole window activation. */
    123     void sltNotifyAboutWindowActivationStolen() { emit sigNotifyAboutWindowActivationStolen(); }
     122    /** Check whether we still have window activation token. */
     123    void sltCheckWindowActivationSanity();
    124124
    125125    /** Hides window. */
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