- Timestamp:
- Sep 30, 2014 2:53:05 PM (10 years ago)
- svn:sync-xref-src-repo-rev:
- 96328
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/runtime
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIConsoleEventHandler.cpp
r52894 r52898 5 5 6 6 /* 7 * Copyright (C) 2010-201 3Oracle Corporation7 * Copyright (C) 2010-2014 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 43 43 { 44 44 if (!m_pInstance) 45 { 45 46 m_pInstance = new UIConsoleEventHandler(pSession); 47 m_pInstance->prepare(); 48 } 46 49 return m_pInstance; 47 50 } … … 52 55 if (m_pInstance) 53 56 { 57 m_pInstance->cleanup(); 54 58 delete m_pInstance; 55 59 m_pInstance = 0; 56 }57 }58 59 UIConsoleEventHandler::UIConsoleEventHandler(UISession *pSession)60 : m_pSession(pSession)61 {62 Assert(pSession);63 64 // RTPrintf("Self add: %RTthrd\n", RTThreadSelf());65 ComObjPtr<UIMainEventListenerImpl> pListener;66 pListener.createObject();67 pListener->init(new UIMainEventListener(), this);68 m_mainEventListener = CEventListener(pListener);69 QVector<KVBoxEventType> events;70 events71 << KVBoxEventType_OnMousePointerShapeChanged72 << KVBoxEventType_OnMouseCapabilityChanged73 << KVBoxEventType_OnKeyboardLedsChanged74 << KVBoxEventType_OnStateChanged75 << KVBoxEventType_OnAdditionsStateChanged76 << KVBoxEventType_OnNetworkAdapterChanged77 << KVBoxEventType_OnMediumChanged78 << KVBoxEventType_OnVRDEServerChanged79 << KVBoxEventType_OnVRDEServerInfoChanged80 << KVBoxEventType_OnVideoCaptureChanged81 << KVBoxEventType_OnUSBControllerChanged82 << KVBoxEventType_OnUSBDeviceStateChanged83 << KVBoxEventType_OnSharedFolderChanged84 << KVBoxEventType_OnRuntimeError85 << KVBoxEventType_OnCanShowWindow86 << KVBoxEventType_OnShowWindow87 << KVBoxEventType_OnCPUExecutionCapChanged88 << KVBoxEventType_OnGuestMonitorChanged;89 90 const CConsole &console = m_pSession->session().GetConsole();91 console.GetEventSource().RegisterListener(m_mainEventListener, events, TRUE);92 AssertWrapperOk(console);93 94 connect(pListener->getWrapped(), SIGNAL(sigMousePointerShapeChange(bool, bool, QPoint, QSize, QVector<uint8_t>)),95 this, SIGNAL(sigMousePointerShapeChange(bool, bool, QPoint, QSize, QVector<uint8_t>)),96 Qt::QueuedConnection);97 98 connect(pListener->getWrapped(), SIGNAL(sigMouseCapabilityChange(bool, bool, bool, bool)),99 this, SIGNAL(sigMouseCapabilityChange(bool, bool, bool, bool)),100 Qt::QueuedConnection);101 102 connect(pListener->getWrapped(), SIGNAL(sigKeyboardLedsChangeEvent(bool, bool, bool)),103 this, SIGNAL(sigKeyboardLedsChangeEvent(bool, bool, bool)),104 Qt::QueuedConnection);105 106 connect(pListener->getWrapped(), SIGNAL(sigStateChange(KMachineState)),107 this, SIGNAL(sigStateChange(KMachineState)),108 Qt::QueuedConnection);109 110 connect(pListener->getWrapped(), SIGNAL(sigAdditionsChange()),111 this, SIGNAL(sigAdditionsChange()),112 Qt::QueuedConnection);113 114 connect(pListener->getWrapped(), SIGNAL(sigNetworkAdapterChange(CNetworkAdapter)),115 this, SIGNAL(sigNetworkAdapterChange(CNetworkAdapter)),116 Qt::QueuedConnection);117 118 connect(pListener->getWrapped(), SIGNAL(sigMediumChange(CMediumAttachment)),119 this, SIGNAL(sigMediumChange(CMediumAttachment)),120 Qt::QueuedConnection);121 122 connect(pListener->getWrapped(), SIGNAL(sigVRDEChange()),123 this, SIGNAL(sigVRDEChange()),124 Qt::QueuedConnection);125 126 connect(pListener->getWrapped(), SIGNAL(sigVideoCaptureChange()),127 this, SIGNAL(sigVideoCaptureChange()),128 Qt::QueuedConnection);129 130 connect(pListener->getWrapped(), SIGNAL(sigUSBControllerChange()),131 this, SIGNAL(sigUSBControllerChange()),132 Qt::QueuedConnection);133 134 connect(pListener->getWrapped(), SIGNAL(sigUSBDeviceStateChange(CUSBDevice, bool, CVirtualBoxErrorInfo)),135 this, SIGNAL(sigUSBDeviceStateChange(CUSBDevice, bool, CVirtualBoxErrorInfo)),136 Qt::QueuedConnection);137 138 connect(pListener->getWrapped(), SIGNAL(sigSharedFolderChange()),139 this, SIGNAL(sigSharedFolderChange()),140 Qt::QueuedConnection);141 142 connect(pListener->getWrapped(), SIGNAL(sigRuntimeError(bool, QString, QString)),143 this, SIGNAL(sigRuntimeError(bool, QString, QString)),144 Qt::QueuedConnection);145 146 /* This is a vetoable event, so we have to respond to the event and have to147 * use a direct connection therefor. */148 connect(pListener->getWrapped(), SIGNAL(sigCanShowWindow(bool&, QString&)),149 this, SLOT(sltCanShowWindow(bool&, QString&)),150 Qt::DirectConnection);151 152 /* This returns a winId, so we have to respond to the event and have to use153 * a direct connection therefor. */154 connect(pListener->getWrapped(), SIGNAL(sigShowWindow(LONG64&)),155 this, SLOT(sltShowWindow(LONG64&)),156 Qt::DirectConnection);157 158 connect(pListener->getWrapped(), SIGNAL(sigCPUExecutionCapChange()),159 this, SIGNAL(sigCPUExecutionCapChange()),160 Qt::QueuedConnection);161 162 connect(pListener->getWrapped(), SIGNAL(sigGuestMonitorChange(KGuestMonitorChangedEventType, ulong, QRect)),163 this, SIGNAL(sigGuestMonitorChange(KGuestMonitorChangedEventType, ulong, QRect)),164 Qt::QueuedConnection);165 }166 167 UIConsoleEventHandler::~UIConsoleEventHandler()168 {169 const CConsole &console = m_pSession->session().GetConsole();170 if (!console.isNull())171 {172 CEventSource eventSource = console.GetEventSource();173 if (!eventSource.isNull())174 eventSource.UnregisterListener(m_mainEventListener);175 60 } 176 61 } … … 203 88 } 204 89 90 UIConsoleEventHandler::UIConsoleEventHandler(UISession *pSession) 91 : m_pSession(pSession) 92 { 93 } 94 95 void UIConsoleEventHandler::prepare() 96 { 97 /* Make sure session is passed: */ 98 AssertPtrReturnVoid(m_pSession); 99 100 /* Create Main-event listener instance: */ 101 ComObjPtr<UIMainEventListenerImpl> pListener; 102 pListener.createObject(); 103 pListener->init(new UIMainEventListener, this); 104 m_mainEventListener = CEventListener(pListener); 105 106 /* Get console: */ 107 const CConsole console = m_pSession->session().GetConsole(); 108 AssertReturnVoid(!console.isNull() && console.isOk()); 109 /* Get event-source: */ 110 CEventSource eventSource = console.GetEventSource(); 111 AssertReturnVoid(!eventSource.isNull() && eventSource.isOk()); 112 /* Register listener for expected event-types: */ 113 QVector<KVBoxEventType> events; 114 events 115 << KVBoxEventType_OnMousePointerShapeChanged 116 << KVBoxEventType_OnMouseCapabilityChanged 117 << KVBoxEventType_OnKeyboardLedsChanged 118 << KVBoxEventType_OnStateChanged 119 << KVBoxEventType_OnAdditionsStateChanged 120 << KVBoxEventType_OnNetworkAdapterChanged 121 << KVBoxEventType_OnMediumChanged 122 << KVBoxEventType_OnVRDEServerChanged 123 << KVBoxEventType_OnVRDEServerInfoChanged 124 << KVBoxEventType_OnVideoCaptureChanged 125 << KVBoxEventType_OnUSBControllerChanged 126 << KVBoxEventType_OnUSBDeviceStateChanged 127 << KVBoxEventType_OnSharedFolderChanged 128 << KVBoxEventType_OnCPUExecutionCapChanged 129 << KVBoxEventType_OnGuestMonitorChanged 130 << KVBoxEventType_OnRuntimeError 131 << KVBoxEventType_OnCanShowWindow 132 << KVBoxEventType_OnShowWindow; 133 eventSource.RegisterListener(m_mainEventListener, events, TRUE); 134 135 136 /* Prepare connections: */ 137 connect(pListener->getWrapped(), SIGNAL(sigMousePointerShapeChange(bool, bool, QPoint, QSize, QVector<uint8_t>)), 138 this, SIGNAL(sigMousePointerShapeChange(bool, bool, QPoint, QSize, QVector<uint8_t>)), 139 Qt::QueuedConnection); 140 connect(pListener->getWrapped(), SIGNAL(sigMouseCapabilityChange(bool, bool, bool, bool)), 141 this, SIGNAL(sigMouseCapabilityChange(bool, bool, bool, bool)), 142 Qt::QueuedConnection); 143 connect(pListener->getWrapped(), SIGNAL(sigKeyboardLedsChangeEvent(bool, bool, bool)), 144 this, SIGNAL(sigKeyboardLedsChangeEvent(bool, bool, bool)), 145 Qt::QueuedConnection); 146 connect(pListener->getWrapped(), SIGNAL(sigStateChange(KMachineState)), 147 this, SIGNAL(sigStateChange(KMachineState)), 148 Qt::QueuedConnection); 149 connect(pListener->getWrapped(), SIGNAL(sigAdditionsChange()), 150 this, SIGNAL(sigAdditionsChange()), 151 Qt::QueuedConnection); 152 connect(pListener->getWrapped(), SIGNAL(sigNetworkAdapterChange(CNetworkAdapter)), 153 this, SIGNAL(sigNetworkAdapterChange(CNetworkAdapter)), 154 Qt::QueuedConnection); 155 connect(pListener->getWrapped(), SIGNAL(sigMediumChange(CMediumAttachment)), 156 this, SIGNAL(sigMediumChange(CMediumAttachment)), 157 Qt::QueuedConnection); 158 connect(pListener->getWrapped(), SIGNAL(sigVRDEChange()), 159 this, SIGNAL(sigVRDEChange()), 160 Qt::QueuedConnection); 161 connect(pListener->getWrapped(), SIGNAL(sigVideoCaptureChange()), 162 this, SIGNAL(sigVideoCaptureChange()), 163 Qt::QueuedConnection); 164 connect(pListener->getWrapped(), SIGNAL(sigUSBControllerChange()), 165 this, SIGNAL(sigUSBControllerChange()), 166 Qt::QueuedConnection); 167 connect(pListener->getWrapped(), SIGNAL(sigUSBDeviceStateChange(CUSBDevice, bool, CVirtualBoxErrorInfo)), 168 this, SIGNAL(sigUSBDeviceStateChange(CUSBDevice, bool, CVirtualBoxErrorInfo)), 169 Qt::QueuedConnection); 170 connect(pListener->getWrapped(), SIGNAL(sigSharedFolderChange()), 171 this, SIGNAL(sigSharedFolderChange()), 172 Qt::QueuedConnection); 173 connect(pListener->getWrapped(), SIGNAL(sigCPUExecutionCapChange()), 174 this, SIGNAL(sigCPUExecutionCapChange()), 175 Qt::QueuedConnection); 176 connect(pListener->getWrapped(), SIGNAL(sigGuestMonitorChange(KGuestMonitorChangedEventType, ulong, QRect)), 177 this, SIGNAL(sigGuestMonitorChange(KGuestMonitorChangedEventType, ulong, QRect)), 178 Qt::QueuedConnection); 179 180 connect(pListener->getWrapped(), SIGNAL(sigRuntimeError(bool, QString, QString)), 181 this, SIGNAL(sigRuntimeError(bool, QString, QString)), 182 Qt::QueuedConnection); 183 184 /* This is a vetoable event, so we have to respond to the event and have to 185 * use a direct connection therefor. */ 186 connect(pListener->getWrapped(), SIGNAL(sigCanShowWindow(bool&, QString&)), 187 this, SLOT(sltCanShowWindow(bool&, QString&)), 188 Qt::DirectConnection); 189 /* This returns a winId, so we have to respond to the event and have to use 190 * a direct connection therefor. */ 191 connect(pListener->getWrapped(), SIGNAL(sigShowWindow(LONG64&)), 192 this, SLOT(sltShowWindow(LONG64&)), 193 Qt::DirectConnection); 194 } 195 196 void UIConsoleEventHandler::cleanup() 197 { 198 /* Get console: */ 199 const CConsole console = m_pSession->session().GetConsole(); 200 if (console.isNull() || !console.isOk()) 201 return; 202 /* Get event-source: */ 203 CEventSource eventSource = console.GetEventSource(); 204 AssertReturnVoid(!eventSource.isNull() || eventSource.isOk()); 205 /* Unregister listener: */ 206 eventSource.UnregisterListener(m_mainEventListener); 207 } 208 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIConsoleEventHandler.h
r52727 r52898 4 4 5 5 /* 6 * Copyright (C) 2010-201 3Oracle Corporation6 * Copyright (C) 2010-2014 Oracle Corporation 7 7 * 8 8 * This file is part of VirtualBox Open Source Edition (OSE), as … … 15 15 */ 16 16 17 #ifndef __ UIConsoleEventHandler_h__18 #define __ UIConsoleEventHandler_h__17 #ifndef ___UIConsoleEventHandler_h___ 18 #define ___UIConsoleEventHandler_h___ 19 19 20 20 /* COM includes: */ 21 21 #include "COMEnums.h" 22 #include "CEventListener.h" 22 23 #include "CVirtualBoxErrorInfo.h" 23 #include "CEventListener.h"24 24 #include "CMediumAttachment.h" 25 25 #include "CNetworkAdapter.h" … … 29 29 class UISession; 30 30 31 /** Console event handler. */ 31 32 class UIConsoleEventHandler: public QObject 32 33 { 33 34 Q_OBJECT; 34 35 36 signals: 37 38 /** Notifies about mouse pointer shape change. */ 39 void sigMousePointerShapeChange(bool fVisible, bool fAlpha, QPoint hotCorner, QSize size, QVector<uint8_t> shape); 40 /** Notifies about mouse capability change. */ 41 void sigMouseCapabilityChange(bool fSupportsAbsolute, bool fSupportsRelative, bool fSupportsMultiTouch, bool fNeedsHostCursor); 42 /** Notifies about keyboard LEDs change. */ 43 void sigKeyboardLedsChangeEvent(bool fNumLock, bool fCapsLock, bool fScrollLock); 44 /** Notifies about machine state change. */ 45 void sigStateChange(KMachineState state); 46 /** Notifies about guest additions state change. */ 47 void sigAdditionsChange(); 48 /** Notifies about network adapter state change. */ 49 void sigNetworkAdapterChange(CNetworkAdapter adapter); 50 /** Notifies about storage medium state change. */ 51 void sigMediumChange(CMediumAttachment attachment); 52 /** Notifies about VRDE device state change. */ 53 void sigVRDEChange(); 54 /** Notifies about Video Capture device state change. */ 55 void sigVideoCaptureChange(); 56 /** Notifies about USB controller state change. */ 57 void sigUSBControllerChange(); 58 /** Notifies about USB device state change. */ 59 void sigUSBDeviceStateChange(CUSBDevice device, bool fAttached, CVirtualBoxErrorInfo error); 60 /** Notifies about shared folder state change. */ 61 void sigSharedFolderChange(); 62 /** Notifies about CPU execution-cap change. */ 63 void sigCPUExecutionCapChange(); 64 /** Notifies about guest-screen configuration change. */ 65 void sigGuestMonitorChange(KGuestMonitorChangedEventType changeType, ulong uScreenId, QRect screenGeo); 66 /** Notifies about Runtime error. */ 67 void sigRuntimeError(bool fFatal, QString strId, QString strMessage); 68 #ifdef RT_OS_DARWIN 69 /** Notifies about VM window should be shown. */ 70 void sigShowWindow(); 71 #endif /* RT_OS_DARWIN */ 72 35 73 public: 74 75 /** Static instance factory. */ 36 76 static UIConsoleEventHandler* instance(UISession *pSession = 0); 77 /** Static instance destructor. */ 37 78 static void destroy(); 38 79 39 signals: 40 void sigMousePointerShapeChange(bool fVisible, bool fAlpha, QPoint hotCorner, QSize size, QVector<uint8_t> shape); 41 void sigMouseCapabilityChange(bool fSupportsAbsolute, bool fSupportsRelative, bool fSupportsMultiTouch, bool fNeedsHostCursor); 42 void sigKeyboardLedsChangeEvent(bool fNumLock, bool fCapsLock, bool fScrollLock); 43 void sigStateChange(KMachineState state); 44 void sigAdditionsChange(); 45 void sigNetworkAdapterChange(CNetworkAdapter adapter); 46 void sigMediumChange(CMediumAttachment attachment); 47 void sigVRDEChange(); 48 void sigVideoCaptureChange(); 49 void sigUSBControllerChange(); 50 void sigUSBDeviceStateChange(CUSBDevice device, bool fAttached, CVirtualBoxErrorInfo error); 51 void sigSharedFolderChange(); 52 void sigRuntimeError(bool fFatal, QString strId, QString strMessage); 53 #ifdef RT_OS_DARWIN 54 void sigShowWindow(); 55 #endif /* RT_OS_DARWIN */ 56 void sigCPUExecutionCapChange(); 57 void sigGuestMonitorChange(KGuestMonitorChangedEventType changeType, ulong uScreenId, QRect screenGeo); 80 private slots: 58 81 59 private slots: 82 /** Returns whether VM window can be shown. */ 60 83 void sltCanShowWindow(bool &fVeto, QString &strReason); 84 /** Shows VM window if possible. */ 61 85 void sltShowWindow(LONG64 &winId); 62 86 63 87 private: 88 89 /** Constructor: */ 64 90 UIConsoleEventHandler(UISession *pSession); 65 ~UIConsoleEventHandler();66 91 92 /** Prepare routine. */ 93 void prepare(); 94 /** Cleanup routine. */ 95 void cleanup(); 96 97 /** Holds the static instance. */ 67 98 static UIConsoleEventHandler *m_pInstance; 99 100 /** Holds the UI session reference. */ 68 101 UISession *m_pSession; 102 103 /** Holds the main event listener instance. */ 69 104 CEventListener m_mainEventListener; 70 105 }; … … 72 107 #define gConsoleEvents UIConsoleEventHandler::instance() 73 108 74 #endif /* !__UIConsoleEventHandler_h__ */ 75 109 #endif /* !___UIConsoleEventHandler_h___ */
Note:
See TracChangeset
for help on using the changeset viewer.