VirtualBox

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


Ignore:
Timestamp:
Sep 17, 2013 3:02:04 PM (11 years ago)
Author:
vboxsync
Message:

FE/Qt: 5105: Runtime UI: Few more dummy handlers for guest=>host lock synchronization (part 2).

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

Legend:

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

    r48496 r48504  
    2525#include <QPainter>
    2626#include <QTimer>
     27#include <QDateTime>
    2728#ifdef Q_WS_MAC
    2829# include <QMenuBar>
     
    10101011void UIMachineLogic::cleanupActionGroups()
    10111012{
     1013}
     1014
     1015bool UIMachineLogic::eventFilter(QObject *pWatched, QEvent *pEvent)
     1016{
     1017    /* Handle machine-window events: */
     1018    if (UIMachineWindow *pMachineWindow = qobject_cast<UIMachineWindow*>(pWatched))
     1019    {
     1020        /* Make sure this window still registered: */
     1021        if (isMachineWindowsCreated() && m_machineWindowsList.contains(pMachineWindow))
     1022        {
     1023            switch (pEvent->type())
     1024            {
     1025                /* Handle *window activated* event: */
     1026                case QEvent::WindowActivate:
     1027                {
     1028                    /* We should save current lock states as *previous* and
     1029                     * set current lock states to guest values we have,
     1030                     * As we have no ipc between threads of different VMs
     1031                     * we are using 300ms timer as lazy sync timout: */
     1032                    QTimer::singleShot(300, this, SLOT(sltSwitchKeyboardLedsToGuestLeds()));
     1033                    break;
     1034                }
     1035                /* Handle *window deactivated* event: */
     1036                case QEvent::WindowDeactivate:
     1037                {
     1038                    /* We should restore lock states to *previous* known: */
     1039                    sltSwitchKeyboardLedsToPreviousLeds();
     1040                    break;
     1041                }
     1042                /* Default: */
     1043                default: break;
     1044            }
     1045        }
     1046    }
     1047    /* Call to base-class: */
     1048    return QIWithRetranslateUI3<QObject>::eventFilter(pWatched, pEvent);
    10121049}
    10131050
     
    21372174#endif /* Q_WS_MAC */
    21382175
     2176void UIMachineLogic::sltSwitchKeyboardLedsToGuestLeds()
     2177{
     2178//    /* Log statement (printf): */
     2179//    QString strDt = QDateTime::currentDateTime().toString("HH:mm:ss:zzz");
     2180//    printf("%s: UIMachineLogic: sltSwitchKeyboardLedsToGuestLeds called, machine name is {%s}\n",
     2181//           strDt.toAscii().constData(),
     2182//           session().GetMachine().GetName().toAscii().constData());
     2183
     2184    /* Here we have to save current host LED lock states in UISession registry.
     2185     * [void] uisession() -> setHostNumLock(), setHostCapsLock(), setHostScrollLock() can be used for that. */
     2186
     2187    /* Here we have to update host LED lock states using values provided by UISession registry.
     2188     * [bool] uisession() -> isNumLock(), isCapsLock(), isScrollLock() can be used for that. */
     2189}
     2190
     2191void UIMachineLogic::sltSwitchKeyboardLedsToPreviousLeds()
     2192{
     2193//    /* Log statement (printf): */
     2194//    QString strDt = QDateTime::currentDateTime().toString("HH:mm:ss:zzz");
     2195//    printf("%s: UIMachineLogic: sltSwitchKeyboardLedsToPreviousLeds called, machine name is {%s}\n",
     2196//           strDt.toAscii().constData(),
     2197//           session().GetMachine().GetName().toAscii().constData());
     2198
     2199    /* Here we have to restore host LED lock states from UISession registry.
     2200     * [bool] uisession() -> isHostNumLock(), isHostCapsLock(), isHostScrollLock() can be used for that. */
     2201}
     2202
    21392203int UIMachineLogic::searchMaxSnapshotIndex(const CMachine &machine,
    21402204                                           const CSnapshot &snapshot,
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.h

    r48386 r48504  
    165165    //virtual void cleanupSessionConnections() {}
    166166    //virtual void cleanupRequiredFeatures() {}
     167
     168    /* Handler: Event-filter stuff: */
     169    bool eventFilter(QObject *pWatched, QEvent *pEvent);
    167170
    168171private slots:
     
    222225#endif /* RT_OS_DARWIN */
    223226
     227    /* Handlers: Keyboard LEDs sync logic: */
     228    void sltSwitchKeyboardLedsToGuestLeds();
     229    void sltSwitchKeyboardLedsToPreviousLeds();
     230
    224231private:
    225232
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.cpp

    r48314 r48504  
    9999    , m_fCapsLock(false)
    100100    , m_fScrollLock(false)
     101    , m_fHostNumLock(false)
     102    , m_fHostCapsLock(false)
     103    , m_fHostScrollLock(false)
    101104    , m_uNumLockAdaptionCnt(2)
    102105    , m_uCapsLockAdaptionCnt(2)
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.h

    r47478 r48504  
    134134    bool isCapsLock() const { return m_fCapsLock; }
    135135    bool isScrollLock() const { return m_fScrollLock; }
     136    bool isHostNumLock() const { return m_fHostNumLock; }
     137    bool isHostCapsLock() const { return m_fHostCapsLock; }
     138    bool isHostScrollLock() const { return m_fHostScrollLock; }
     139    void setHostNumLock(bool fHostNumLock) { m_fHostNumLock = fHostNumLock; }
     140    void setHostCapsLock(bool fHostCapsLock) { m_fHostCapsLock = fHostCapsLock; }
     141    void setHostScrollLock(bool fHostScrollLock) { m_fHostScrollLock = fHostScrollLock; }
    136142    uint numLockAdaptionCnt() const { return m_uNumLockAdaptionCnt; }
    137143    uint capsLockAdaptionCnt() const { return m_uCapsLockAdaptionCnt; }
     
    300306    bool m_fCapsLock : 1;
    301307    bool m_fScrollLock : 1;
     308    bool m_fHostNumLock : 1;
     309    bool m_fHostCapsLock : 1;
     310    bool m_fHostScrollLock : 1;
    302311    uint m_uNumLockAdaptionCnt;
    303312    uint m_uCapsLockAdaptionCnt;
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