VirtualBox

Changeset 88679 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Apr 23, 2021 2:50:25 PM (4 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:8161: A bit of cleanup for UIConsoleEventHandler.

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

Legend:

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

    r86541 r88679  
    55
    66/*
    7  * Copyright (C) 2010-2020 Oracle Corporation
     7 * Copyright (C) 2010-2021 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    1717
    1818/* GUI includes: */
     19#include "UICommon.h"
    1920#include "UIConsoleEventHandler.h"
     21#include "UIExtraDataManager.h"
    2022#include "UIMainEventListener.h"
    2123#include "UIMousePointerShapeData.h"
    22 #include "UIExtraDataManager.h"
    23 #include "UICommon.h"
    2424#include "UISession.h"
    2525#ifdef VBOX_WS_MAC
     
    2929/* COM includes: */
    3030#include "COMEnums.h"
     31#include "CConsole.h"
    3132#include "CEventListener.h"
    3233#include "CEventSource.h"
    33 #include "CConsole.h"
    3434
    3535
     
    9393    UIConsoleEventHandlerProxy(QObject *pParent, UISession *pSession);
    9494    /** Destructs event proxy object. */
    95     ~UIConsoleEventHandlerProxy();
    96 
    97 protected:
    98 
    99     /** @name Prepare/Cleanup cascade.
    100       * @{ */
    101         /** Prepares all. */
    102         void prepare();
    103         /** Prepares listener. */
    104         void prepareListener();
    105         /** Prepares connections. */
    106         void prepareConnections();
    107 
    108         /** Cleanups connections. */
    109         void cleanupConnections();
    110         /** Cleanups listener. */
    111         void cleanupListener();
    112         /** Cleanups all. */
    113         void cleanup();
    114     /** @} */
     95    virtual ~UIConsoleEventHandlerProxy() /* override */;
    11596
    11697private slots:
    11798
    118     /** @name Slots for waitable signals.
    119       * @{ */
    120         /** Returns whether VM window can be shown. */
    121         void sltCanShowWindow(bool &fVeto, QString &strReason);
    122         /** Shows VM window if possible. */
    123         void sltShowWindow(qint64 &winId);
    124     /** @} */
     99    /** Returns whether VM window can be shown. */
     100    void sltCanShowWindow(bool &fVeto, QString &strReason);
     101    /** Shows VM window if possible. */
     102    void sltShowWindow(qint64 &winId);
    125103
    126104private:
     105
     106    /** Prepares all. */
     107    void prepare();
     108    /** Prepares listener. */
     109    void prepareListener();
     110    /** Prepares connections. */
     111    void prepareConnections();
     112
     113    /** Cleanups connections. */
     114    void cleanupConnections();
     115    /** Cleanups listener. */
     116    void cleanupListener();
     117    /** Cleanups all. */
     118    void cleanup();
    127119
    128120    /** Holds the UI session reference. */
     
    144136    , m_pSession(pSession)
    145137{
    146     /* Prepare: */
    147138    prepare();
    148139}
     
    150141UIConsoleEventHandlerProxy::~UIConsoleEventHandlerProxy()
    151142{
    152     /* Cleanup: */
    153143    cleanup();
    154144}
    155145
     146void UIConsoleEventHandlerProxy::sltCanShowWindow(bool & /* fVeto */, QString & /* strReason */)
     147{
     148    /* Nothing for now. */
     149}
     150
     151void UIConsoleEventHandlerProxy::sltShowWindow(qint64 &winId)
     152{
     153#ifdef VBOX_WS_MAC
     154    /* First of all, just ask the GUI thread to show the machine-window: */
     155    winId = 0;
     156    if (::darwinSetFrontMostProcess())
     157        emit sigShowWindow();
     158    else
     159    {
     160        /* If it's failed for some reason, send the other process our PSN so it can try: */
     161        winId = ::darwinGetCurrentProcessId();
     162    }
     163#else /* !VBOX_WS_MAC */
     164    /* Return the ID of the top-level machine-window. */
     165    winId = (ULONG64)m_pSession->mainMachineWindowId();
     166#endif /* !VBOX_WS_MAC */
     167}
     168
    156169void UIConsoleEventHandlerProxy::prepare()
    157170{
    158     /* Prepare: */
    159171    prepareListener();
    160172    prepareConnections();
     
    203215        << KVBoxEventType_OnAudioAdapterChanged
    204216        << KVBoxEventType_OnClipboardModeChanged
    205         << KVBoxEventType_OnDnDModeChanged;
     217        << KVBoxEventType_OnDnDModeChanged
     218    ;
    206219
    207220    /* Register event listener for console event source: */
     
    311324void UIConsoleEventHandlerProxy::cleanup()
    312325{
    313     /* Cleanup: */
    314326    cleanupConnections();
    315327    cleanupListener();
    316 }
    317 
    318 void UIConsoleEventHandlerProxy::sltCanShowWindow(bool & /* fVeto */, QString & /* strReason */)
    319 {
    320     /* Nothing for now. */
    321 }
    322 
    323 void UIConsoleEventHandlerProxy::sltShowWindow(qint64 &winId)
    324 {
    325 #ifdef VBOX_WS_MAC
    326     /* First of all, just ask the GUI thread to show the machine-window: */
    327     winId = 0;
    328     if (::darwinSetFrontMostProcess())
    329         emit sigShowWindow();
    330     else
    331     {
    332         /* If it's failed for some reason, send the other process our PSN so it can try: */
    333         winId = ::darwinGetCurrentProcessId();
    334     }
    335 #else /* !VBOX_WS_MAC */
    336     /* Return the ID of the top-level machine-window. */
    337     winId = (ULONG64)m_pSession->mainMachineWindowId();
    338 #endif /* !VBOX_WS_MAC */
    339328}
    340329
     
    345334
    346335/* static */
    347 UIConsoleEventHandler *UIConsoleEventHandler::m_spInstance = 0;
     336UIConsoleEventHandler *UIConsoleEventHandler::s_pInstance = 0;
    348337
    349338/* static */
    350339void UIConsoleEventHandler::create(UISession *pSession)
    351340{
    352     if (!m_spInstance)
    353         m_spInstance = new UIConsoleEventHandler(pSession);
     341    if (!s_pInstance)
     342        s_pInstance = new UIConsoleEventHandler(pSession);
    354343}
    355344
     
    357346void UIConsoleEventHandler::destroy()
    358347{
    359     if (m_spInstance)
     348    if (s_pInstance)
    360349    {
    361         delete m_spInstance;
    362         m_spInstance = 0;
     350        delete s_pInstance;
     351        s_pInstance = 0;
    363352    }
    364353}
     
    367356    : m_pProxy(new UIConsoleEventHandlerProxy(this, pSession))
    368357{
    369     /* Prepare: */
    370358    prepare();
    371359}
     
    373361void UIConsoleEventHandler::prepare()
    374362{
    375     /* Prepare: */
    376363    prepareConnections();
    377364}
     
    393380            Qt::QueuedConnection);
    394381    connect(m_pProxy, &UIConsoleEventHandlerProxy::sigStateChange,
    395         this, &UIConsoleEventHandler::sigStateChange,
     382            this, &UIConsoleEventHandler::sigStateChange,
    396383            Qt::QueuedConnection);
    397384    connect(m_pProxy, &UIConsoleEventHandlerProxy::sigAdditionsChange,
     
    402389            Qt::QueuedConnection);
    403390    connect(m_pProxy, &UIConsoleEventHandlerProxy::sigStorageDeviceChange,
    404         this, &UIConsoleEventHandler::sigStorageDeviceChange,
     391            this, &UIConsoleEventHandler::sigStorageDeviceChange,
    405392            Qt::QueuedConnection);
    406393    connect(m_pProxy, &UIConsoleEventHandlerProxy::sigMediumChange,
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIConsoleEventHandler.h

    r82968 r88679  
    55
    66/*
    7  * Copyright (C) 2010-2020 Oracle Corporation
     7 * Copyright (C) 2010-2021 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    2828/* COM includes: */
    2929#include "COMEnums.h"
    30 #include "CVirtualBoxErrorInfo.h"
    3130#include "CMediumAttachment.h"
    3231#include "CNetworkAdapter.h"
    3332#include "CUSBDevice.h"
     33#include "CVirtualBoxErrorInfo.h"
    3434
    3535/* Forward declarations: */
     
    9696
    9797    /** Returns singleton instance created by the factory. */
    98     static UIConsoleEventHandler* instance() { return m_spInstance; }
     98    static UIConsoleEventHandler *instance() { return s_pInstance; }
    9999    /** Creates singleton instance created by the factory. */
    100100    static void create(UISession *pSession);
     
    107107    UIConsoleEventHandler(UISession *pSession);
    108108
    109     /** @name Prepare cascade.
    110       * @{ */
    111         /** Prepares all. */
    112         void prepare();
    113         /** Prepares connections. */
    114         void prepareConnections();
    115     /** @} */
     109    /** Prepares all. */
     110    void prepare();
     111    /** Prepares connections. */
     112    void prepareConnections();
    116113
    117114private:
    118115
    119116    /** Holds the singleton static console event handler instance. */
    120     static UIConsoleEventHandler *m_spInstance;
     117    static UIConsoleEventHandler *s_pInstance;
    121118
    122119    /** Holds the console event proxy instance. */
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